The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: linux-kernel@vger.kernel.org, Daniel Palmer <daniel@0x0f.com>
Subject: Re: [PATCH] tools/nolibc: mark arg1 operand in __nolibc_syscall0() as write-only
Date: Fri, 3 Jul 2026 19:41:58 +0200	[thread overview]
Message-ID: <akf0Zk-ci0WG93Mc@1wt.eu> (raw)
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 <linux@weissschuh.net>
> ---
>  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 <w@1wt.eu>

Thanks!
Willy

  reply	other threads:[~2026-07-03 17:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03 17:30 [PATCH] tools/nolibc: mark arg1 operand in __nolibc_syscall0() as write-only Thomas Weißschuh
2026-07-03 17:41 ` Willy Tarreau [this message]
2026-07-03 17:45   ` Willy Tarreau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=akf0Zk-ci0WG93Mc@1wt.eu \
    --to=w@1wt.eu \
    --cc=daniel@0x0f.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox