From: kettenis Date: Sun, 21 Jan 2024 17:18:13 +0000 (+0000) Subject: Static non-PIE binaries always have a base address of 0 (even if the ELF X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=51689999131972de3737a6cebfc77b68f9a299e7;p=openbsd Static non-PIE binaries always have a base address of 0 (even if the ELF headers start at a higher address). Using the wrong base address meant that we were protecting the wrong address range for the malloc internals which made the code error out now that mimmutable(2) no longer allows an RW->R transition. Issue found by gkoehler@ who got most of the way towards a proper fix. ok deraadt@ --- diff --git a/lib/libc/dlfcn/init.c b/lib/libc/dlfcn/init.c index dd38ba9ddfb..9fc63c97f98 100644 --- a/lib/libc/dlfcn/init.c +++ b/lib/libc/dlfcn/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.21 2024/01/19 14:15:51 deraadt Exp $ */ +/* $OpenBSD: init.c,v 1.22 2024/01/21 17:18:13 kettenis Exp $ */ /* * Copyright (c) 2014,2015 Philip Guenther * @@ -129,7 +129,6 @@ _libc_preinit(int argc, char **argv, char **envp, dl_cb_cb *cb) * Static non-PIE processes don't get an AUX vector, * so find the phdrs through the ELF header */ - _static_phdr_info.dlpi_addr = (Elf_Addr)__executable_start; phdr = (void *)((char *)__executable_start + __executable_start->e_phoff); phnum = __executable_start->e_phnum;