From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.formilux.org (mta1.formilux.org [51.159.59.229]) (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 63B6521FF2A for ; Fri, 3 Jul 2026 17:42:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=51.159.59.229 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783100531; cv=none; b=VO9V67VDpraZvKF//UTMes/I6tL2xW1sMpmhxB8vMCICI/5DbbEgAi2bdjAk0c/6p0bKKY7RRPdz5IpeHCw+Rsp07c9WWPzHJ03ROJZ24fZ/lhDoA2AvJnf6+4JH8vL5VHQ3ojHHa1GF6Bk4qNwvYCKB3PK6yO7ox8TPS3+Xa+Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783100531; c=relaxed/simple; bh=yNxo4mZvwXBgkBTii5oTeHl4pq0sIoVOShkfqFtsq98=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IRAafjeue6nE6Ri4dSCx03aSdfxrLmUxCI05+5IpBXhzGvy9PMFck9S6KSO9xm+tN4mNqXGKVljHQXrxbhm0oth/RhxrboX3P+O+k/R8tn16+vQQ1X13QJulSYi1SBZ9tfvmG4IsEuuFOT1zDvYG4NCDJ25tdxweqXCv4Uig8nI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=1wt.eu; spf=pass smtp.mailfrom=1wt.eu; dkim=pass (1024-bit key) header.d=1wt.eu header.i=@1wt.eu header.b=qytJmTw2; arc=none smtp.client-ip=51.159.59.229 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=1wt.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=1wt.eu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=1wt.eu header.i=@1wt.eu header.b="qytJmTw2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1wt.eu; s=mail; t=1783100519; bh=AZjdVgkO6lK5OjUf9s/Nw59e5Qa1/ipBqjFBIb8MYz0=; h=From:Message-ID:From; b=qytJmTw2Vmm9kc3b2uKfPCbPqT1iT/DXoDmVRV+uJW2eNqfI8LBGZXTcgU2svqts0 Rxd99XQtpVvHM8wS0BWVi1/JWF/15Bq+uxgjSCvv14TuVNwr0jLgVL4JPUJ+3lRAw1 M9aba7YREqOtSUlznqij/S0lpmbqlSukHb231338= Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by mta1.formilux.org (Postfix) with ESMTP id 568C7C0E12; Fri, 03 Jul 2026 19:41:59 +0200 (CEST) Date: Fri, 3 Jul 2026 19:41:58 +0200 From: Willy Tarreau To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: linux-kernel@vger.kernel.org, Daniel Palmer Subject: Re: [PATCH] tools/nolibc: mark arg1 operand in __nolibc_syscall0() as write-only Message-ID: References: <20260703-nolibc-sparc-asm-v1-1-c7fe73e2e777@weissschuh.net> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260703-nolibc-sparc-asm-v1-1-c7fe73e2e777@weissschuh.net> Hi Thomas! On Fri, Jul 03, 2026 at 07:30:16PM +0200, Thomas Weißschuh wrote: > __nolibc_syscall0() does not set the arg1 variable before passing it to > the asm block. This uninitialized variable read is undefined behavior. > Clang can miscompile this. Interesting. I don't know how we ended up like this, most likely just due to reusing the same code blocks for the different variants. I'm noting that m68k is affected as well then. I'm CCing Daniel for a double-check. > Mark the asm operand as write-only to fix this. > > Fixes: 8e1930296f92 ("tools/nolibc: Add support for SPARC") > Signed-off-by: Thomas Weißschuh > --- > tools/include/nolibc/arch-sparc.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/include/nolibc/arch-sparc.h b/tools/include/nolibc/arch-sparc.h > index ddae9bc10dfe..23fab40accfa 100644 > --- a/tools/include/nolibc/arch-sparc.h > +++ b/tools/include/nolibc/arch-sparc.h > @@ -45,7 +45,7 @@ > \ > __asm__ volatile ( \ > _NOLIBC_SYSCALL \ > - : "+r"(_arg1) \ > + : "=r"(_arg1) \ > : "r"(_num) \ > : "memory", "cc" \ > ); \ Agreed, this totally makes sense. Acked-by: Willy Tarreau Thanks! Willy