* [PATCH] x86: uapi: ptrace: guard register offset macros with __ASSEMBLER__ or __FRAME_OFFSETS
@ 2026-08-21 22:45 Nick Desaulniers
2026-09-01 21:45 ` Nick Desaulniers
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Nick Desaulniers @ 2026-08-21 22:45 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Richard Weinberger, Anton Ivanov, Johannes Berg,
Oleg Nesterov, Nathan Chancellor, Bill Wendling, Justin Stitt
Cc: linux-kernel, linux-um, llvm, Nick Desaulniers
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.
Assisted-by: Gemini
Link: https://github.com/llvm/llvm-project/issues/217413
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
arch/x86/include/uapi/asm/ptrace-abi.h | 4 ++--
arch/x86/um/asm/ptrace.h | 4 +---
arch/x86/um/ptrace_32.c | 1 +
3 files changed, 4 insertions(+), 5 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
diff --git a/arch/x86/um/asm/ptrace.h b/arch/x86/um/asm/ptrace.h
index 2641d28d115c..439c4151f6b7 100644
--- a/arch/x86/um/asm/ptrace.h
+++ b/arch/x86/um/asm/ptrace.h
@@ -13,9 +13,7 @@ enum {
};
#include <linux/compiler.h>
-#ifndef CONFIG_X86_32
-#define __FRAME_OFFSETS /* Needed to get the R* macros */
-#endif
+#define __FRAME_OFFSETS /* Needed to get the register macros */
#include <asm/ptrace-generic.h>
#define user_mode(r) UPT_IS_USER(&(r)->regs)
diff --git a/arch/x86/um/ptrace_32.c b/arch/x86/um/ptrace_32.c
index 3af3cb821524..9e9155b0e918 100644
--- a/arch/x86/um/ptrace_32.c
+++ b/arch/x86/um/ptrace_32.c
@@ -7,6 +7,7 @@
#include <linux/sched.h>
#include <linux/uaccess.h>
#include <linux/regset.h>
+#define __FRAME_OFFSETS
#include <asm/ptrace-abi.h>
#include <registers.h>
#include <skas.h>
---
base-commit: 26260251022fbc2f248a3d747a9b2b961b18d2d8
change-id: 20260821-ptrace_uapi-462350036cbd
Best regards,
--
Nick Desaulniers <ndesaulniers@google.com>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] x86: uapi: ptrace: guard register offset macros with __ASSEMBLER__ or __FRAME_OFFSETS 2026-08-21 22:45 [PATCH] x86: uapi: ptrace: guard register offset macros with __ASSEMBLER__ or __FRAME_OFFSETS Nick Desaulniers @ 2026-09-01 21:45 ` Nick Desaulniers 2026-09-02 13:43 ` enh 2026-09-02 17:29 ` Oleg Nesterov 2026-09-24 14:54 ` Johannes Berg 2026-09-26 12:19 ` Oleg Nesterov 2 siblings, 2 replies; 8+ messages in thread From: Nick Desaulniers @ 2026-09-01 21:45 UTC (permalink / raw) To: Oleg Nesterov, Elliott Hughes Cc: linux-kernel, linux-um, llvm, Bill Wendling, Nathan Chancellor, Justin Stitt, Johannes Berg, Anton Ivanov, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, Richard Weinberger On Fri, Aug 21, 2026 at 3:46 PM Nick Desaulniers <ndesaulniers@google.com> wrote: > > 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. > > Assisted-by: Gemini > Link: https://github.com/llvm/llvm-project/issues/217413 > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> + enh (who pulled this into android for testing) Oleg, can I get an ack/nack here? Or someone who knows better the history of UAPI headers? (I think the Assisted-by tags need `LLM` now IIUC? Assisted-by: LLM Gemini) We've worked around this now in lldb-server, but figured it might be nice to clean this up for the rest of userspace, too. > --- > arch/x86/include/uapi/asm/ptrace-abi.h | 4 ++-- > arch/x86/um/asm/ptrace.h | 4 +--- > arch/x86/um/ptrace_32.c | 1 + > 3 files changed, 4 insertions(+), 5 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 > diff --git a/arch/x86/um/asm/ptrace.h b/arch/x86/um/asm/ptrace.h > index 2641d28d115c..439c4151f6b7 100644 > --- a/arch/x86/um/asm/ptrace.h > +++ b/arch/x86/um/asm/ptrace.h > @@ -13,9 +13,7 @@ enum { > }; > > #include <linux/compiler.h> > -#ifndef CONFIG_X86_32 > -#define __FRAME_OFFSETS /* Needed to get the R* macros */ > -#endif > +#define __FRAME_OFFSETS /* Needed to get the register macros */ > #include <asm/ptrace-generic.h> > > #define user_mode(r) UPT_IS_USER(&(r)->regs) > diff --git a/arch/x86/um/ptrace_32.c b/arch/x86/um/ptrace_32.c > index 3af3cb821524..9e9155b0e918 100644 > --- a/arch/x86/um/ptrace_32.c > +++ b/arch/x86/um/ptrace_32.c > @@ -7,6 +7,7 @@ > #include <linux/sched.h> > #include <linux/uaccess.h> > #include <linux/regset.h> > +#define __FRAME_OFFSETS > #include <asm/ptrace-abi.h> > #include <registers.h> > #include <skas.h> > > --- > base-commit: 26260251022fbc2f248a3d747a9b2b961b18d2d8 > change-id: 20260821-ptrace_uapi-462350036cbd > > Best regards, > -- > Nick Desaulniers <ndesaulniers@google.com> > -- Thanks, ~Nick Desaulniers ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] x86: uapi: ptrace: guard register offset macros with __ASSEMBLER__ or __FRAME_OFFSETS 2026-09-01 21:45 ` Nick Desaulniers @ 2026-09-02 13:43 ` enh 2026-09-02 17:29 ` Oleg Nesterov 1 sibling, 0 replies; 8+ messages in thread From: enh @ 2026-09-02 13:43 UTC (permalink / raw) To: Nick Desaulniers Cc: Oleg Nesterov, linux-kernel, linux-um, llvm, Bill Wendling, Nathan Chancellor, Justin Stitt, Johannes Berg, Anton Ivanov, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, Richard Weinberger On Tue, Sep 1, 2026 at 5:45 PM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Fri, Aug 21, 2026 at 3:46 PM Nick Desaulniers > <ndesaulniers@google.com> wrote: > > > > 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. > > > > Assisted-by: Gemini > > Link: https://github.com/llvm/llvm-project/issues/217413 > > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> > > + enh (who pulled this into android for testing) for those who don't know me, i've been Android's libc maintainer for a while now [was https://blog.linuxplumbersconf.org/2014/ocw/proposals/2337 really that long ago?!]... i applied this patch to Android's libc's copy of the uapi headers (because Android uses the uapi headers directly, unlike glibc, and exposes this header transitively from <sys/ptrace.h>, also unlike glibc), and everything still built without problems. this does solve a real problem for us: llvm's coding style means they have a lot of "FS" and "SS" identifiers that conflict with these macros, and we see a conflict every few years. Tested-by: Elliott Hughes <enh@google.com> > Oleg, can I get an ack/nack here? Or someone who knows better the > history of UAPI headers? > > (I think the Assisted-by tags need `LLM` now IIUC? Assisted-by: LLM Gemini) > > We've worked around this now in lldb-server, but figured it might be > nice to clean this up for the rest of userspace, too. > > > --- > > arch/x86/include/uapi/asm/ptrace-abi.h | 4 ++-- > > arch/x86/um/asm/ptrace.h | 4 +--- > > arch/x86/um/ptrace_32.c | 1 + > > 3 files changed, 4 insertions(+), 5 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 > > diff --git a/arch/x86/um/asm/ptrace.h b/arch/x86/um/asm/ptrace.h > > index 2641d28d115c..439c4151f6b7 100644 > > --- a/arch/x86/um/asm/ptrace.h > > +++ b/arch/x86/um/asm/ptrace.h > > @@ -13,9 +13,7 @@ enum { > > }; > > > > #include <linux/compiler.h> > > -#ifndef CONFIG_X86_32 > > -#define __FRAME_OFFSETS /* Needed to get the R* macros */ > > -#endif > > +#define __FRAME_OFFSETS /* Needed to get the register macros */ > > #include <asm/ptrace-generic.h> > > > > #define user_mode(r) UPT_IS_USER(&(r)->regs) > > diff --git a/arch/x86/um/ptrace_32.c b/arch/x86/um/ptrace_32.c > > index 3af3cb821524..9e9155b0e918 100644 > > --- a/arch/x86/um/ptrace_32.c > > +++ b/arch/x86/um/ptrace_32.c > > @@ -7,6 +7,7 @@ > > #include <linux/sched.h> > > #include <linux/uaccess.h> > > #include <linux/regset.h> > > +#define __FRAME_OFFSETS > > #include <asm/ptrace-abi.h> > > #include <registers.h> > > #include <skas.h> > > > > --- > > base-commit: 26260251022fbc2f248a3d747a9b2b961b18d2d8 > > change-id: 20260821-ptrace_uapi-462350036cbd > > > > Best regards, > > -- > > Nick Desaulniers <ndesaulniers@google.com> > > > > > -- > Thanks, > ~Nick Desaulniers ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] x86: uapi: ptrace: guard register offset macros with __ASSEMBLER__ or __FRAME_OFFSETS 2026-09-01 21:45 ` Nick Desaulniers 2026-09-02 13:43 ` enh @ 2026-09-02 17:29 ` Oleg Nesterov 2026-09-17 18:20 ` Nick Desaulniers 1 sibling, 1 reply; 8+ messages in thread From: Oleg Nesterov @ 2026-09-02 17:29 UTC (permalink / raw) To: Nick Desaulniers Cc: Elliott Hughes, linux-kernel, linux-um, llvm, Bill Wendling, Nathan Chancellor, Justin Stitt, Johannes Berg, Anton Ivanov, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, Richard Weinberger On 09/01, Nick Desaulniers wrote: > > On Fri, Aug 21, 2026 at 3:46 PM Nick Desaulniers > <ndesaulniers@google.com> wrote: > > > > 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. > > > > Assisted-by: Gemini > > Link: https://github.com/llvm/llvm-project/issues/217413 > > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> > > + enh (who pulled this into android for testing) > > Oleg, can I get an ack/nack here? Oh... there is a little problem, I don't understand the usage of (magic to me) __FRAME_OFFSETS ;) > Or someone who knows better the > history of UAPI headers? Certainly not me.... OK. I'll try to read this patch tomorrow with the clear head after sleep. Oleg. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] x86: uapi: ptrace: guard register offset macros with __ASSEMBLER__ or __FRAME_OFFSETS 2026-09-02 17:29 ` Oleg Nesterov @ 2026-09-17 18:20 ` Nick Desaulniers 0 siblings, 0 replies; 8+ messages in thread From: Nick Desaulniers @ 2026-09-17 18:20 UTC (permalink / raw) To: Oleg Nesterov Cc: Elliott Hughes, linux-kernel, linux-um, llvm, Bill Wendling, Nathan Chancellor, Justin Stitt, Johannes Berg, Anton Ivanov, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, Richard Weinberger On Wed, Sep 2, 2026 at 10:29 AM Oleg Nesterov <oleg@redhat.com> wrote: > > On 09/01, Nick Desaulniers wrote: > > > > On Fri, Aug 21, 2026 at 3:46 PM Nick Desaulniers > > <ndesaulniers@google.com> wrote: > > > > > > 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. > > > > > > Assisted-by: Gemini > > > Link: https://github.com/llvm/llvm-project/issues/217413 > > > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> > > > > + enh (who pulled this into android for testing) > > > > Oleg, can I get an ack/nack here? > > Oh... there is a little problem, I don't understand the usage of > (magic to me) __FRAME_OFFSETS ;) Yeah, my Assisted by tag is from asking Gemini to triple check my patch before posting, and it pointing out to me from a local review: "did you intend to break the arch/x86/um/ C uses of these macro defines?" So I'm just matching an existing pattern in arch/x86/um/ for 64b with the __FRAME_OFFSETS parts of this patch. The patch started off as "why are the 64b macros behind the __ASSEMBLER__ preprocessor guards, but not the 32b ones?" I went back through the pre-git history tree, and FWICT, those macros have always been guarded for 64b, since the introduction of x86_64 support itself. Dunno if anyone remembers anymore _why_ the 32b macro defines don't have that guard (chesterton's fence?), but to me, IMO, it looks like a mistake. Hence this patch. PTAL > > > Or someone who knows better the > > history of UAPI headers? > > Certainly not me.... > > OK. I'll try to read this patch tomorrow with the clear head after sleep. Thanks for taking a look. -- Thanks, ~Nick Desaulniers ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] x86: uapi: ptrace: guard register offset macros with __ASSEMBLER__ or __FRAME_OFFSETS 2026-08-21 22:45 [PATCH] x86: uapi: ptrace: guard register offset macros with __ASSEMBLER__ or __FRAME_OFFSETS Nick Desaulniers 2026-09-01 21:45 ` Nick Desaulniers @ 2026-09-24 14:54 ` Johannes Berg 2026-09-25 21:25 ` Nick Desaulniers 2026-09-26 12:19 ` Oleg Nesterov 2 siblings, 1 reply; 8+ messages in thread From: Johannes Berg @ 2026-09-24 14:54 UTC (permalink / raw) To: Nick Desaulniers, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, Richard Weinberger, Anton Ivanov, Oleg Nesterov, Nathan Chancellor, Bill Wendling, Justin Stitt Cc: linux-kernel, linux-um, llvm On Fri, 2026-08-21 at 15:45 -0700, Nick Desaulniers wrote: > > arch/x86/um/asm/ptrace.h | 4 +--- > arch/x86/um/ptrace_32.c | 1 + This seems like a simple adjustment for what you need to do in x86, so that's OK, but I don't think we'll take this through the UML tree. But for UML you can have my Acked-by: Johannes Berg <johannes@sipsolutions.net> johannes ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] x86: uapi: ptrace: guard register offset macros with __ASSEMBLER__ or __FRAME_OFFSETS 2026-09-24 14:54 ` Johannes Berg @ 2026-09-25 21:25 ` Nick Desaulniers 0 siblings, 0 replies; 8+ messages in thread From: Nick Desaulniers @ 2026-09-25 21:25 UTC (permalink / raw) To: Johannes Berg, Oleg Nesterov Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, Richard Weinberger, Anton Ivanov, Nathan Chancellor, Bill Wendling, Justin Stitt, linux-kernel, linux-um, llvm On Thu, Sep 24, 2026 at 7:54 AM Johannes Berg <johannes@sipsolutions.net> wrote: > > On Fri, 2026-08-21 at 15:45 -0700, Nick Desaulniers wrote: > > > > arch/x86/um/asm/ptrace.h | 4 +--- > > arch/x86/um/ptrace_32.c | 1 + > > This seems like a simple adjustment for what you need to do in x86, so > that's OK, but I don't think we'll take this through the UML tree. Appreciated! I agree, maybe with Oleg's review this can go via the x86 tree? > > But for UML you can have my > > Acked-by: Johannes Berg <johannes@sipsolutions.net> > > johannes -- Thanks, ~Nick Desaulniers ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] x86: uapi: ptrace: guard register offset macros with __ASSEMBLER__ or __FRAME_OFFSETS 2026-08-21 22:45 [PATCH] x86: uapi: ptrace: guard register offset macros with __ASSEMBLER__ or __FRAME_OFFSETS Nick Desaulniers 2026-09-01 21:45 ` Nick Desaulniers 2026-09-24 14:54 ` Johannes Berg @ 2026-09-26 12:19 ` Oleg Nesterov 2 siblings, 0 replies; 8+ messages in thread From: Oleg Nesterov @ 2026-09-26 12:19 UTC (permalink / raw) To: Nick Desaulniers Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, Richard Weinberger, Anton Ivanov, Johannes Berg, Nathan Chancellor, Bill Wendling, Justin Stitt, linux-kernel, linux-um, llvm On 08/21, Nick Desaulniers wrote: > > 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. > > Assisted-by: Gemini > Link: https://github.com/llvm/llvm-project/issues/217413 > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> > --- > arch/x86/include/uapi/asm/ptrace-abi.h | 4 ++-- > arch/x86/um/asm/ptrace.h | 4 +--- > arch/x86/um/ptrace_32.c | 1 + > 3 files changed, 4 insertions(+), 5 deletions(-) Acked-by: Oleg Nesterov <oleg@redhat.com> ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-09-26 12:20 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-08-21 22:45 [PATCH] x86: uapi: ptrace: guard register offset macros with __ASSEMBLER__ or __FRAME_OFFSETS Nick Desaulniers 2026-09-01 21:45 ` Nick Desaulniers 2026-09-02 13:43 ` enh 2026-09-02 17:29 ` Oleg Nesterov 2026-09-17 18:20 ` Nick Desaulniers 2026-09-24 14:54 ` Johannes Berg 2026-09-25 21:25 ` Nick Desaulniers 2026-09-26 12:19 ` Oleg Nesterov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®