From: Al Viro <viro@ZenIV.linux.org.uk>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: James Morris <jmorris@namei.org>,
linux-next@vger.kernel.org, linux-kernel@vger.kernel.org,
Petko Manolov <petkan@mip-labs.com>,
Mimi Zohar <zohar@linux.vnet.ibm.com>
Subject: Re: linux-next: manual merge of the security tree with the vfs tree
Date: Thu, 31 Dec 2015 04:30:19 +0000 [thread overview]
Message-ID: <20151231043019.GD9938@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20151231152453.08cfae79@canb.auug.org.au>
On Thu, Dec 31, 2015 at 03:24:53PM +1100, Stephen Rothwell wrote:
> Hi James,
>
> Today's linux-next merge of the security tree got a conflict in:
>
> security/integrity/ima/ima_fs.c
>
> between commit:
>
> 3bc8f29b149e ("new helper: memdup_user_nul()")
>
> from the vfs tree and commit:
>
> 38d859f991f3 ("IMA: policy can now be updated multiple times")
>
> from the security tree.
>
> I fixed it up (hopefully, see below) and can carry the fix as necessary
> (no action is required).
> + res = mutex_lock_interruptible(&ima_write_mutex);
> + if (res)
> + return res;
>
> if (datalen >= PAGE_SIZE)
> datalen = PAGE_SIZE - 1;
>
> /* No partial writes. */
> + result = -EINVAL;
> if (*ppos != 0)
> - return -EINVAL;
> + goto out;
>
> - result = -ENOMEM;
> - data = kmalloc(datalen + 1, GFP_KERNEL);
> - if (!data)
> - goto out;
> -
> - *(data + datalen) = '\0';
> -
> - result = -EFAULT;
> - if (copy_from_user(data, buf, datalen))
> + data = memdup_user_nul(buf, datalen);
> - if (IS_ERR(data))
> - return PTR_ERR(data);
> ++ if (IS_ERR(data)) {
> ++ result = PTR_ERR(data);
> + goto out;
> ++ }
Why do it in this order? With or without opencoding memdup_user_nul(),
what's the point of taking the mutex before copying the data from
userland? All it achieves is holding it longer, over the area that
needs no exclusion whatsoever.
next prev parent reply other threads:[~2015-12-31 4:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-31 4:24 linux-next: manual merge of the security tree with the vfs tree Stephen Rothwell
2015-12-31 4:30 ` Al Viro [this message]
2015-12-31 10:45 ` Petko Manolov
2016-01-01 4:34 ` Al Viro
2016-01-01 17:29 ` Petko Manolov
2016-01-01 17:41 ` [PATCH] ima_write_policy() optimizations; kbuild test robot
2016-01-04 1:37 ` linux-next: manual merge of the security tree with the vfs tree Mimi Zohar
2016-01-04 1:55 ` Stephen Rothwell
-- strict thread matches above, loose matches on Subject: below --
2019-08-12 4:44 Stephen Rothwell
2015-05-13 4:39 Stephen Rothwell
2015-05-13 4:26 Stephen Rothwell
2014-12-10 2:47 Stephen Rothwell
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=20151231043019.GD9938@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=petkan@mip-labs.com \
--cc=sfr@canb.auug.org.au \
--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;
as well as URLs for NNTP newsgroup(s).