]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names
authorDave Martin <Dave.Martin@arm.com>
Tue, 1 Jul 2025 13:56:13 +0000 (14:56 +0100)
committerKees Cook <kees@kernel.org>
Tue, 15 Jul 2025 05:27:48 +0000 (22:27 -0700)
Instead of having the core code guess the note name for each regset,
use USER_REGSET_NOTE_TYPE() to pick the correct name from elf.h.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: x86@kernel.org
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Link: https://lore.kernel.org/r/20250701135616.29630-21-Dave.Martin@arm.com
Signed-off-by: Kees Cook <kees@kernel.org>
arch/x86/kernel/ptrace.c

index 095f04bdabdc123391f4cbe6b4812d12379281ee..3dcadc13f09ad33e82750c6b658f1f5cbe4d8b8f 100644 (file)
@@ -1236,7 +1236,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 
 static struct user_regset x86_64_regsets[] __ro_after_init = {
        [REGSET64_GENERAL] = {
-               .core_note_type = NT_PRSTATUS,
+               USER_REGSET_NOTE_TYPE(PRSTATUS),
                .n              = sizeof(struct user_regs_struct) / sizeof(long),
                .size           = sizeof(long),
                .align          = sizeof(long),
@@ -1244,7 +1244,7 @@ static struct user_regset x86_64_regsets[] __ro_after_init = {
                .set            = genregs_set
        },
        [REGSET64_FP] = {
-               .core_note_type = NT_PRFPREG,
+               USER_REGSET_NOTE_TYPE(PRFPREG),
                .n              = sizeof(struct fxregs_state) / sizeof(long),
                .size           = sizeof(long),
                .align          = sizeof(long),
@@ -1253,7 +1253,7 @@ static struct user_regset x86_64_regsets[] __ro_after_init = {
                .set            = xfpregs_set
        },
        [REGSET64_XSTATE] = {
-               .core_note_type = NT_X86_XSTATE,
+               USER_REGSET_NOTE_TYPE(X86_XSTATE),
                .size           = sizeof(u64),
                .align          = sizeof(u64),
                .active         = xstateregs_active,
@@ -1261,7 +1261,7 @@ static struct user_regset x86_64_regsets[] __ro_after_init = {
                .set            = xstateregs_set
        },
        [REGSET64_IOPERM] = {
-               .core_note_type = NT_386_IOPERM,
+               USER_REGSET_NOTE_TYPE(386_IOPERM),
                .n              = IO_BITMAP_LONGS,
                .size           = sizeof(long),
                .align          = sizeof(long),
@@ -1270,7 +1270,7 @@ static struct user_regset x86_64_regsets[] __ro_after_init = {
        },
 #ifdef CONFIG_X86_USER_SHADOW_STACK
        [REGSET64_SSP] = {
-               .core_note_type = NT_X86_SHSTK,
+               USER_REGSET_NOTE_TYPE(X86_SHSTK),
                .n              = 1,
                .size           = sizeof(u64),
                .align          = sizeof(u64),
@@ -1297,7 +1297,7 @@ static const struct user_regset_view user_x86_64_view = {
 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
 static struct user_regset x86_32_regsets[] __ro_after_init = {
        [REGSET32_GENERAL] = {
-               .core_note_type = NT_PRSTATUS,
+               USER_REGSET_NOTE_TYPE(PRSTATUS),
                .n              = sizeof(struct user_regs_struct32) / sizeof(u32),
                .size           = sizeof(u32),
                .align          = sizeof(u32),
@@ -1305,7 +1305,7 @@ static struct user_regset x86_32_regsets[] __ro_after_init = {
                .set            = genregs32_set
        },
        [REGSET32_FP] = {
-               .core_note_type = NT_PRFPREG,
+               USER_REGSET_NOTE_TYPE(PRFPREG),
                .n              = sizeof(struct user_i387_ia32_struct) / sizeof(u32),
                .size           = sizeof(u32),
                .align          = sizeof(u32),
@@ -1314,7 +1314,7 @@ static struct user_regset x86_32_regsets[] __ro_after_init = {
                .set            = fpregs_set
        },
        [REGSET32_XFP] = {
-               .core_note_type = NT_PRXFPREG,
+               USER_REGSET_NOTE_TYPE(PRXFPREG),
                .n              = sizeof(struct fxregs_state) / sizeof(u32),
                .size           = sizeof(u32),
                .align          = sizeof(u32),
@@ -1323,7 +1323,7 @@ static struct user_regset x86_32_regsets[] __ro_after_init = {
                .set            = xfpregs_set
        },
        [REGSET32_XSTATE] = {
-               .core_note_type = NT_X86_XSTATE,
+               USER_REGSET_NOTE_TYPE(X86_XSTATE),
                .size           = sizeof(u64),
                .align          = sizeof(u64),
                .active         = xstateregs_active,
@@ -1331,7 +1331,7 @@ static struct user_regset x86_32_regsets[] __ro_after_init = {
                .set            = xstateregs_set
        },
        [REGSET32_TLS] = {
-               .core_note_type = NT_386_TLS,
+               USER_REGSET_NOTE_TYPE(386_TLS),
                .n              = GDT_ENTRY_TLS_ENTRIES,
                .bias           = GDT_ENTRY_TLS_MIN,
                .size           = sizeof(struct user_desc),
@@ -1341,7 +1341,7 @@ static struct user_regset x86_32_regsets[] __ro_after_init = {
                .set            = regset_tls_set
        },
        [REGSET32_IOPERM] = {
-               .core_note_type = NT_386_IOPERM,
+               USER_REGSET_NOTE_TYPE(386_IOPERM),
                .n              = IO_BITMAP_BYTES / sizeof(u32),
                .size           = sizeof(u32),
                .align          = sizeof(u32),