aboutsummaryrefslogtreecommitdiffstats
path: root/security/keys/keyctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/keys/keyctl.c')
-rw-r--r--security/keys/keyctl.c18
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)
751 751
752 /* the key is probably readable - now try to read it */ 752 /* the key is probably readable - now try to read it */
753can_read_key: 753can_read_key:
754 ret = key_validate(key); 754 ret = -EOPNOTSUPP;
755 if (ret == 0) { 755 if (key->type->read) {
756 ret = -EOPNOTSUPP; 756 /* Read the data with the semaphore held (since we might sleep)
757 if (key->type->read) { 757 * to protect against the key being updated or revoked.
758 /* read the data with the semaphore held (since we 758 */
759 * might sleep) */ 759 down_read(&key->sem);
760 down_read(&key->sem); 760 ret = key_validate(key);
761 if (ret == 0)
761 ret = key->type->read(key, buffer, buflen); 762 ret = key->type->read(key, buffer, buflen);
762 up_read(&key->sem); 763 up_read(&key->sem);
763 }
764 } 764 }
765 765
766error2: 766error2: