From: Geliang Tang <geliangtang@gmail.com>
To: Mimi Zohar <zohar@linux.vnet.ibm.com>,
Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
James Morris <james.l.morris@oracle.com>,
"Serge E. Hallyn" <serge@hallyn.com>
Cc: Geliang Tang <geliangtang@gmail.com>,
linux-ima-devel@lists.sourceforge.net,
linux-ima-user@lists.sourceforge.net,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] ima: use memdup_user_nul
Date: Sat, 6 May 2017 23:40:18 +0800 [thread overview]
Message-ID: <044d541d7d33c997f9661ae625d1374bc1e5dab8.1493782979.git.geliangtang@gmail.com> (raw)
In-Reply-To: <6baf3aa45d0b5e0fd016b508bac905ebf8443aac.1493779294.git.geliangtang@gmail.com>
Use memdup_user_nul() helper instead of open-coding to simplify the
code.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
security/integrity/ima/ima_fs.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
index ca303e5..ad491c5 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)
--
2.9.3
next prev parent reply other threads:[~2017-05-06 15:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-06 15:40 [PATCH] drm/i915: " Geliang Tang
2017-05-06 15:40 ` Geliang Tang [this message]
2017-05-08 15:44 ` [PATCH] ima: " Mimi Zohar
2017-05-06 15:40 ` [PATCH] platform/x86: toshiba_acpi: " Geliang Tang
2017-05-07 11:42 ` Andy Shevchenko
2017-05-06 15:40 ` [PATCH] sparc: use memdup_user_nul in sun4m LED driver Geliang Tang
2017-05-09 19:16 ` David Miller
2017-05-08 7:29 ` [Intel-gfx] [PATCH] drm/i915: use memdup_user_nul Daniel Vetter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=044d541d7d33c997f9661ae625d1374bc1e5dab8.1493782979.git.geliangtang@gmail.com \
--to=geliangtang@gmail.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=james.l.morris@oracle.com \
--cc=linux-ima-devel@lists.sourceforge.net \
--cc=linux-ima-user@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=serge@hallyn.com \
--cc=zohar@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®