diff options
author | David Howells <dhowells@redhat.com> | 2019-05-22 09:09:29 -0400 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2019-05-29 17:32:05 -0400 |
commit | 7936d16df9a56c993c23385ea9c2785127f81711 (patch) | |
tree | d86542e699dc8b41a70c214369dda8f6bbdd8063 /security | |
parent | 2e21865faf4fd7ca99eb2ace072c6d618059e342 (diff) |
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')
-rw-r--r-- | security/keys/keyctl.c | 3 | ||||
-rw-r--r-- | security/keys/request_key_auth.c | 2 |
2 files changed, 3 insertions, 2 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) | |||
1524 | 1524 | ||
1525 | ret = -EPERM; | 1525 | ret = -EPERM; |
1526 | oldwork = NULL; | 1526 | oldwork = NULL; |
1527 | parent = me->real_parent; | 1527 | parent = rcu_dereference_protected(me->real_parent, |
1528 | lockdep_is_held(&tasklist_lock)); | ||
1528 | 1529 | ||
1529 | /* the parent mustn't be init and mustn't be a kernel thread */ | 1530 | /* the parent mustn't be init and mustn't be a kernel thread */ |
1530 | if (parent->pid <= 1 || !parent->mm) | 1531 | if (parent->pid <= 1 || !parent->mm) |
diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c index bda6201c6c45..572c7a60473a 100644 --- a/security/keys/request_key_auth.c +++ b/security/keys/request_key_auth.c | |||
@@ -152,7 +152,7 @@ struct key *request_key_auth_new(struct key *target, const char *op, | |||
152 | struct key *dest_keyring) | 152 | struct key *dest_keyring) |
153 | { | 153 | { |
154 | struct request_key_auth *rka, *irka; | 154 | struct request_key_auth *rka, *irka; |
155 | const struct cred *cred = current->cred; | 155 | const struct cred *cred = current_cred(); |
156 | struct key *authkey = NULL; | 156 | struct key *authkey = NULL; |
157 | char desc[20]; | 157 | char desc[20]; |
158 | int ret = -ENOMEM; | 158 | int ret = -ENOMEM; |