diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2023-02-21 14:41:52 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2023-02-21 14:41:52 +0000 |
commit | 96c03ad60ca7f1b12a313708d3cbad85dcb98d25 (patch) | |
tree | 542f6fed5dd42e2aaa66cd36597584b7af7566a7 /lib/libc | |
parent | 3dda07799de88de2ac1c1df9a6052b8a34b05d0e (diff) |
In static binaries, if WEAK execve can be found, use pinsyscall(2) to
tell the kernel where the execve stub is found. With this mechanism
we cannot tell the size, so use 128 as an estimate for the most we expect
from any architecture.
discussed with kettenis, ok guenther
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/dlfcn/init.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/libc/dlfcn/init.c b/lib/libc/dlfcn/init.c index 48c062cef55..a2d8e792160 100644 --- a/lib/libc/dlfcn/init.c +++ b/lib/libc/dlfcn/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.12 2023/01/16 07:09:12 guenther Exp $ */ +/* $OpenBSD: init.c,v 1.13 2023/02/21 14:41:51 deraadt Exp $ */ /* * Copyright (c) 2014,2015 Philip Guenther <guenther@openbsd.org> * @@ -203,6 +203,12 @@ _csu_finish(char **argv, char **envp, void (*cleanup)(void)) return &environ; } +int pinsyscall(int, void *, size_t); +PROTO_NORMAL(pinsyscall); + +int HIDDEN(execve)(const char *, char *const *, char *const *) + __attribute__((weak)); + #ifndef PIC /* * static libc in a static link? Then set up __progname and environ @@ -212,6 +218,10 @@ early_static_init(char **argv, char **envp) { static char progname_storage[NAME_MAX+1]; + /* XXX 128 maximum size of a system call stub, hopefully */ + if (&HIDDEN(execve)) + pinsyscall(SYS_execve, &HIDDEN(execve), 128); + environ = envp; /* set up __progname */ |