lkml.org 
[lkml]   [2021]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: [PATCH] arm64/vdso: Discard .note.gnu.property sections in vDSO
On Thu, Apr 29, 2021 at 2:50 AM Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> The 04/29/2021 02:23, Bill Wendling wrote:
> > On Thu, Apr 29, 2021 at 12:55 AM Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> > > The 04/28/2021 12:31, Bill Wendling wrote:
> > > > On Wed, Apr 28, 2021 at 12:21 PM Bill Wendling <morbo@google.com> wrote:
> > > > > On Wed, Apr 28, 2021 at 10:40 AM Mark Brown <broonie@kernel.org> wrote:
> > > > > > On Wed, Apr 28, 2021 at 06:28:47PM +0100, Catalin Marinas wrote:
> > > > > > > On Fri, Apr 23, 2021 at 01:51:59PM -0700, Bill Wendling wrote:
> > > > > >
> > > > > > > > Since the note.gnu.property section in the vDSO is not checked by the
> > > > > > > > dynamic linker, discard the .note.gnu.property sections in the vDSO.
> > > > > >
> > > > > > > Can we not instead fix the linker script to preserve the
> > > > > > > .note.gnu.property, correctly aligned? It doesn't take much space and
> > > > > > > while we don't use it now, it has the BTI information about the binary.
> > > > > >
> > > > > > > Cc'ing a few others who were involved in the BTI support.
> > > > > >
> > > > > > Not just BTI, we also flag PAC usage in there too and could add other
> > > > > > extensions going forwards. While the note isn't actively used by
> > > > > > anything right now due to the kernel mapping the vDSO prior to userspace
> > > > > > starting it is part of the ABI and something could end up wanting to use
> > > > > > it and getting confused if it's not there. It would be much better to
> > > > > > fix the alignment issue.
> > > > >
> > > > > If there's only one of the 8-byte aligned sections guaranteed, we
> > > > > could place it first in the note. Otherwise, we will have to change
> > > > > the alignment of the note (or somehow merge multiple notes).
> > > > >
> > > > I should have clarified that there's only one *entry* in the
> > > > .note.gnu.properties section, and if not then is it possible to merge
> > > > multiple entries into one. (Excuse my ignorance if this is already the
> > > > case.)
> > >
> > > .note.gnu.property should go to PT_GNU_PROPERTY and it
> > > should be merged following rules specified in
> > > https://github.com/hjl-tools/linux-abi/wiki/Linux-Extensions-to-gABI
> > > and
> > > https://github.com/ARM-software/abi-aa/blob/master/aaelf64/aaelf64.rst#program-property
> > >
> > > it may also be covered by a (8byte aligned) PT_NOTE, but
> > > that's not a requirement on aarch64 (x86 requires it for
> > > compatibility with old dynamic linker, but since the vdso
> > > is handled specially that may not be relevant either).
> > >
> > > i don't know how this works in linker scripts.
> >
> > This is a potential patch. I haven't had time to test it though.
> > However, it does appear to format the section in the "expected" way,
> > so one's able to grab the build IDs. Thoughts?
>
>
> please show the program headers.
>

$ readelf -lW arch/arm64/kernel/vdso/vdso.so

Elf file type is DYN (Shared object file)
Entry point 0x300
There are 4 program headers, starting at offset 64

Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flg Align
LOAD 0x000000 0x0000000000000000 0x0000000000000000
0x000968 0x000968 R E 0x8
DYNAMIC 0x0008a8 0x00000000000008a8 0x00000000000008a8
0x0000c0 0x0000c0 R 0x8
NOTE 0x000288 0x0000000000000288 0x0000000000000288
0x000074 0x000074 R 0x8
GNU_EH_FRAME 0x0008a4 0x00000000000008a4 0x00000000000008a4
0x000000 0x000000 R E 0x1

Section to Segment mapping:
Segment Sections...
00 .hash .dynsym .dynstr .gnu.version .gnu.version_d .note
.text .eh_frame_hdr .eh_frame .dynamic
01 .dynamic
02 .note
03 .eh_frame_hdr .eh_frame

> >
> > $ objdump -s -j .note ./arch/arm64/kernel/vdso/vdso.so
> >
> > ./arch/arm64/kernel/vdso/vdso.so: file format elf64-little
> >
> > Contents of section .note:
> > 0288 04000000 10000000 05000000 474e5500 ............GNU.
> > 0298 000000c0 04000000 03000000 00000000 ................
> > 02a8 06000000 04000000 00000000 4c696e75 ............Linu
> > 02b8 78000000 000a0500 06000000 01000000 x...............
> > 02c8 00010000 4c696e75 78000000 00000000 ....Linux.......
> > 02d8 04000000 14000000 03000000 474e5500 ............GNU.
> > 02e8 958db149 af5156cb 45309896 7a53ae8a ...I.QV.E0..zS..
> > 02f8 ef34e95c .4.\
> >
> > diff --git a/arch/arm64/kernel/vdso/vdso.lds.S
> > b/arch/arm64/kernel/vdso/vdso.lds.S
> > index d808ad31e01f..d51e886c6223 100644
> > --- a/arch/arm64/kernel/vdso/vdso.lds.S
> > +++ b/arch/arm64/kernel/vdso/vdso.lds.S
> > @@ -31,7 +31,13 @@ SECTIONS
> > .gnu.version_d : { *(.gnu.version_d) }
> > .gnu.version_r : { *(.gnu.version_r) }
> >
> > - .note : { *(.note.*) } :text :note
> > + /*
> > + * Add the .note.gnu.property section first, as it's aligned to
> > + * 8-bytes, while other notes are aligned to 4-bytes.
> > + */
> > + . = ALIGN(8);
> > +
> > + .note : { *(.note.gnu.property) *(.note.*) } :text :note
> >
> > . = ALIGN(16);
>
> --

\
 
 \ /
  Last update: 2021-04-29 20:52    [W:0.065 / U:0.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site