[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ef904b3b-e9b2-4fb4-bce6-72eb4f2018e2@p183>
Date: Fri, 21 Jun 2024 21:32:25 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, Jiri Olsa <jolsa@...nel.org>
Subject: Re: [PATCH] build-id: require program headers to be right after ELF
header
On Fri, Jun 21, 2024 at 10:07:52AM -0700, Andrew Morton wrote:
> On Fri, 21 Jun 2024 18:05:50 +0300 Alexey Dobriyan <adobriyan@...il.com> wrote:
>
> > ELF spec doesn't require program header to be placed right after
> > ELF header, but build-id code very much assumes such placement:
> >
> > find_get_page(vma->vm_file->f_mapping, 0);
> >
> > and later check against PAGE_SIZE.
> >
> > Returns errors for now until someone rewrites build-id parser
> > to be more correct.
> >
> > ...
> >
> > --- a/lib/buildid.c
> > +++ b/lib/buildid.c
> > @@ -73,6 +73,9 @@ static int get_build_id_32(const void *page_addr, unsigned char *build_id,
> > Elf32_Phdr *phdr;
> > int i;
> >
> > + 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 +101,9 @@ static int get_build_id_64(const void *page_addr, unsigned char *build_id,
> > Elf64_Phdr *phdr;
> > int i;
> >
> > + 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))
>
> Well can we get comments in here eplaining the shortcoming? That way
> we're more likely to get a volunteer.
Sure.
> And please drop the braces?
Bracers are good. It took hundred years to drop -Wdeclaration-after-statement,
I hope to see mandatory bracers by 2050.
Powered by blists - more mailing lists