Patch "build-id: require program headers to be right after ELF header" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    build-id: require program headers to be right after ELF header

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     build-id-require-program-headers-to-be-right-after-e.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit addfa88a98a87ad451163f800f13124712f02b0c
Author: Alexey Dobriyan <adobriyan@xxxxxxxxx>
Date:   Fri Jun 21 21:39:33 2024 +0300

    build-id: require program headers to be right after ELF header
    
    [ Upstream commit 961a2851324561caed579764ffbee3db82b32829 ]
    
    Neither ELF spec not ELF loader require program header to be placed right
    after ELF header, but build-id code very much assumes such placement:
    
    See
    
            find_get_page(vma->vm_file->f_mapping, 0);
    
    line and checks against PAGE_SIZE.
    
    Returns errors for now until someone rewrites build-id parser
    to be more inline with load_elf_binary().
    
    Link: https://lkml.kernel.org/r/d58bc281-6ca7-467a-9a64-40fa214bd63e@p183
    Signed-off-by: Alexey Dobriyan <adobriyan@xxxxxxxxx>
    Reviewed-by: Jiri Olsa <jolsa@xxxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Stable-dep-of: 905415ff3ffb ("lib/buildid: harden build ID parsing logic")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/lib/buildid.c b/lib/buildid.c
index dfc62625cae4e..493537344fc81 100644
--- a/lib/buildid.c
+++ b/lib/buildid.c
@@ -73,6 +73,13 @@ static int get_build_id_32(const void *page_addr, unsigned char *build_id,
 	Elf32_Phdr *phdr;
 	int i;
 
+	/*
+	 * FIXME
+	 * Neither ELF spec nor ELF loader require that program headers
+	 * start immediately after ELF header.
+	 */
+	if (ehdr->e_phoff != sizeof(Elf32_Ehdr))
+		return -EINVAL;
 	/* only supports phdr that fits in one page */
 	if (ehdr->e_phnum >
 	    (PAGE_SIZE - sizeof(Elf32_Ehdr)) / sizeof(Elf32_Phdr))
@@ -98,6 +105,13 @@ static int get_build_id_64(const void *page_addr, unsigned char *build_id,
 	Elf64_Phdr *phdr;
 	int i;
 
+	/*
+	 * FIXME
+	 * Neither ELF spec nor ELF loader require that program headers
+	 * start immediately after ELF header.
+	 */
+	if (ehdr->e_phoff != sizeof(Elf64_Ehdr))
+		return -EINVAL;
 	/* only supports phdr that fits in one page */
 	if (ehdr->e_phnum >
 	    (PAGE_SIZE - sizeof(Elf64_Ehdr)) / sizeof(Elf64_Phdr))




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux