summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--security/keys/keyctl.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index ada12c3e3ac4..1302cb398346 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -766,6 +766,11 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)
key = key_ref_to_ptr(key_ref);
+ if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) {
+ ret = -ENOKEY;
+ goto error2;
+ }
+
/* see if we can read it directly */
ret = key_permission(key_ref, KEY_NEED_READ);
if (ret == 0)