Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1299573

Re: linux-next: manual merge of the security tree with the vfs tree

From Al Viro <viro@ZenIV.linux.org.uk>
Newsgroups linux.kernel
Subject Re: linux-next: manual merge of the security tree with the vfs tree
Date 2015-12-31 05:40 +0100
Message-ID <qLDbQ-7YS-7@gated-at.bofh.it> (permalink)
References <qLD2a-7Vz-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

linux-next: manual merge of the security tree with the vfs tree Stephen Rothwell <sfr@canb.auug.org.au> - 2015-12-31 05:30 +0100
  Re: linux-next: manual merge of the security tree with the vfs tree Al Viro <viro@ZenIV.linux.org.uk> - 2015-12-31 05:40 +0100
    Re: linux-next: manual merge of the security tree with the vfs tree Petko Manolov <petkan@mip-labs.com> - 2015-12-31 11:50 +0100
      Re: linux-next: manual merge of the security tree with the vfs tree Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-01 05:40 +0100
        Re: linux-next: manual merge of the security tree with the vfs tree Petko Manolov <petkan@mip-labs.com> - 2016-01-01 18:30 +0100
          Re: [PATCH] ima_write_policy() optimizations; kbuild test robot <lkp@intel.com> - 2016-01-01 18:50 +0100
  Re: linux-next: manual merge of the security tree with the vfs tree Mimi Zohar <zohar@linux.vnet.ibm.com> - 2016-01-04 02:40 +0100
    Re: linux-next: manual merge of the security tree with the vfs tree Stephen Rothwell <sfr@canb.auug.org.au> - 2016-01-04 03:00 +0100

csiph-web