diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2017-05-14 00:15:25 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-06-30 08:04:07 +0200 |
commit | 02412e9b4e54e124fe0890b30b891d3e6f3adf38 (patch) | |
tree | 2adb7eb71d4702ca6169d4e0e668fd83a554ed5e /security | |
parent | sel_write_validatetrans(): don't open-code memdup_user_nul() (diff) | |
download | linux-02412e9b4e54e124fe0890b30b891d3e6f3adf38.tar.xz linux-02412e9b4e54e124fe0890b30b891d3e6f3adf38.zip |
ima_write_policy(): don't open-code memdup_user_nul()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'security')
-rw-r--r-- | security/integrity/ima/ima_fs.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c index ca303e5d2b94..ad491c51e833 100644 --- a/security/integrity/ima/ima_fs.c +++ b/security/integrity/ima/ima_fs.c @@ -323,16 +323,11 @@ static ssize_t ima_write_policy(struct file *file, const char __user *buf, if (*ppos != 0) goto out; - result = -ENOMEM; - data = kmalloc(datalen + 1, GFP_KERNEL); - if (!data) + data = memdup_user_nul(buf, datalen); + if (IS_ERR(data)) { + result = PTR_ERR(data); goto out; - - *(data + datalen) = '\0'; - - result = -EFAULT; - if (copy_from_user(data, buf, datalen)) - goto out_free; + } result = mutex_lock_interruptible(&ima_write_mutex); if (result < 0) |