summaryrefslogtreecommitdiff
path: root/arch/x86/include/uapi/asm
diff options
context:
space:
mode:
authorNick Desaulniers <ndesaulniers@google.com>2026-08-21 15:45:42 -0700
committerBorislav Petkov (AMD) <bp@alien8.de>2026-09-28 12:11:19 -0700
commita661c34fe693c8f9ef29b45ee71cfa1fe593502b (patch)
treed0152d60222a83789187e0a450987c17c886fb9d /arch/x86/include/uapi/asm
parente3ee38c1bc0b11a8d3e63dce7050759b61864286 (diff)
downloadlinux-next-a661c34fe693c8f9ef29b45ee71cfa1fe593502b.tar.gz
linux-next-a661c34fe693c8f9ef29b45ee71cfa1fe593502b.zip
{x86,um}/uapi/ptrace: Guard register offset macros with __ASSEMBLER__ or __FRAME_OFFSETS
The register offset macros in <asm/ptrace-abi.h> are guarded by `defined(__ASSEMBLER__) || defined(__FRAME_OFFSETS)` for 64-bit, but were left unguarded for 32-bit. This causes havoc for userspace that happens to use identifiers colliding with these short macro names (e.g., EBX, ECX, EAX, DS, ES, FS, GS, CS, SS). Without this guard, userspace is forced to be super extra careful with include ordering to minimize the chance of collision. Wrap both the 32-bit and 64-bit register definitions under `#if defined(__ASSEMBLER__) || defined(__FRAME_OFFSETS)`, and ensure User-Mode Linux (UML) defines `__FRAME_OFFSETS` for 32-bit as well. Closes: https://github.com/llvm/llvm-project/issues/217413 Assisted-by: LLM Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Johannes Berg <johannes@sipsolutions.net> Tested-by: Elliott Hughes <enh@google.com> Link: https://patch.msgid.link/20260821-ptrace_uapi-v1-1-3de8638a29f2@google.com
Diffstat (limited to 'arch/x86/include/uapi/asm')
-rw-r--r--arch/x86/include/uapi/asm/ptrace-abi.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/x86/include/uapi/asm/ptrace-abi.h b/arch/x86/include/uapi/asm/ptrace-abi.h
index 5823584dea13..3656955c6faa 100644
--- a/arch/x86/include/uapi/asm/ptrace-abi.h
+++ b/arch/x86/include/uapi/asm/ptrace-abi.h
@@ -2,6 +2,7 @@
#ifndef _ASM_X86_PTRACE_ABI_H
#define _ASM_X86_PTRACE_ABI_H
+#if defined(__ASSEMBLER__) || defined(__FRAME_OFFSETS)
#ifdef __i386__
#define EBX 0
@@ -25,7 +26,6 @@
#else /* __i386__ */
-#if defined(__ASSEMBLER__) || defined(__FRAME_OFFSETS)
/*
* C ABI says these regs are callee-preserved. They aren't saved on kernel entry
* unless syscall needs a complete, fully filled "struct pt_regs".
@@ -57,12 +57,12 @@
#define EFLAGS 144
#define RSP 152
#define SS 160
-#endif /* __ASSEMBLER__ */
/* top of stack page */
#define FRAME_SIZE 168
#endif /* !__i386__ */
+#endif /* defined(__ASSEMBLER__) || defined(__FRAME_OFFSETS) */
/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
#define PTRACE_GETREGS 12