On 12/29/21 5:15 PM, 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? I was simply following the existing code. The next version will use the vmemdup_user function.