Re: [PATCH v10 2/5] fs: split off setxattr_copy and do_setxattr function from setxattr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 30, 2021 at 01:15:10AM +0000, Al Viro wrote:
> On Wed, Dec 29, 2021 at 12:29:59PM -0800, Stefan Roesch wrote:
> > +	if (ctx->size) {
> > +		if (ctx->size > XATTR_SIZE_MAX)
> >  			return -E2BIG;
> > -		kvalue = kvmalloc(size, GFP_KERNEL);
> > -		if (!kvalue)
> > +
> > +		ctx->kvalue = kvmalloc(ctx->size, GFP_KERNEL);
> > +		if (!ctx->kvalue)
> >  			return -ENOMEM;
> > -		if (copy_from_user(kvalue, value, size)) {
> > -			error = -EFAULT;
> > -			goto out;
> > +
> > +		if (copy_from_user(ctx->kvalue, ctx->value, ctx->size)) {
> > +			kvfree(ctx->kvalue);
> > +			return -EFAULT;
> 
> BTW, what's wrong with using vmemdup_user() here?

Nothing? It's simply timing paired with that specific code not needing
to be touched:

- in 2005 that code was kmalloc(GFP_KERNEL) + copy_from_user()
- in 2009 it was changed to memdup_user(GFP_USER)
- in 2012 it was changed to kvmalloc(GFP_KERNEL) + copy_from_user()

In 2018 you added vmemdup_user() and noone has updated that codepath. :)



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux