diff options
author | Todd Kjos <tkjos@google.com> | 2021-10-12 09:56:14 -0700 |
---|---|---|
committer | Aaron Ding <aaronding@google.com> | 2021-12-10 23:43:33 +0800 |
commit | abc14a8591547702efd4a572661d9439f1a5af52 (patch) | |
tree | d738d3a5c512f9bbc76bef53c04278e58a99ba6f | |
parent | 3fead5f99bb65e8bb69fc84b7bc4d4b4b6ef4318 (diff) | |
download | common-abc14a8591547702efd4a572661d9439f1a5af52.tar.gz |
BACKPORT: binder: use cred instead of task for getsecid
Use the 'struct cred' saved at binder_open() to lookup
the security ID via security_cred_getsecid(). This
ensures that the security context that opened binder
is the one used to generate the secctx.
Cc: stable@vger.kernel.org # 5.4+
Fixes: ec74136ded79 ("binder: create node flag to request sender's security context")
Signed-off-by: Todd Kjos <tkjos@google.com>
Suggested-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Reported-by: kernel test robot <lkp@intel.com>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Bug: 200688826
(cherry picked from commit 4d5b5539742d2554591751b4248b0204d20dcc9d)
[ refactored to avoid changing KMI: struct binder_proc ]
Change-Id: Ie023be3190caf20ca3901560455e9f027c9426cd
-rw-r--r-- | drivers/android/binder.c | 2 | ||||
-rw-r--r-- | include/linux/security.h | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 39778af28b25..962f3203aa6a 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -2865,7 +2865,7 @@ static void binder_transaction(struct binder_proc *proc, size_t added_size; int max_retries = 100; - security_task_getsecid(proc->tsk, &secid); + security_cred_getsecid(binder_get_cred(proc), &secid); retry_alloc: ret = security_secid_to_secctx(secid, &secctx, &secctx_sz); if (ret == -ENOMEM && max_retries-- > 0) { diff --git a/include/linux/security.h b/include/linux/security.h index 83eb90400a75..ae42887ebb61 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -1010,6 +1010,11 @@ static inline void security_transfer_creds(struct cred *new, { } +static inline void security_cred_getsecid(const struct cred *c, u32 *secid) +{ + *secid = 0; +} + static inline int security_kernel_act_as(struct cred *cred, u32 secid) { return 0; |