[Devel] [PATCH RHEL7 COMMIT] ms/KEYS: fix key refcount leak in keyctl_read_key()
Konstantin Khorenko
khorenko at virtuozzo.com
Mon Oct 30 11:50:48 MSK 2017
The commit is pushed to "branch-rh7-3.10.0-693.1.1.vz7.37.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.1.1.vz7.37.19
------>
commit 5950e057c5666628aa8d2e672e5104bc2d521823
Author: Eric Biggers <ebiggers at google.com>
Date: Mon Sep 18 11:36:31 2017 -0700
ms/KEYS: fix key refcount leak in keyctl_read_key()
In keyctl_read_key(), if key_permission() were to return an error code
other than EACCES, we would leak a the reference to the key. This can't
actually happen currently because key_permission() can only return an
error code other than EACCES if security_key_permission() does, only
SELinux and Smack implement that hook, and neither can return an error
code other than EACCES. But it should still be fixed, as it is a bug
waiting to happen.
Fixes: 29db91906340 ("[PATCH] Keys: Add LSM hooks for key management [try #3]")
Signed-off-by: Eric Biggers <ebiggers at google.com>
Signed-off-by: David Howells <dhowells at redhat.com>
https://jira.sw.ru/browse/PSBM-72405
(cherry picked from commit 7fc0786d956d9e59b68d282be9b156179846ea3d)
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
security/keys/keyctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 1f02193..fec97ae 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -758,7 +758,7 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)
if (ret == 0)
goto can_read_key;
if (ret != -EACCES)
- goto error;
+ goto error2;
/* we can't; see if it's searchable from this process's keyrings
* - we automatically take account of the fact that it may be
More information about the Devel
mailing list