Skip to content

Commit 2fc4947

Browse files
akihikodakikees
authored andcommitted
binfmt_elf: Use note name macros
Use note name macros to match with the userspace's expectation. 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 7da8e4a commit 2fc4947

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

fs/binfmt_elf.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,7 @@ static int parse_elf_property(const char *data, size_t *off, size_t datasz,
762762
}
763763

764764
#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))
767766

768767
static int parse_elf_properties(struct file *f, const struct elf_phdr *phdr,
769768
struct arch_elf_state *arch)
@@ -800,7 +799,7 @@ static int parse_elf_properties(struct file *f, const struct elf_phdr *phdr,
800799
if (note.nhdr.n_type != NT_GNU_PROPERTY_TYPE_0 ||
801800
note.nhdr.n_namesz != NOTE_NAME_SZ ||
802801
strncmp(note.data + sizeof(note.nhdr),
803-
GNU_PROPERTY_TYPE_0_NAME, n - sizeof(note.nhdr)))
802+
NN_GNU_PROPERTY_TYPE_0, n - sizeof(note.nhdr)))
804803
return -ENOEXEC;
805804

806805
off = round_up(sizeof(note.nhdr) + NOTE_NAME_SZ,
@@ -1603,14 +1602,14 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
16031602
do
16041603
i += 2;
16051604
while (auxv[i - 2] != AT_NULL);
1606-
fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
1605+
fill_note(note, NN_AUXV, NT_AUXV, i * sizeof(elf_addr_t), auxv);
16071606
}
16081607

16091608
static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
16101609
const kernel_siginfo_t *siginfo)
16111610
{
16121611
copy_siginfo_to_external(csigdata, siginfo);
1613-
fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
1612+
fill_note(note, NN_SIGINFO, NT_SIGINFO, sizeof(*csigdata), csigdata);
16141613
}
16151614

16161615
/*
@@ -1706,7 +1705,7 @@ static int fill_files_note(struct memelfnote *note, struct coredump_params *cprm
17061705
}
17071706

17081707
size = name_curpos - (char *)data;
1709-
fill_note(note, "CORE", NT_FILE, size, data);
1708+
fill_note(note, NN_FILE, NT_FILE, size, data);
17101709
return 0;
17111710
}
17121711

@@ -1767,7 +1766,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
17671766
regset_get(t->task, &view->regsets[0],
17681767
sizeof(t->prstatus.pr_reg), &t->prstatus.pr_reg);
17691768

1770-
fill_note(&t->notes[0], "CORE", NT_PRSTATUS,
1769+
fill_note(&t->notes[0], NN_PRSTATUS, NT_PRSTATUS,
17711770
PRSTATUS_SIZE, &t->prstatus);
17721771
info->size += notesize(&t->notes[0]);
17731772

@@ -1801,7 +1800,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
18011800
if (is_fpreg)
18021801
SET_PR_FPVALID(&t->prstatus);
18031802

1804-
fill_note(&t->notes[note_iter], is_fpreg ? "CORE" : "LINUX",
1803+
fill_note(&t->notes[note_iter], is_fpreg ? NN_PRFPREG : "LINUX",
18051804
note_type, ret, data);
18061805

18071806
info->size += notesize(&t->notes[note_iter]);
@@ -1821,7 +1820,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
18211820
fill_prstatus(&t->prstatus.common, p, signr);
18221821
elf_core_copy_task_regs(p, &t->prstatus.pr_reg);
18231822

1824-
fill_note(&t->notes[0], "CORE", NT_PRSTATUS, sizeof(t->prstatus),
1823+
fill_note(&t->notes[0], NN_PRSTATUS, NT_PRSTATUS, sizeof(t->prstatus),
18251824
&(t->prstatus));
18261825
info->size += notesize(&t->notes[0]);
18271826

@@ -1832,7 +1831,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
18321831
}
18331832

18341833
t->prstatus.pr_fpvalid = 1;
1835-
fill_note(&t->notes[1], "CORE", NT_PRFPREG, sizeof(*fpu), fpu);
1834+
fill_note(&t->notes[1], NN_PRFPREG, NT_PRFPREG, sizeof(*fpu), fpu);
18361835
info->size += notesize(&t->notes[1]);
18371836

18381837
return 1;
@@ -1852,7 +1851,7 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
18521851
psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL);
18531852
if (!psinfo)
18541853
return 0;
1855-
fill_note(&info->psinfo, "CORE", NT_PRPSINFO, sizeof(*psinfo), psinfo);
1854+
fill_note(&info->psinfo, NN_PRPSINFO, NT_PRPSINFO, sizeof(*psinfo), psinfo);
18561855

18571856
#ifdef CORE_DUMP_USE_REGSET
18581857
view = task_user_regset_view(dump_task);

fs/binfmt_elf_fdpic.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ static struct elf_thread_status *elf_dump_thread_status(long signr, struct task_
13971397
regset_get(p, &view->regsets[0],
13981398
sizeof(t->prstatus.pr_reg), &t->prstatus.pr_reg);
13991399

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),
14011401
&t->prstatus);
14021402
t->num_notes++;
14031403
*sz += notesize(&t->notes[0]);
@@ -1415,7 +1415,7 @@ static struct elf_thread_status *elf_dump_thread_status(long signr, struct task_
14151415
}
14161416

14171417
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),
14191419
&t->fpu);
14201420
t->num_notes++;
14211421
*sz += notesize(&t->notes[1]);
@@ -1530,15 +1530,15 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
15301530
*/
15311531

15321532
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);
15341534
thread_status_size += notesize(&psinfo_note);
15351535

15361536
auxv = (elf_addr_t *) current->mm->saved_auxv;
15371537
i = 0;
15381538
do
15391539
i += 2;
15401540
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);
15421542
thread_status_size += notesize(&auxv_note);
15431543

15441544
offset = sizeof(*elf); /* ELF header */

0 commit comments

Comments
 (0)