lsm: convert security_setselfattr() to use memdup_user()
As suggested by the kernel test robot, memdup_user() is a better option than the combo of kmalloc()/copy_from_user(). Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202310270805.2ArE52i5-lkp@intel.com/ Acked-by: Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
parent
4179320229
commit
9ba8802c8b
@ -4011,14 +4011,9 @@ int security_setselfattr(unsigned int attr, struct lsm_ctx __user *uctx,
|
|||||||
if (size > PAGE_SIZE)
|
if (size > PAGE_SIZE)
|
||||||
return -E2BIG;
|
return -E2BIG;
|
||||||
|
|
||||||
lctx = kmalloc(size, GFP_KERNEL);
|
lctx = memdup_user(uctx, size);
|
||||||
if (lctx == NULL)
|
if (IS_ERR(lctx))
|
||||||
return -ENOMEM;
|
return PTR_ERR(lctx);
|
||||||
|
|
||||||
if (copy_from_user(lctx, uctx, size)) {
|
|
||||||
rc = -EFAULT;
|
|
||||||
goto free_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size < lctx->len || size < lctx->ctx_len + sizeof(*lctx) ||
|
if (size < lctx->len || size < lctx->ctx_len + sizeof(*lctx) ||
|
||||||
lctx->len < lctx->ctx_len + sizeof(*lctx)) {
|
lctx->len < lctx->ctx_len + sizeof(*lctx)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user