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

Configure Feed

Select the types of activity you want to include in your feed.

binfmt_elf: Use note name macros

Use note name macros to match with the userspace's expectation.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Acked-by: Baoquan He <bhe@redhat.com>
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Link: https://lore.kernel.org/r/20250115-elf-v5-2-0f9e55bbb2fc@daynix.com
Signed-off-by: Kees Cook <kees@kernel.org>

authored by

Akihiko Odaki and committed by
Kees Cook
2fc4947b 7da8e4ad

+14 -15
+10 -11
fs/binfmt_elf.c
··· 762 762 } 763 763 764 764 #define NOTE_DATA_SZ SZ_1K 765 - #define GNU_PROPERTY_TYPE_0_NAME "GNU" 766 - #define NOTE_NAME_SZ (sizeof(GNU_PROPERTY_TYPE_0_NAME)) 765 + #define NOTE_NAME_SZ (sizeof(NN_GNU_PROPERTY_TYPE_0)) 767 766 768 767 static int parse_elf_properties(struct file *f, const struct elf_phdr *phdr, 769 768 struct arch_elf_state *arch) ··· 799 800 if (note.nhdr.n_type != NT_GNU_PROPERTY_TYPE_0 || 800 801 note.nhdr.n_namesz != NOTE_NAME_SZ || 801 802 strncmp(note.data + sizeof(note.nhdr), 802 - GNU_PROPERTY_TYPE_0_NAME, n - sizeof(note.nhdr))) 803 + NN_GNU_PROPERTY_TYPE_0, n - sizeof(note.nhdr))) 803 804 return -ENOEXEC; 804 805 805 806 off = round_up(sizeof(note.nhdr) + NOTE_NAME_SZ, ··· 1602 1603 do 1603 1604 i += 2; 1604 1605 while (auxv[i - 2] != AT_NULL); 1605 - fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv); 1606 + fill_note(note, NN_AUXV, NT_AUXV, i * sizeof(elf_addr_t), auxv); 1606 1607 } 1607 1608 1608 1609 static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata, 1609 1610 const kernel_siginfo_t *siginfo) 1610 1611 { 1611 1612 copy_siginfo_to_external(csigdata, siginfo); 1612 - fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata); 1613 + fill_note(note, NN_SIGINFO, NT_SIGINFO, sizeof(*csigdata), csigdata); 1613 1614 } 1614 1615 1615 1616 /* ··· 1705 1706 } 1706 1707 1707 1708 size = name_curpos - (char *)data; 1708 - fill_note(note, "CORE", NT_FILE, size, data); 1709 + fill_note(note, NN_FILE, NT_FILE, size, data); 1709 1710 return 0; 1710 1711 } 1711 1712 ··· 1766 1767 regset_get(t->task, &view->regsets[0], 1767 1768 sizeof(t->prstatus.pr_reg), &t->prstatus.pr_reg); 1768 1769 1769 - fill_note(&t->notes[0], "CORE", NT_PRSTATUS, 1770 + fill_note(&t->notes[0], NN_PRSTATUS, NT_PRSTATUS, 1770 1771 PRSTATUS_SIZE, &t->prstatus); 1771 1772 info->size += notesize(&t->notes[0]); 1772 1773 ··· 1800 1801 if (is_fpreg) 1801 1802 SET_PR_FPVALID(&t->prstatus); 1802 1803 1803 - fill_note(&t->notes[note_iter], is_fpreg ? "CORE" : "LINUX", 1804 + fill_note(&t->notes[note_iter], is_fpreg ? NN_PRFPREG : "LINUX", 1804 1805 note_type, ret, data); 1805 1806 1806 1807 info->size += notesize(&t->notes[note_iter]); ··· 1820 1821 fill_prstatus(&t->prstatus.common, p, signr); 1821 1822 elf_core_copy_task_regs(p, &t->prstatus.pr_reg); 1822 1823 1823 - fill_note(&t->notes[0], "CORE", NT_PRSTATUS, sizeof(t->prstatus), 1824 + fill_note(&t->notes[0], NN_PRSTATUS, NT_PRSTATUS, sizeof(t->prstatus), 1824 1825 &(t->prstatus)); 1825 1826 info->size += notesize(&t->notes[0]); 1826 1827 ··· 1831 1832 } 1832 1833 1833 1834 t->prstatus.pr_fpvalid = 1; 1834 - fill_note(&t->notes[1], "CORE", NT_PRFPREG, sizeof(*fpu), fpu); 1835 + fill_note(&t->notes[1], NN_PRFPREG, NT_PRFPREG, sizeof(*fpu), fpu); 1835 1836 info->size += notesize(&t->notes[1]); 1836 1837 1837 1838 return 1; ··· 1851 1852 psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL); 1852 1853 if (!psinfo) 1853 1854 return 0; 1854 - fill_note(&info->psinfo, "CORE", NT_PRPSINFO, sizeof(*psinfo), psinfo); 1855 + fill_note(&info->psinfo, NN_PRPSINFO, NT_PRPSINFO, sizeof(*psinfo), psinfo); 1855 1856 1856 1857 #ifdef CORE_DUMP_USE_REGSET 1857 1858 view = task_user_regset_view(dump_task);
+4 -4
fs/binfmt_elf_fdpic.c
··· 1397 1397 regset_get(p, &view->regsets[0], 1398 1398 sizeof(t->prstatus.pr_reg), &t->prstatus.pr_reg); 1399 1399 1400 - fill_note(&t->notes[0], "CORE", NT_PRSTATUS, sizeof(t->prstatus), 1400 + fill_note(&t->notes[0], NN_PRSTATUS, NT_PRSTATUS, sizeof(t->prstatus), 1401 1401 &t->prstatus); 1402 1402 t->num_notes++; 1403 1403 *sz += notesize(&t->notes[0]); ··· 1415 1415 } 1416 1416 1417 1417 if (t->prstatus.pr_fpvalid) { 1418 - fill_note(&t->notes[1], "CORE", NT_PRFPREG, sizeof(t->fpu), 1418 + fill_note(&t->notes[1], NN_PRFPREG, NT_PRFPREG, sizeof(t->fpu), 1419 1419 &t->fpu); 1420 1420 t->num_notes++; 1421 1421 *sz += notesize(&t->notes[1]); ··· 1530 1530 */ 1531 1531 1532 1532 fill_psinfo(psinfo, current->group_leader, current->mm); 1533 - fill_note(&psinfo_note, "CORE", NT_PRPSINFO, sizeof(*psinfo), psinfo); 1533 + fill_note(&psinfo_note, NN_PRPSINFO, NT_PRPSINFO, sizeof(*psinfo), psinfo); 1534 1534 thread_status_size += notesize(&psinfo_note); 1535 1535 1536 1536 auxv = (elf_addr_t *) current->mm->saved_auxv; ··· 1538 1538 do 1539 1539 i += 2; 1540 1540 while (auxv[i - 2] != AT_NULL); 1541 - fill_note(&auxv_note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv); 1541 + fill_note(&auxv_note, NN_AUXV, NT_AUXV, i * sizeof(elf_addr_t), auxv); 1542 1542 thread_status_size += notesize(&auxv_note); 1543 1543 1544 1544 offset = sizeof(*elf); /* ELF header */