summaryrefslogtreecommitdiff
path: root/security/keys/keyctl.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2019-05-22 16:09:29 +0300
committerDavid Howells <dhowells@redhat.com>2019-05-30 00:32:05 +0300
commit7936d16df9a56c993c23385ea9c2785127f81711 (patch)
treed86542e699dc8b41a70c214369dda8f6bbdd8063 /security/keys/keyctl.c
parent2e21865faf4fd7ca99eb2ace072c6d618059e342 (diff)
downloadlinux-7936d16df9a56c993c23385ea9c2785127f81711.tar.xz
keys: sparse: Fix incorrect RCU accesses
Fix a pair of accesses that should be using RCU protection. rcu_dereference_protected() is needed to access task_struct::real_parent. current_cred() should be used to access current->cred. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: James Morris <jamorris@linux.microsoft.com>
Diffstat (limited to 'security/keys/keyctl.c')
-rw-r--r--security/keys/keyctl.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 3e4053a217c3..0f947bcbad46 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -1524,7 +1524,8 @@ long keyctl_session_to_parent(void)
ret = -EPERM;
oldwork = NULL;
- parent = me->real_parent;
+ parent = rcu_dereference_protected(me->real_parent,
+ lockdep_is_held(&tasklist_lock));
/* the parent mustn't be init and mustn't be a kernel thread */
if (parent->pid <= 1 || !parent->mm)