|
Message-ID: <a6cb2e48-e285-07f1-cff9-b337a56e7966@linaro.org> Date: Thu, 10 Dec 2020 15:49:37 -0300 From: Adhemerval Zanella <adhemerval.zanella@...aro.org> To: Szabolcs Nagy <szabolcs.nagy@....com>, libc-alpha@...rceware.org Cc: Mark Rutland <mark.rutland@....com>, kernel-hardening@...ts.openwall.com, Catalin Marinas <catalin.marinas@....com>, linux-kernel@...r.kernel.org, Jeremy Linton <jeremy.linton@....com>, Mark Brown <broonie@...nel.org>, Topi Miettinen <toiwoton@...il.com>, Will Deacon <will@...nel.org>, linux-arm-kernel@...ts.infradead.org Subject: Re: [PATCH v3 1/2] aarch64: align address for BTI protection [BZ #26988] On 02/12/2020 05:55, Szabolcs Nagy via Libc-alpha wrote: > Handle unaligned executable load segments (the bfd linker is not > expected to produce such binaries, but other linkers may). > > Computing the mapping bounds follows _dl_map_object_from_fd more > closely now. > > Fixes bug 26988. LGTM, thanks. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@...aro.org> > --- > v3: > - split the last patch in two so this bug is fixed separately. > - pushed to nsz/btifix-v3 branch. > > sysdeps/aarch64/dl-bti.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/sysdeps/aarch64/dl-bti.c b/sysdeps/aarch64/dl-bti.c > index 8f4728adce..67d63c8a73 100644 > --- a/sysdeps/aarch64/dl-bti.c > +++ b/sysdeps/aarch64/dl-bti.c > @@ -20,19 +20,22 @@ > #include <libintl.h> > #include <ldsodefs.h> > > -static int > +static void > enable_bti (struct link_map *map, const char *program) > { Ok. > + const size_t pagesz = GLRO(dl_pagesize); > const ElfW(Phdr) *phdr; > - unsigned prot; > > for (phdr = map->l_phdr; phdr < &map->l_phdr[map->l_phnum]; ++phdr) > if (phdr->p_type == PT_LOAD && (phdr->p_flags & PF_X)) > { > - void *start = (void *) (phdr->p_vaddr + map->l_addr); > - size_t len = phdr->p_memsz; > + size_t vstart = ALIGN_DOWN (phdr->p_vaddr, pagesz); > + size_t vend = ALIGN_UP (phdr->p_vaddr + phdr->p_filesz, pagesz); > + off_t off = ALIGN_DOWN (phdr->p_offset, pagesz); > + void *start = (void *) (vstart + map->l_addr); > + size_t len = vend - vstart; > > - prot = PROT_EXEC | PROT_BTI; > + unsigned prot = PROT_EXEC | PROT_BTI; > if (phdr->p_flags & PF_R) > prot |= PROT_READ; > if (phdr->p_flags & PF_W) > @@ -48,7 +51,6 @@ enable_bti (struct link_map *map, const char *program) > N_("mprotect failed to turn on BTI")); > } > } > - return 0; > } > > /* Enable BTI for MAP and its dependencies. */ > Ok.
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.