Skip to content

Commit 4f773fc

Browse files
committed
Merge tag 'execve-v6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull execve updates from Kees Cook: - elf: Define and use note name macros (Akihiko Odaki) - elf: add remaining SHF_ flag macros (Timur Tabi) - binfmt: Remove loader from linux_binprm struct (Yonatan Goldschmidt) - binfmt_elf_fdpic: fix variable set but not used warning (sunliming) * tag 'execve-v6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: binfmt_elf_fdpic: fix variable set but not used warning elf: add remaining SHF_ flag macros binfmt: Remove loader from linux_binprm struct crash: Remove KEXEC_CORE_NOTE_NAME s390/crash: Use note name macros crash: Use note name macros powerpc/crash: Use note name macros binfmt_elf: Use note name macros elf: Define note name macros
2 parents b0cb56c + 8d68cab commit 4f773fc

File tree

12 files changed

+148
-80
lines changed

12 files changed

+148
-80
lines changed

arch/powerpc/kernel/fadump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ u32 *__init fadump_regs_to_elf_notes(u32 *buf, struct pt_regs *regs)
751751
* prstatus.pr_pid = ????
752752
*/
753753
elf_core_copy_regs(&prstatus.pr_reg, regs);
754-
buf = append_elf_note(buf, CRASH_CORE_NOTE_NAME, NT_PRSTATUS,
754+
buf = append_elf_note(buf, NN_PRSTATUS, NT_PRSTATUS,
755755
&prstatus, sizeof(prstatus));
756756
return buf;
757757
}

arch/powerpc/platforms/powernv/opal-core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static Elf64_Word *__init auxv_to_elf64_notes(Elf64_Word *buf,
149149
/* end of vector */
150150
bufp[idx++] = cpu_to_be64(AT_NULL);
151151

152-
buf = append_elf64_note(buf, CRASH_CORE_NOTE_NAME, NT_AUXV,
152+
buf = append_elf64_note(buf, NN_AUXV, NT_AUXV,
153153
oc_conf->auxv_buf, AUXV_DESC_SZ);
154154
return buf;
155155
}
@@ -252,7 +252,7 @@ static Elf64_Word * __init opalcore_append_cpu_notes(Elf64_Word *buf)
252252
* crashing CPU's prstatus.
253253
*/
254254
first_cpu_note = buf;
255-
buf = append_elf64_note(buf, CRASH_CORE_NOTE_NAME, NT_PRSTATUS,
255+
buf = append_elf64_note(buf, NN_PRSTATUS, NT_PRSTATUS,
256256
&prstatus, sizeof(prstatus));
257257

258258
for (i = 0; i < oc_conf->num_cpus; i++, bufp += size_per_thread) {
@@ -279,15 +279,15 @@ static Elf64_Word * __init opalcore_append_cpu_notes(Elf64_Word *buf)
279279
fill_prstatus(&prstatus, thread_pir, &regs);
280280

281281
if (thread_pir != oc_conf->crashing_cpu) {
282-
buf = append_elf64_note(buf, CRASH_CORE_NOTE_NAME,
282+
buf = append_elf64_note(buf, NN_PRSTATUS,
283283
NT_PRSTATUS, &prstatus,
284284
sizeof(prstatus));
285285
} else {
286286
/*
287287
* Add crashing CPU as the first NT_PRSTATUS note for
288288
* GDB to process the core file appropriately.
289289
*/
290-
append_elf64_note(first_cpu_note, CRASH_CORE_NOTE_NAME,
290+
append_elf64_note(first_cpu_note, NN_PRSTATUS,
291291
NT_PRSTATUS, &prstatus,
292292
sizeof(prstatus));
293293
}

arch/s390/kernel/crash_dump.c

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,6 @@ bool is_kdump_kernel(void)
246246
}
247247
EXPORT_SYMBOL_GPL(is_kdump_kernel);
248248

249-
static const char *nt_name(Elf64_Word type)
250-
{
251-
const char *name = "LINUX";
252-
253-
if (type == NT_PRPSINFO || type == NT_PRSTATUS || type == NT_PRFPREG)
254-
name = KEXEC_CORE_NOTE_NAME;
255-
return name;
256-
}
257-
258249
/*
259250
* Initialize ELF note
260251
*/
@@ -279,10 +270,8 @@ static void *nt_init_name(void *buf, Elf64_Word type, void *desc, int d_len,
279270
return PTR_ADD(buf, len);
280271
}
281272

282-
static inline void *nt_init(void *buf, Elf64_Word type, void *desc, int d_len)
283-
{
284-
return nt_init_name(buf, type, desc, d_len, nt_name(type));
285-
}
273+
#define nt_init(buf, type, desc) \
274+
nt_init_name(buf, NT_ ## type, &(desc), sizeof(desc), NN_ ## type)
286275

287276
/*
288277
* Calculate the size of ELF note
@@ -298,10 +287,7 @@ static size_t nt_size_name(int d_len, const char *name)
298287
return size;
299288
}
300289

301-
static inline size_t nt_size(Elf64_Word type, int d_len)
302-
{
303-
return nt_size_name(d_len, nt_name(type));
304-
}
290+
#define nt_size(type, desc) nt_size_name(sizeof(desc), NN_ ## type)
305291

306292
/*
307293
* Fill ELF notes for one CPU with save area registers
@@ -322,18 +308,16 @@ static void *fill_cpu_elf_notes(void *ptr, int cpu, struct save_area *sa)
322308
memcpy(&nt_fpregset.fpc, &sa->fpc, sizeof(sa->fpc));
323309
memcpy(&nt_fpregset.fprs, &sa->fprs, sizeof(sa->fprs));
324310
/* Create ELF notes for the CPU */
325-
ptr = nt_init(ptr, NT_PRSTATUS, &nt_prstatus, sizeof(nt_prstatus));
326-
ptr = nt_init(ptr, NT_PRFPREG, &nt_fpregset, sizeof(nt_fpregset));
327-
ptr = nt_init(ptr, NT_S390_TIMER, &sa->timer, sizeof(sa->timer));
328-
ptr = nt_init(ptr, NT_S390_TODCMP, &sa->todcmp, sizeof(sa->todcmp));
329-
ptr = nt_init(ptr, NT_S390_TODPREG, &sa->todpreg, sizeof(sa->todpreg));
330-
ptr = nt_init(ptr, NT_S390_CTRS, &sa->ctrs, sizeof(sa->ctrs));
331-
ptr = nt_init(ptr, NT_S390_PREFIX, &sa->prefix, sizeof(sa->prefix));
311+
ptr = nt_init(ptr, PRSTATUS, nt_prstatus);
312+
ptr = nt_init(ptr, PRFPREG, nt_fpregset);
313+
ptr = nt_init(ptr, S390_TIMER, sa->timer);
314+
ptr = nt_init(ptr, S390_TODCMP, sa->todcmp);
315+
ptr = nt_init(ptr, S390_TODPREG, sa->todpreg);
316+
ptr = nt_init(ptr, S390_CTRS, sa->ctrs);
317+
ptr = nt_init(ptr, S390_PREFIX, sa->prefix);
332318
if (cpu_has_vx()) {
333-
ptr = nt_init(ptr, NT_S390_VXRS_HIGH,
334-
&sa->vxrs_high, sizeof(sa->vxrs_high));
335-
ptr = nt_init(ptr, NT_S390_VXRS_LOW,
336-
&sa->vxrs_low, sizeof(sa->vxrs_low));
319+
ptr = nt_init(ptr, S390_VXRS_HIGH, sa->vxrs_high);
320+
ptr = nt_init(ptr, S390_VXRS_LOW, sa->vxrs_low);
337321
}
338322
return ptr;
339323
}
@@ -346,16 +330,16 @@ static size_t get_cpu_elf_notes_size(void)
346330
struct save_area *sa = NULL;
347331
size_t size;
348332

349-
size = nt_size(NT_PRSTATUS, sizeof(struct elf_prstatus));
350-
size += nt_size(NT_PRFPREG, sizeof(elf_fpregset_t));
351-
size += nt_size(NT_S390_TIMER, sizeof(sa->timer));
352-
size += nt_size(NT_S390_TODCMP, sizeof(sa->todcmp));
353-
size += nt_size(NT_S390_TODPREG, sizeof(sa->todpreg));
354-
size += nt_size(NT_S390_CTRS, sizeof(sa->ctrs));
355-
size += nt_size(NT_S390_PREFIX, sizeof(sa->prefix));
333+
size = nt_size(PRSTATUS, struct elf_prstatus);
334+
size += nt_size(PRFPREG, elf_fpregset_t);
335+
size += nt_size(S390_TIMER, sa->timer);
336+
size += nt_size(S390_TODCMP, sa->todcmp);
337+
size += nt_size(S390_TODPREG, sa->todpreg);
338+
size += nt_size(S390_CTRS, sa->ctrs);
339+
size += nt_size(S390_PREFIX, sa->prefix);
356340
if (cpu_has_vx()) {
357-
size += nt_size(NT_S390_VXRS_HIGH, sizeof(sa->vxrs_high));
358-
size += nt_size(NT_S390_VXRS_LOW, sizeof(sa->vxrs_low));
341+
size += nt_size(S390_VXRS_HIGH, sa->vxrs_high);
342+
size += nt_size(S390_VXRS_LOW, sa->vxrs_low);
359343
}
360344

361345
return size;
@@ -371,7 +355,7 @@ static void *nt_prpsinfo(void *ptr)
371355
memset(&prpsinfo, 0, sizeof(prpsinfo));
372356
prpsinfo.pr_sname = 'R';
373357
strcpy(prpsinfo.pr_fname, "vmlinux");
374-
return nt_init(ptr, NT_PRPSINFO, &prpsinfo, sizeof(prpsinfo));
358+
return nt_init(ptr, PRPSINFO, prpsinfo);
375359
}
376360

377361
/*
@@ -610,7 +594,7 @@ static size_t get_elfcorehdr_size(int phdr_count)
610594
/* PT_NOTES */
611595
size += sizeof(Elf64_Phdr);
612596
/* nt_prpsinfo */
613-
size += nt_size(NT_PRPSINFO, sizeof(struct elf_prpsinfo));
597+
size += nt_size(PRPSINFO, struct elf_prpsinfo);
614598
/* regsets */
615599
size += get_cpu_cnt() * get_cpu_elf_notes_size();
616600
/* nt_vmcoreinfo */

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: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
10241024
/* deal with each load segment separately */
10251025
phdr = params->phdrs;
10261026
for (loop = 0; loop < params->hdr.e_phnum; loop++, phdr++) {
1027-
unsigned long maddr, disp, excess, excess1;
1027+
unsigned long maddr, disp, excess;
10281028
int prot = 0, flags;
10291029

10301030
if (phdr->p_type != PT_LOAD)
@@ -1120,9 +1120,10 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
11201120
* extant in the file
11211121
*/
11221122
excess = phdr->p_memsz - phdr->p_filesz;
1123-
excess1 = PAGE_SIZE - ((maddr + phdr->p_filesz) & ~PAGE_MASK);
11241123

11251124
#ifdef CONFIG_MMU
1125+
unsigned long excess1
1126+
= PAGE_SIZE - ((maddr + phdr->p_filesz) & ~PAGE_MASK);
11261127
if (excess > excess1) {
11271128
unsigned long xaddr = maddr + phdr->p_filesz + excess1;
11281129
unsigned long xmaddr;
@@ -1397,7 +1398,7 @@ static struct elf_thread_status *elf_dump_thread_status(long signr, struct task_
13971398
regset_get(p, &view->regsets[0],
13981399
sizeof(t->prstatus.pr_reg), &t->prstatus.pr_reg);
13991400

1400-
fill_note(&t->notes[0], "CORE", NT_PRSTATUS, sizeof(t->prstatus),
1401+
fill_note(&t->notes[0], NN_PRSTATUS, NT_PRSTATUS, sizeof(t->prstatus),
14011402
&t->prstatus);
14021403
t->num_notes++;
14031404
*sz += notesize(&t->notes[0]);
@@ -1415,7 +1416,7 @@ static struct elf_thread_status *elf_dump_thread_status(long signr, struct task_
14151416
}
14161417

14171418
if (t->prstatus.pr_fpvalid) {
1418-
fill_note(&t->notes[1], "CORE", NT_PRFPREG, sizeof(t->fpu),
1419+
fill_note(&t->notes[1], NN_PRFPREG, NT_PRFPREG, sizeof(t->fpu),
14191420
&t->fpu);
14201421
t->num_notes++;
14211422
*sz += notesize(&t->notes[1]);
@@ -1530,15 +1531,15 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
15301531
*/
15311532

15321533
fill_psinfo(psinfo, current->group_leader, current->mm);
1533-
fill_note(&psinfo_note, "CORE", NT_PRPSINFO, sizeof(*psinfo), psinfo);
1534+
fill_note(&psinfo_note, NN_PRPSINFO, NT_PRPSINFO, sizeof(*psinfo), psinfo);
15341535
thread_status_size += notesize(&psinfo_note);
15351536

15361537
auxv = (elf_addr_t *) current->mm->saved_auxv;
15371538
i = 0;
15381539
do
15391540
i += 2;
15401541
while (auxv[i - 2] != AT_NULL);
1541-
fill_note(&auxv_note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
1542+
fill_note(&auxv_note, NN_AUXV, NT_AUXV, i * sizeof(elf_addr_t), auxv);
15421543
thread_status_size += notesize(&auxv_note);
15431544

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

fs/exec.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
755755
mm->arg_start = bprm->p;
756756
#endif
757757

758-
if (bprm->loader)
759-
bprm->loader -= stack_shift;
760758
bprm->exec -= stack_shift;
761759

762760
if (mmap_write_lock_killable(mm))

fs/proc/kcore.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
#include <asm/sections.h>
3535
#include "internal.h"
3636

37-
#define CORE_STR "CORE"
38-
3937
#ifndef ELF_CORE_EFLAGS
4038
#define ELF_CORE_EFLAGS 0
4139
#endif
@@ -122,7 +120,9 @@ static void update_kcore_size(void)
122120

123121
kcore_phdrs_len = kcore_nphdr * sizeof(struct elf_phdr);
124122
kcore_notes_len = (4 * sizeof(struct elf_note) +
125-
3 * ALIGN(sizeof(CORE_STR), 4) +
123+
ALIGN(sizeof(NN_PRSTATUS), 4) +
124+
ALIGN(sizeof(NN_PRPSINFO), 4) +
125+
ALIGN(sizeof(NN_TASKSTRUCT), 4) +
126126
VMCOREINFO_NOTE_NAME_BYTES +
127127
ALIGN(sizeof(struct elf_prstatus), 4) +
128128
ALIGN(sizeof(struct elf_prpsinfo), 4) +
@@ -443,11 +443,11 @@ static ssize_t read_kcore_iter(struct kiocb *iocb, struct iov_iter *iter)
443443
goto out;
444444
}
445445

446-
append_kcore_note(notes, &i, CORE_STR, NT_PRSTATUS, &prstatus,
446+
append_kcore_note(notes, &i, NN_PRSTATUS, NT_PRSTATUS, &prstatus,
447447
sizeof(prstatus));
448-
append_kcore_note(notes, &i, CORE_STR, NT_PRPSINFO, &prpsinfo,
448+
append_kcore_note(notes, &i, NN_PRPSINFO, NT_PRPSINFO, &prpsinfo,
449449
sizeof(prpsinfo));
450-
append_kcore_note(notes, &i, CORE_STR, NT_TASKSTRUCT, current,
450+
append_kcore_note(notes, &i, NN_TASKSTRUCT, NT_TASKSTRUCT, current,
451451
arch_task_struct_size);
452452
/*
453453
* vmcoreinfo_size is mostly constant after init time, but it

include/linux/binfmts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct linux_binprm {
6464
const char *fdpath; /* generated filename for execveat */
6565
unsigned interp_flags;
6666
int execfd; /* File descriptor of the executable */
67-
unsigned long loader, exec;
67+
unsigned long exec;
6868

6969
struct rlimit rlim_stack; /* Saved RLIMIT_STACK used during exec. */
7070

include/linux/kexec.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ extern note_buf_t __percpu *crash_notes;
6868
#define KEXEC_CRASH_MEM_ALIGN PAGE_SIZE
6969
#endif
7070

71-
#define KEXEC_CORE_NOTE_NAME CRASH_CORE_NOTE_NAME
72-
7371
/*
7472
* This structure is used to hold the arguments that are used when loading
7573
* kernel binaries.

include/linux/vmcore_info.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
#include <linux/elfcore.h>
77
#include <linux/elf.h>
88

9-
#define CRASH_CORE_NOTE_NAME "CORE"
109
#define CRASH_CORE_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
11-
#define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(CRASH_CORE_NOTE_NAME), 4)
10+
#define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(NN_PRSTATUS), 4)
1211
#define CRASH_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
1312

1413
/*

0 commit comments

Comments
 (0)