[PATCH] tools/nolibc: mark arg1 operand in __nolibc_syscall0() as write-only
From: Thomas Weißschuh
Date: Fri Jul 03 2026 - 13:30:36 EST
__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.
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@xxxxxxxxxxxxxx>
---
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" \
); \
---
base-commit: d92642aeb2b9b0c670194d5768c3a6b227002d0d
change-id: 20260703-nolibc-sparc-asm-3544ec0f1edc
Best regards,
--
Thomas Weißschuh <linux@xxxxxxxxxxxxxx>