aboutsummaryrefslogtreecommitdiffstats
path: root/security/keys/keyring.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2020-04-04 12:24:47 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2020-04-04 12:24:47 -0700
commit4c205c84e249e0a91dcfabe461d77667ec9b2d05 (patch)
tree211606956d526d055ccce3f7f5cdc514d3be05fb /security/keys/keyring.c
parentMerge tag 'drm-next-2020-04-03-1' of git://anongit.freedesktop.org/drm/drm (diff)
parentKEYS: Avoid false positive ENOMEM error on key read (diff)
downloadlinux-dev-4c205c84e249e0a91dcfabe461d77667ec9b2d05.tar.xz
linux-dev-4c205c84e249e0a91dcfabe461d77667ec9b2d05.zip
Merge tag 'keys-fixes-20200329' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
Pull keyrings fixes from David Howells: "Here's a couple of patches that fix a circular dependency between holding key->sem and mm->mmap_sem when reading data from a key. One potential issue is that a filesystem looking to use a key inside, say, ->readpages() could deadlock if the key being read is the key that's required and the buffer the key is being read into is on a page that needs to be fetched. The case actually detected is a bit more involved - with a filesystem calling request_key() and locking the target keyring for write - which could be being read" * tag 'keys-fixes-20200329' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs: KEYS: Avoid false positive ENOMEM error on key read KEYS: Don't write out to userspace while holding key semaphore
Diffstat (limited to 'security/keys/keyring.c')
-rw-r--r--security/keys/keyring.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index febf36c6ddc5..5ca620d31cd3 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -459,7 +459,6 @@ static int keyring_read_iterator(const void *object, void *data)
{
struct keyring_read_iterator_context *ctx = data;
const struct key *key = keyring_ptr_to_key(object);
- int ret;
kenter("{%s,%d},,{%zu/%zu}",
key->type->name, key->serial, ctx->count, ctx->buflen);
@@ -467,10 +466,7 @@ static int keyring_read_iterator(const void *object, void *data)
if (ctx->count >= ctx->buflen)
return 1;
- ret = put_user(key->serial, ctx->buffer);
- if (ret < 0)
- return ret;
- ctx->buffer++;
+ *ctx->buffer++ = key->serial;
ctx->count += sizeof(key->serial);
return 0;
}