Skip to content

Commit d416a46

Browse files
committed
Merge tag 'execve-v6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull execve updates from Kees Cook: - Fix a few comments for correctness and typos (Baruch Siach) - Small simplifications for binfmt (Christophe JAILLET) - Set p_align to 4 for PT_NOTE in core dump (Fangrui Song) * tag 'execve-v6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: binfmt_elf: fix comment typo s/reset/regset/ elf: correct note name comment binfmt: Slightly simplify elf_fdpic_map_file() binfmt: Use struct_size() coredump, vmcore: Set p_align to 4 for PT_NOTE
2 parents 98be618 + aa88054 commit d416a46

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

fs/binfmt_elf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,7 +1517,7 @@ static void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, loff_t offset)
15171517
phdr->p_filesz = sz;
15181518
phdr->p_memsz = 0;
15191519
phdr->p_flags = 0;
1520-
phdr->p_align = 0;
1520+
phdr->p_align = 4;
15211521
}
15221522

15231523
static void fill_note(struct memelfnote *note, const char *name, int type,
@@ -1773,7 +1773,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
17731773
/*
17741774
* NT_PRSTATUS is the one special case, because the regset data
17751775
* goes into the pr_reg field inside the note contents, rather
1776-
* than being the whole note contents. We fill the reset in here.
1776+
* than being the whole note contents. We fill the regset in here.
17771777
* We assume that regset 0 is NT_PRSTATUS.
17781778
*/
17791779
fill_prstatus(&t->prstatus.common, t->task, signr);

fs/binfmt_elf_fdpic.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -743,12 +743,12 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
743743
struct elf32_fdpic_loadmap *loadmap;
744744
#ifdef CONFIG_MMU
745745
struct elf32_fdpic_loadseg *mseg;
746+
unsigned long load_addr;
746747
#endif
747748
struct elf32_fdpic_loadseg *seg;
748749
struct elf32_phdr *phdr;
749-
unsigned long load_addr, stop;
750750
unsigned nloads, tmp;
751-
size_t size;
751+
unsigned long stop;
752752
int loop, ret;
753753

754754
/* allocate a load map table */
@@ -760,8 +760,7 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
760760
if (nloads == 0)
761761
return -ELIBBAD;
762762

763-
size = sizeof(*loadmap) + nloads * sizeof(*seg);
764-
loadmap = kzalloc(size, GFP_KERNEL);
763+
loadmap = kzalloc(struct_size(loadmap, segs, nloads), GFP_KERNEL);
765764
if (!loadmap)
766765
return -ENOMEM;
767766

@@ -770,9 +769,6 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
770769
loadmap->version = ELF32_FDPIC_LOADMAP_VERSION;
771770
loadmap->nsegs = nloads;
772771

773-
load_addr = params->load_addr;
774-
seg = loadmap->segs;
775-
776772
/* map the requested LOADs into the memory space */
777773
switch (params->flags & ELF_FDPIC_FLAG_ARRANGEMENT) {
778774
case ELF_FDPIC_FLAG_CONSTDISP:
@@ -1269,7 +1265,7 @@ static inline void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, loff_t offs
12691265
phdr->p_filesz = sz;
12701266
phdr->p_memsz = 0;
12711267
phdr->p_flags = 0;
1272-
phdr->p_align = 0;
1268+
phdr->p_align = 4;
12731269
return;
12741270
}
12751271

fs/proc/vmcore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ static int __init merge_note_headers_elf64(char *elfptr, size_t *elfsz,
877877
phdr.p_offset = roundup(note_off, PAGE_SIZE);
878878
phdr.p_vaddr = phdr.p_paddr = 0;
879879
phdr.p_filesz = phdr.p_memsz = phdr_sz;
880-
phdr.p_align = 0;
880+
phdr.p_align = 4;
881881

882882
/* Add merged PT_NOTE program header*/
883883
tmp = elfptr + sizeof(Elf64_Ehdr);
@@ -1068,7 +1068,7 @@ static int __init merge_note_headers_elf32(char *elfptr, size_t *elfsz,
10681068
phdr.p_offset = roundup(note_off, PAGE_SIZE);
10691069
phdr.p_vaddr = phdr.p_paddr = 0;
10701070
phdr.p_filesz = phdr.p_memsz = phdr_sz;
1071-
phdr.p_align = 0;
1071+
phdr.p_align = 4;
10721072

10731073
/* Add merged PT_NOTE program header*/
10741074
tmp = elfptr + sizeof(Elf32_Ehdr);

include/uapi/linux/elf.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ typedef struct elf64_shdr {
372372
* Notes used in ET_CORE. Architectures export some of the arch register sets
373373
* using the corresponding note types via the PTRACE_GETREGSET and
374374
* PTRACE_SETREGSET requests.
375-
* The note name for all these is "LINUX".
375+
* The note name for these types is "LINUX", except NT_PRFPREG that is named
376+
* "CORE".
376377
*/
377378
#define NT_PRSTATUS 1
378379
#define NT_PRFPREG 2

0 commit comments

Comments
 (0)