Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names

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>

authored by

Dave Martin and committed by
Kees Cook
3de0414d c9d4cb25

+11 -11
+11 -11
arch/x86/kernel/ptrace.c
··· 1236 1236 1237 1237 static struct user_regset x86_64_regsets[] __ro_after_init = { 1238 1238 [REGSET64_GENERAL] = { 1239 - .core_note_type = NT_PRSTATUS, 1239 + USER_REGSET_NOTE_TYPE(PRSTATUS), 1240 1240 .n = sizeof(struct user_regs_struct) / sizeof(long), 1241 1241 .size = sizeof(long), 1242 1242 .align = sizeof(long), ··· 1244 1244 .set = genregs_set 1245 1245 }, 1246 1246 [REGSET64_FP] = { 1247 - .core_note_type = NT_PRFPREG, 1247 + USER_REGSET_NOTE_TYPE(PRFPREG), 1248 1248 .n = sizeof(struct fxregs_state) / sizeof(long), 1249 1249 .size = sizeof(long), 1250 1250 .align = sizeof(long), ··· 1253 1253 .set = xfpregs_set 1254 1254 }, 1255 1255 [REGSET64_XSTATE] = { 1256 - .core_note_type = NT_X86_XSTATE, 1256 + USER_REGSET_NOTE_TYPE(X86_XSTATE), 1257 1257 .size = sizeof(u64), 1258 1258 .align = sizeof(u64), 1259 1259 .active = xstateregs_active, ··· 1261 1261 .set = xstateregs_set 1262 1262 }, 1263 1263 [REGSET64_IOPERM] = { 1264 - .core_note_type = NT_386_IOPERM, 1264 + USER_REGSET_NOTE_TYPE(386_IOPERM), 1265 1265 .n = IO_BITMAP_LONGS, 1266 1266 .size = sizeof(long), 1267 1267 .align = sizeof(long), ··· 1270 1270 }, 1271 1271 #ifdef CONFIG_X86_USER_SHADOW_STACK 1272 1272 [REGSET64_SSP] = { 1273 - .core_note_type = NT_X86_SHSTK, 1273 + USER_REGSET_NOTE_TYPE(X86_SHSTK), 1274 1274 .n = 1, 1275 1275 .size = sizeof(u64), 1276 1276 .align = sizeof(u64), ··· 1297 1297 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION 1298 1298 static struct user_regset x86_32_regsets[] __ro_after_init = { 1299 1299 [REGSET32_GENERAL] = { 1300 - .core_note_type = NT_PRSTATUS, 1300 + USER_REGSET_NOTE_TYPE(PRSTATUS), 1301 1301 .n = sizeof(struct user_regs_struct32) / sizeof(u32), 1302 1302 .size = sizeof(u32), 1303 1303 .align = sizeof(u32), ··· 1305 1305 .set = genregs32_set 1306 1306 }, 1307 1307 [REGSET32_FP] = { 1308 - .core_note_type = NT_PRFPREG, 1308 + USER_REGSET_NOTE_TYPE(PRFPREG), 1309 1309 .n = sizeof(struct user_i387_ia32_struct) / sizeof(u32), 1310 1310 .size = sizeof(u32), 1311 1311 .align = sizeof(u32), ··· 1314 1314 .set = fpregs_set 1315 1315 }, 1316 1316 [REGSET32_XFP] = { 1317 - .core_note_type = NT_PRXFPREG, 1317 + USER_REGSET_NOTE_TYPE(PRXFPREG), 1318 1318 .n = sizeof(struct fxregs_state) / sizeof(u32), 1319 1319 .size = sizeof(u32), 1320 1320 .align = sizeof(u32), ··· 1323 1323 .set = xfpregs_set 1324 1324 }, 1325 1325 [REGSET32_XSTATE] = { 1326 - .core_note_type = NT_X86_XSTATE, 1326 + USER_REGSET_NOTE_TYPE(X86_XSTATE), 1327 1327 .size = sizeof(u64), 1328 1328 .align = sizeof(u64), 1329 1329 .active = xstateregs_active, ··· 1331 1331 .set = xstateregs_set 1332 1332 }, 1333 1333 [REGSET32_TLS] = { 1334 - .core_note_type = NT_386_TLS, 1334 + USER_REGSET_NOTE_TYPE(386_TLS), 1335 1335 .n = GDT_ENTRY_TLS_ENTRIES, 1336 1336 .bias = GDT_ENTRY_TLS_MIN, 1337 1337 .size = sizeof(struct user_desc), ··· 1341 1341 .set = regset_tls_set 1342 1342 }, 1343 1343 [REGSET32_IOPERM] = { 1344 - .core_note_type = NT_386_IOPERM, 1344 + USER_REGSET_NOTE_TYPE(386_IOPERM), 1345 1345 .n = IO_BITMAP_BYTES / sizeof(u32), 1346 1346 .size = sizeof(u32), 1347 1347 .align = sizeof(u32),