Skip to content

Commit aa3a0a7

Browse files
ebiggersgregkh
authored andcommitted
FS-Cache: fix dereference of NULL user_key_payload
commit d124b2c53c7bee6569d2a2d0b18b4a1afde00134 upstream. When the file /proc/fs/fscache/objects (available with CONFIG_FSCACHE_OBJECT_LIST=y) is opened, we request a user key with description "fscache:objlist", then access its payload. However, a revoked key has a NULL payload, and we failed to check for this. request_key() *does* skip revoked keys, but there is still a window where the key can be revoked before we access its payload. Fix it by checking for a NULL payload, treating it like a key which was already revoked at the time it was requested. Fixes: 4fbf429 ("FS-Cache: Allow the current state of all objects to be dumped") Reviewed-by: James Morris <james.l.morris@oracle.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1bb1d42 commit aa3a0a7

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

fs/fscache/object-list.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,13 @@ static void fscache_objlist_config(struct fscache_objlist_data *data)
330330
rcu_read_lock();
331331

332332
confkey = user_key_payload(key);
333+
if (!confkey) {
334+
/* key was revoked */
335+
rcu_read_unlock();
336+
key_put(key);
337+
goto no_config;
338+
}
339+
333340
buf = confkey->data;
334341

335342
for (len = confkey->datalen - 1; len >= 0; len--) {

0 commit comments

Comments
 (0)