diff options
author | Paul Moore <paul@paul-moore.com> | 2023-10-24 19:42:38 +0300 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2023-11-13 06:54:42 +0300 |
commit | fdcf699b60712ecd6e41d9fc09137279257a4bf8 (patch) | |
tree | 2b9076ef67f4fd3542e16f6fa701c47453644bea /security/security.c | |
parent | dc46db78b9747f8114030982ee5c2faf2faaeddd (diff) | |
download | linux-fdcf699b60712ecd6e41d9fc09137279257a4bf8.tar.xz |
lsm: correct error codes in security_getselfattr()
We should return -EINVAL if the user specifies LSM_FLAG_SINGLE without
supplying a valid lsm_ctx struct buffer.
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Reviewed-by: Mickaël Salaün <mic@digikod.net>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/security.c')
-rw-r--r-- | security/security.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/security/security.c b/security/security.c index 74ff9a48bd66..78e7ffcc9f6c 100644 --- a/security/security.c +++ b/security/security.c @@ -3922,9 +3922,9 @@ int security_getselfattr(unsigned int attr, struct lsm_ctx __user *uctx, /* * Only flag supported is LSM_FLAG_SINGLE */ - if (flags != LSM_FLAG_SINGLE) + if (flags != LSM_FLAG_SINGLE || !uctx) return -EINVAL; - if (uctx && copy_from_user(&lctx, uctx, sizeof(lctx))) + if (copy_from_user(&lctx, uctx, sizeof(lctx))) return -EFAULT; /* * If the LSM ID isn't specified it is an error. |