summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2024-01-19 14:15:52 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2024-01-19 14:15:52 +0000
commit72d73adbe093fc640541c4ccb558a4558bfcc9d0 (patch)
tree5c69c5ae22d67dbdfcff0ef5e5df6708f4f6c66c /lib
parentd9dbacd31c5f7595a51c50a7ccef91294d43ea55 (diff)
Stop initializing pinsyscall(SYS_execve in static binaries that contain
an execve(2) stub. The new pinsyscalls(2) that applies to all system calls has made this redundant.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/dlfcn/init.c21
-rw-r--r--lib/libc/sys/Makefile.inc23
2 files changed, 5 insertions, 39 deletions
diff --git a/lib/libc/dlfcn/init.c b/lib/libc/dlfcn/init.c
index c15eda483ac..dd38ba9ddfb 100644
--- a/lib/libc/dlfcn/init.c
+++ b/lib/libc/dlfcn/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.20 2024/01/18 19:00:11 deraadt Exp $ */
+/* $OpenBSD: init.c,v 1.21 2024/01/19 14:15:51 deraadt Exp $ */
/*
* Copyright (c) 2014,2015 Philip Guenther <guenther@openbsd.org>
*
@@ -71,9 +71,6 @@ extern Elf_Ehdr __executable_start[] __attribute__((weak));
/* provide definitions for these */
const dl_cb *_dl_cb __relro = NULL;
-int pinsyscall(int, void *, size_t);
-PROTO_NORMAL(pinsyscall);
-
int HIDDEN(execve)(const char *, char *const *, char *const *)
__attribute__((weak));
@@ -141,23 +138,9 @@ _libc_preinit(int argc, char **argv, char **envp, dl_cb_cb *cb)
_static_phdr_info.dlpi_phnum = phnum;
/* static libc in a static link? */
- if (cb == NULL) {
+ if (cb == NULL)
setup_static_tib(phdr, phnum);
-#if !defined(__hppa__)
- if (&HIDDEN(execve)) {
- extern const int _execve_size;
-
- pinsyscall(SYS_execve, &HIDDEN(execve), _execve_size);
- } else {
- static const int not_syscall;
-
- /* Static binary which does not use execve() */
- pinsyscall(SYS_execve, (void *)&not_syscall, 1);
- }
-#endif
- }
-
/*
* If a static binary has text relocations (DT_TEXT), then un-writeable
* segments were not made immutable by the kernel. Textrel and RELRO
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index 45c37543536..e833a28924c 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.176 2023/12/12 15:30:55 deraadt Exp $
+# $OpenBSD: Makefile.inc,v 1.177 2024/01/19 14:15:51 deraadt Exp $
# $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $
# @(#)Makefile.inc 8.1 (Berkeley) 6/17/93
@@ -23,23 +23,6 @@ SRCS+= ptrace.c semctl.c \
# stack protector helper functions
SRCS+= stack_protector.c
-# Extract execve stub size for static binary pinsyscall(2) in dlfcn/init.c
-SRCS+= _execvesize.c
-CLEANFILES+=_execvesize.c
-_execvesize.c: execve.o execve.po
- readelf -s execve.po | awk \
- '/ execve$$/{ printf("#ifdef _PROFILE\nconst int _execve_size = %d;\n", $$3); }' > $@
- readelf -s execve.o | awk \
- '/ execve$$/{ printf("#else\nconst int _execve_size = %d;\n#endif\n", $$3); }' >> $@
-
-# _libc_preinit() needs to know if compiled with or without profiling
-_execvesize.po:
- @echo "${COMPILE.c} -D_PROFILE ${.IMPSRC} -o ${.TARGET}"
- @${COMPILE.c} ${DFLAGS} -D_PROFILE ${.IMPSRC} -o ${.TARGET}.o
- @-mv $@.d $*.d
- @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
- @rm -f ${.TARGET}.o
-
# cancelation details
SRCS+= canceled.c
@@ -79,7 +62,7 @@ ASM= __semctl.o __thrsigdivert.o \
mknod.o mknodat.o mlock.o mlockall.o mmap.o mount.o mprotect.o \
mquery.o msgctl.o msgget.o munlock.o munlockall.o munmap.o \
nfssvc.o \
- pathconf.o pipe.o pipe2.o pinsyscall.o pledge.o profil.o \
+ pathconf.o pipe.o pipe2.o pledge.o profil.o \
quotactl.o \
readlink.o readlinkat.o reboot.o \
rename.o renameat.o revoke.o rmdir.o \
@@ -208,7 +191,7 @@ MAN+= __get_tcb.2 __thrsigdivert.2 __thrsleep.2 _exit.2 accept.2 \
mimmutable.2 minherit.2 mkdir.2 mkfifo.2 mknod.2 mlock.2 \
mlockall.2 mmap.2 mount.2 mprotect.2 mquery.2 msyscall.2 msgctl.2 \
msgget.2 msgrcv.2 msgsnd.2 msync.2 munmap.2 nanosleep.2 \
- nfssvc.2 open.2 pathconf.2 pinsyscall.2 pinsyscalls.2 pipe.2 pledge.2 \
+ nfssvc.2 open.2 pathconf.2 pinsyscalls.2 pipe.2 pledge.2 \
poll.2 profil.2 ptrace.2 quotactl.2 read.2 readlink.2 reboot.2 recv.2 \
rename.2 revoke.2 rmdir.2 sched_yield.2 select.2 semctl.2 semget.2 \
semop.2 send.2 setgroups.2 setpgid.2 setregid.2 \