From: Mimi Zohar <zohar@linux.vnet.ibm.com>
To: Geliang Tang <geliangtang@gmail.com>,
Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
James Morris <james.l.morris@oracle.com>,
"Serge E. Hallyn" <serge@hallyn.com>
Cc: linux-ima-devel@lists.sourceforge.net,
linux-ima-user@lists.sourceforge.net,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ima: use memdup_user_nul
Date: Mon, 08 May 2017 11:44:35 -0400 [thread overview]
Message-ID: <1494258275.5871.1.camel@linux.vnet.ibm.com> (raw)
In-Reply-To: <044d541d7d33c997f9661ae625d1374bc1e5dab8.1493782979.git.geliangtang@gmail.com>
On Sat, 2017-05-06 at 23:40 +0800, Geliang Tang wrote:
> Use memdup_user_nul() helper instead of open-coding to simplify the
> code.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Thanks, this patch will be queued.
Mimi
> ---
> 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)
next prev parent reply other threads:[~2017-05-08 15:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-06 15:40 [PATCH] drm/i915: use memdup_user_nul Geliang Tang
2017-05-06 15:40 ` [PATCH] ima: " Geliang Tang
2017-05-08 15:44 ` Mimi Zohar [this message]
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=1494258275.5871.1.camel@linux.vnet.ibm.com \
--to=zohar@linux.vnet.ibm.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=geliangtang@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 \
/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