Skip to content

Commit 7da8e4a

Browse files
akihikodakikees
authored andcommitted
elf: Define note name macros
elf.h had a comment saying: > Notes used in ET_CORE. Architectures export some of the arch register > sets using the corresponding note types via the PTRACE_GETREGSET and > PTRACE_SETREGSET requests. > The note name for these types is "LINUX", except NT_PRFPREG that is > named "CORE". However, NT_PRSTATUS is also named "CORE". It is also unclear what "these types" refers to. To fix these problems, define a name for each note type. The added definitions are macros so the kernel and userspace can directly refer to them to remove their duplicate definitions of note names. Signed-off-by: Akihiko Odaki <[email protected]> Acked-by: Baoquan He <[email protected]> Reviewed-by: Dave Martin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent a64dcfb commit 7da8e4a

File tree

1 file changed

+84
-5
lines changed

1 file changed

+84
-5
lines changed

include/uapi/linux/elf.h

Lines changed: 84 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,101 +368,180 @@ typedef struct elf64_shdr {
368368
#define ELF_OSABI ELFOSABI_NONE
369369
#endif
370370

371+
/* Note definitions: NN_ defines names. NT_ defines types. */
372+
373+
#define NN_GNU_PROPERTY_TYPE_0 "GNU"
374+
#define NT_GNU_PROPERTY_TYPE_0 5
375+
371376
/*
372377
* Notes used in ET_CORE. Architectures export some of the arch register sets
373378
* using the corresponding note types via the PTRACE_GETREGSET and
374379
* PTRACE_SETREGSET requests.
375-
* The note name for these types is "LINUX", except NT_PRFPREG that is named
376-
* "CORE".
377380
*/
381+
#define NN_PRSTATUS "CORE"
378382
#define NT_PRSTATUS 1
383+
#define NN_PRFPREG "CORE"
379384
#define NT_PRFPREG 2
385+
#define NN_PRPSINFO "CORE"
380386
#define NT_PRPSINFO 3
387+
#define NN_TASKSTRUCT "CORE"
381388
#define NT_TASKSTRUCT 4
389+
#define NN_AUXV "CORE"
382390
#define NT_AUXV 6
383391
/*
384392
* Note to userspace developers: size of NT_SIGINFO note may increase
385393
* in the future to accomodate more fields, don't assume it is fixed!
386394
*/
395+
#define NN_SIGINFO "CORE"
387396
#define NT_SIGINFO 0x53494749
397+
#define NN_FILE "CORE"
388398
#define NT_FILE 0x46494c45
399+
#define NN_PRXFPREG "LINUX"
389400
#define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/common.h */
401+
#define NN_PPC_VMX "LINUX"
390402
#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */
403+
#define NN_PPC_SPE "LINUX"
391404
#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */
405+
#define NN_PPC_VSX "LINUX"
392406
#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */
407+
#define NN_PPC_TAR "LINUX"
393408
#define NT_PPC_TAR 0x103 /* Target Address Register */
409+
#define NN_PPC_PPR "LINUX"
394410
#define NT_PPC_PPR 0x104 /* Program Priority Register */
411+
#define NN_PPC_DSCR "LINUX"
395412
#define NT_PPC_DSCR 0x105 /* Data Stream Control Register */
413+
#define NN_PPC_EBB "LINUX"
396414
#define NT_PPC_EBB 0x106 /* Event Based Branch Registers */
415+
#define NN_PPC_PMU "LINUX"
397416
#define NT_PPC_PMU 0x107 /* Performance Monitor Registers */
417+
#define NN_PPC_TM_CGPR "LINUX"
398418
#define NT_PPC_TM_CGPR 0x108 /* TM checkpointed GPR Registers */
419+
#define NN_PPC_TM_CFPR "LINUX"
399420
#define NT_PPC_TM_CFPR 0x109 /* TM checkpointed FPR Registers */
421+
#define NN_PPC_TM_CVMX "LINUX"
400422
#define NT_PPC_TM_CVMX 0x10a /* TM checkpointed VMX Registers */
423+
#define NN_PPC_TM_CVSX "LINUX"
401424
#define NT_PPC_TM_CVSX 0x10b /* TM checkpointed VSX Registers */
425+
#define NN_PPC_TM_SPR "LINUX"
402426
#define NT_PPC_TM_SPR 0x10c /* TM Special Purpose Registers */
427+
#define NN_PPC_TM_CTAR "LINUX"
403428
#define NT_PPC_TM_CTAR 0x10d /* TM checkpointed Target Address Register */
429+
#define NN_PPC_TM_CPPR "LINUX"
404430
#define NT_PPC_TM_CPPR 0x10e /* TM checkpointed Program Priority Register */
431+
#define NN_PPC_TM_CDSCR "LINUX"
405432
#define NT_PPC_TM_CDSCR 0x10f /* TM checkpointed Data Stream Control Register */
433+
#define NN_PPC_PKEY "LINUX"
406434
#define NT_PPC_PKEY 0x110 /* Memory Protection Keys registers */
435+
#define NN_PPC_DEXCR "LINUX"
407436
#define NT_PPC_DEXCR 0x111 /* PowerPC DEXCR registers */
437+
#define NN_PPC_HASHKEYR "LINUX"
408438
#define NT_PPC_HASHKEYR 0x112 /* PowerPC HASHKEYR register */
439+
#define NN_386_TLS "LINUX"
409440
#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */
441+
#define NN_386_IOPERM "LINUX"
410442
#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */
443+
#define NN_X86_XSTATE "LINUX"
411444
#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */
412445
/* Old binutils treats 0x203 as a CET state */
446+
#define NN_X86_SHSTK "LINUX"
413447
#define NT_X86_SHSTK 0x204 /* x86 SHSTK state */
448+
#define NN_X86_XSAVE_LAYOUT "LINUX"
414449
#define NT_X86_XSAVE_LAYOUT 0x205 /* XSAVE layout description */
450+
#define NN_S390_HIGH_GPRS "LINUX"
415451
#define NT_S390_HIGH_GPRS 0x300 /* s390 upper register halves */
452+
#define NN_S390_TIMER "LINUX"
416453
#define NT_S390_TIMER 0x301 /* s390 timer register */
454+
#define NN_S390_TODCMP "LINUX"
417455
#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */
456+
#define NN_S390_TODPREG "LINUX"
418457
#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */
458+
#define NN_S390_CTRS "LINUX"
419459
#define NT_S390_CTRS 0x304 /* s390 control registers */
460+
#define NN_S390_PREFIX "LINUX"
420461
#define NT_S390_PREFIX 0x305 /* s390 prefix register */
462+
#define NN_S390_LAST_BREAK "LINUX"
421463
#define NT_S390_LAST_BREAK 0x306 /* s390 breaking event address */
464+
#define NN_S390_SYSTEM_CALL "LINUX"
422465
#define NT_S390_SYSTEM_CALL 0x307 /* s390 system call restart data */
466+
#define NN_S390_TDB "LINUX"
423467
#define NT_S390_TDB 0x308 /* s390 transaction diagnostic block */
468+
#define NN_S390_VXRS_LOW "LINUX"
424469
#define NT_S390_VXRS_LOW 0x309 /* s390 vector registers 0-15 upper half */
470+
#define NN_S390_VXRS_HIGH "LINUX"
425471
#define NT_S390_VXRS_HIGH 0x30a /* s390 vector registers 16-31 */
472+
#define NN_S390_GS_CB "LINUX"
426473
#define NT_S390_GS_CB 0x30b /* s390 guarded storage registers */
474+
#define NN_S390_GS_BC "LINUX"
427475
#define NT_S390_GS_BC 0x30c /* s390 guarded storage broadcast control block */
476+
#define NN_S390_RI_CB "LINUX"
428477
#define NT_S390_RI_CB 0x30d /* s390 runtime instrumentation */
478+
#define NN_S390_PV_CPU_DATA "LINUX"
429479
#define NT_S390_PV_CPU_DATA 0x30e /* s390 protvirt cpu dump data */
480+
#define NN_ARM_VFP "LINUX"
430481
#define NT_ARM_VFP 0x400 /* ARM VFP/NEON registers */
482+
#define NN_ARM_TLS "LINUX"
431483
#define NT_ARM_TLS 0x401 /* ARM TLS register */
484+
#define NN_ARM_HW_BREAK "LINUX"
432485
#define NT_ARM_HW_BREAK 0x402 /* ARM hardware breakpoint registers */
486+
#define NN_ARM_HW_WATCH "LINUX"
433487
#define NT_ARM_HW_WATCH 0x403 /* ARM hardware watchpoint registers */
488+
#define NN_ARM_SYSTEM_CALL "LINUX"
434489
#define NT_ARM_SYSTEM_CALL 0x404 /* ARM system call number */
490+
#define NN_ARM_SVE "LINUX"
435491
#define NT_ARM_SVE 0x405 /* ARM Scalable Vector Extension registers */
492+
#define NN_ARM_PAC_MASK "LINUX"
436493
#define NT_ARM_PAC_MASK 0x406 /* ARM pointer authentication code masks */
494+
#define NN_ARM_PACA_KEYS "LINUX"
437495
#define NT_ARM_PACA_KEYS 0x407 /* ARM pointer authentication address keys */
496+
#define NN_ARM_PACG_KEYS "LINUX"
438497
#define NT_ARM_PACG_KEYS 0x408 /* ARM pointer authentication generic key */
498+
#define NN_ARM_TAGGED_ADDR_CTRL "LINUX"
439499
#define NT_ARM_TAGGED_ADDR_CTRL 0x409 /* arm64 tagged address control (prctl()) */
500+
#define NN_ARM_PAC_ENABLED_KEYS "LINUX"
440501
#define NT_ARM_PAC_ENABLED_KEYS 0x40a /* arm64 ptr auth enabled keys (prctl()) */
502+
#define NN_ARM_SSVE "LINUX"
441503
#define NT_ARM_SSVE 0x40b /* ARM Streaming SVE registers */
504+
#define NN_ARM_ZA "LINUX"
442505
#define NT_ARM_ZA 0x40c /* ARM SME ZA registers */
506+
#define NN_ARM_ZT "LINUX"
443507
#define NT_ARM_ZT 0x40d /* ARM SME ZT registers */
508+
#define NN_ARM_FPMR "LINUX"
444509
#define NT_ARM_FPMR 0x40e /* ARM floating point mode register */
510+
#define NN_ARM_POE "LINUX"
445511
#define NT_ARM_POE 0x40f /* ARM POE registers */
512+
#define NN_ARM_GCS "LINUX"
446513
#define NT_ARM_GCS 0x410 /* ARM GCS state */
514+
#define NN_ARC_V2 "LINUX"
447515
#define NT_ARC_V2 0x600 /* ARCv2 accumulator/extra registers */
516+
#define NN_VMCOREDD "LINUX"
448517
#define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note */
518+
#define NN_MIPS_DSP "LINUX"
449519
#define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers */
520+
#define NN_MIPS_FP_MODE "LINUX"
450521
#define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode */
522+
#define NN_MIPS_MSA "LINUX"
451523
#define NT_MIPS_MSA 0x802 /* MIPS SIMD registers */
524+
#define NN_RISCV_CSR "LINUX"
452525
#define NT_RISCV_CSR 0x900 /* RISC-V Control and Status Registers */
526+
#define NN_RISCV_VECTOR "LINUX"
453527
#define NT_RISCV_VECTOR 0x901 /* RISC-V vector registers */
528+
#define NN_RISCV_TAGGED_ADDR_CTRL "LINUX"
454529
#define NT_RISCV_TAGGED_ADDR_CTRL 0x902 /* RISC-V tagged address control (prctl()) */
530+
#define NN_LOONGARCH_CPUCFG "LINUX"
455531
#define NT_LOONGARCH_CPUCFG 0xa00 /* LoongArch CPU config registers */
532+
#define NN_LOONGARCH_CSR "LINUX"
456533
#define NT_LOONGARCH_CSR 0xa01 /* LoongArch control and status registers */
534+
#define NN_LOONGARCH_LSX "LINUX"
457535
#define NT_LOONGARCH_LSX 0xa02 /* LoongArch Loongson SIMD Extension registers */
536+
#define NN_LOONGARCH_LASX "LINUX"
458537
#define NT_LOONGARCH_LASX 0xa03 /* LoongArch Loongson Advanced SIMD Extension registers */
538+
#define NN_LOONGARCH_LBT "LINUX"
459539
#define NT_LOONGARCH_LBT 0xa04 /* LoongArch Loongson Binary Translation registers */
540+
#define NN_LOONGARCH_HW_BREAK "LINUX"
460541
#define NT_LOONGARCH_HW_BREAK 0xa05 /* LoongArch hardware breakpoint registers */
542+
#define NN_LOONGARCH_HW_WATCH "LINUX"
461543
#define NT_LOONGARCH_HW_WATCH 0xa06 /* LoongArch hardware watchpoint registers */
462544

463-
/* Note types with note name "GNU" */
464-
#define NT_GNU_PROPERTY_TYPE_0 5
465-
466545
/* Note header in a PT_NOTE section */
467546
typedef struct elf32_note {
468547
Elf32_Word n_namesz; /* Name size */

0 commit comments

Comments
 (0)