Skip to content

Commit b112708

Browse files
ebiggersidryomov
authored andcommitted
libceph: don't WARN() if user tries to add invalid key
The WARN_ON(!key->len) in set_secret() in net/ceph/crypto.c is hit if a user tries to add a key of type "ceph" with an invalid payload as follows (assuming CONFIG_CEPH_LIB=y): echo -e -n '\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \ | keyctl padd ceph desc @s This can be hit by fuzzers. As this is merely bad input and not a kernel bug, replace the WARN_ON() with return -EINVAL. Fixes: 7af3ea1 ("libceph: stop allocating a new cipher on every crypto request") Cc: <stable@vger.kernel.org> # v4.10+ Signed-off-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 7c08428 commit b112708

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎net/ceph/crypto.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ static int set_secret(struct ceph_crypto_key *key, void *buf)
3737
return -ENOTSUPP;
3838
}
3939

40-
WARN_ON(!key->len);
40+
if (!key->len)
41+
return -EINVAL;
42+
4143
key->key = kmemdup(buf, key->len, GFP_NOIO);
4244
if (!key->key) {
4345
ret = -ENOMEM;

0 commit comments

Comments
 (0)