diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-01-09 05:20:11 +0300 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-01-09 05:20:11 +0300 |
commit | 6108209c4ae964836f6bac5210f1c64153800b62 (patch) | |
tree | 83651902b46af6bbf8d2ea4841b397bac306095b /security | |
parent | a1c6f05733c27ba7067c06c095f49e8732a5ae17 (diff) | |
parent | a7f61e89af73e9bf760826b20dba4e637221fcb9 (diff) | |
download | linux-6108209c4ae964836f6bac5210f1c64153800b62.tar.xz |
Merge branch 'for-linus' into work.misc
Diffstat (limited to 'security')
-rw-r--r-- | security/keys/keyctl.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c index fb111eafcb89..1c3872aeed14 100644 --- a/security/keys/keyctl.c +++ b/security/keys/keyctl.c @@ -751,16 +751,16 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen) /* the key is probably readable - now try to read it */ can_read_key: - ret = key_validate(key); - if (ret == 0) { - ret = -EOPNOTSUPP; - if (key->type->read) { - /* read the data with the semaphore held (since we - * might sleep) */ - down_read(&key->sem); + ret = -EOPNOTSUPP; + if (key->type->read) { + /* Read the data with the semaphore held (since we might sleep) + * to protect against the key being updated or revoked. + */ + down_read(&key->sem); + ret = key_validate(key); + if (ret == 0) ret = key->type->read(key, buffer, buflen); - up_read(&key->sem); - } + up_read(&key->sem); } error2: |