From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 966FC1FBEA8 for ; Sun, 2 Aug 2026 12:47:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785674833; cv=none; b=UjIT3qkmw08ZYR5YoeMhhGEZeINtVyiv81OZXkkQQBG2GLRgt2IonejL4dH8+gHCO39kpHmwfW1mkX4WeRv+Vd8Wl42/aWN4ngWngniMoE/L8twWMuHj43iHXrdPdv5LK6qiUB8+hI9QdUVNeH4rNvh3iGrlZfWxnM1sPppUkzc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785674833; c=relaxed/simple; bh=OpgRIBbOI1zRNmbSwCveEquYUVTMMkXW8xXwGEFbkjk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=N4GuVmJwMUlCDKP8TlCeAjfQI/btIL6+Ymp3jOdBaMabmOHg034CYyfnQpBMx0PB/3d8GuZvBY7pmfWJ/wX6lQILCJCDefxMcV+w0040LkpowrFQxgeZhAajrLJVtfvE3pGulRfOFCB6U7aMmIKRtk6h/BxFN6o0Jj3+WW5by74= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=nWtZiuD4; arc=none smtp.client-ip=91.218.175.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="nWtZiuD4" Date: Sun, 2 Aug 2026 14:47:00 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785674827; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=674mEUCKLsOl+WAwZEbvUl5py6fzkcWEqlbd/JHpKCE=; b=nWtZiuD4NgBzt/O0Q1oGjaW5WSDXH+w+Pf80t3RToeQPUPRrF6dN3nscUuxLTs3HTIrkJQ HobHkTbb/eAshMmy6ZcUk858SaAtB761Ki5FqQudfsk4GWyFcuaQ1DuJmtivRIpGuanZV0 avjvQqm/kNpRIp+w4N82oTnby5hKjCI= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Thorsten Blum To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND] x86/fpu: Use vmemdup_user() in xstateregs_set() Message-ID: References: <20260720195534.70111-3-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260720195534.70111-3-thorsten.blum@linux.dev> X-Migadu-Flow: FLOW_OUT On Mon, Jul 20, 2026 at 09:55:35PM +0200, Thorsten Blum wrote: > Replace the open-coded vmalloc() and copy_from_user() with > vmemdup_user() to simplify xstateregs_set(). > > vmemdup_user() returns an ERR_PTR() on failure, preserving the existing > -ENOMEM and -EFAULT error codes. Since vmemdup_user() is backed by > kvmalloc(), use kvfree() to free the buffer instead. > > Return early on error and drop the obsolete out label. > > Signed-off-by: Thorsten Blum > --- > arch/x86/kernel/fpu/regset.c | 17 ++++++----------- > 1 file changed, 6 insertions(+), 11 deletions(-) > > diff --git a/arch/x86/kernel/fpu/regset.c b/arch/x86/kernel/fpu/regset.c > index 0986c2200adc..8dc9de732c78 100644 > --- a/arch/x86/kernel/fpu/regset.c > +++ b/arch/x86/kernel/fpu/regset.c > @@ -3,7 +3,8 @@ > * FPU register's regset abstraction, for ptrace, core dumps, etc. > */ > #include > -#include > +#include > +#include > > #include > #include > @@ -157,21 +158,15 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset, > return -EFAULT; > > if (!kbuf) { > - tmpbuf = vmalloc(count); > - if (!tmpbuf) > - return -ENOMEM; > - > - if (copy_from_user(tmpbuf, ubuf, count)) { > - ret = -EFAULT; > - goto out; > - } > + tmpbuf = vmemdup_user(ubuf, count); > + if (IS_ERR(tmpbuf)) > + return PTR_ERR(tmpbuf); > } > > fpu_force_restore(fpu); > ret = copy_uabi_from_kernel_to_xstate(fpu->fpstate, kbuf ?: tmpbuf, &target->thread.pkru); > > -out: > - vfree(tmpbuf); > + kvfree(tmpbuf); > return ret; > } > I've resent this cleanup a few times and haven't received feedback. Is this still something you would consider, or would you prefer that I drop it? It's intended to be a mechanical cleanup with no functional changes. Happy to rerun the relevant x86 XSAVE selftests if it helps. Thanks, Thorsten