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. :)