From f7413c6a41ec258d5b922a501ffe84b626e09079 Mon Sep 17 00:00:00 2001 From: deraadt Date: Fri, 5 Apr 2024 13:51:47 +0000 Subject: [PATCH] ld.so should stop calling msyscall(2), since it is fully neutered and about to be removed. Please be careful building through this, you need a kernel at least March 29th or so to build through it, otherwise use snapshots to cross over. ok various people --- libexec/ld.so/Makefile | 4 ++-- libexec/ld.so/library.c | 21 +++++---------------- libexec/ld.so/library_mquery.c | 21 +++++---------------- libexec/ld.so/syscall.h | 3 +-- 4 files changed, 13 insertions(+), 36 deletions(-) diff --git a/libexec/ld.so/Makefile b/libexec/ld.so/Makefile index 44ab6b41f03..7f8f6ef2961 100644 --- a/libexec/ld.so/Makefile +++ b/libexec/ld.so/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.87 2024/01/19 14:16:41 deraadt Exp $ +# $OpenBSD: Makefile,v 1.88 2024/04/05 13:51:47 deraadt Exp $ SUBDIR=ldconfig ldd MAN= ld.so.1 @@ -28,7 +28,7 @@ SRCS+= dl_uname.c dl_dirname.c strlcat.c strlen.c trace.c SRCS+= malloc.c reallocarray.c tib.c ffs.c syscall=close exit fstat getdents getentropy getthrid issetugid kbind \ - mimmutable mmap mprotect munmap msyscall open pledge \ + mimmutable mmap mprotect munmap open pledge \ pinsyscalls read __realpath sendsyslog __set_tcb sysctl thrkill \ utrace write diff --git a/libexec/ld.so/library.c b/libexec/ld.so/library.c index 8cc305ce24b..405fc979760 100644 --- a/libexec/ld.so/library.c +++ b/libexec/ld.so/library.c @@ -1,4 +1,4 @@ -/* $OpenBSD: library.c,v 1.95 2024/01/17 13:00:05 deraadt Exp $ */ +/* $OpenBSD: library.c,v 1.96 2024/04/05 13:51:47 deraadt Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -324,21 +324,10 @@ _dl_tryload_shlib(const char *libname, int type, int flags, int nodelete) } libc = _dl_islibc(dynp, loff); - if (libc) { - if (syscall_phdp) - _dl_pin(libfile, syscall_phdp, (void *)libaddr, - (size_t)((exec_start + exec_size) - libaddr), - exec_start, exec_size); - - /* - * XXX msyscall() can be removed once pinsyscalls() - * is fully operational - */ - /* Request permission for system calls in libc.so's text segment */ - if (_dl_msyscall(exec_start, exec_size) == -1) - _dl_printf("msyscall %lx %lx error\n", - exec_start, exec_size); - } + if (libc && syscall_phdp) + _dl_pin(libfile, syscall_phdp, (void *)libaddr, + (size_t)((exec_start + exec_size) - libaddr), + exec_start, exec_size); _dl_close(libfile); dynp = (Elf_Dyn *)((unsigned long)dynp + loff); diff --git a/libexec/ld.so/library_mquery.c b/libexec/ld.so/library_mquery.c index 1129ecdc66d..971d9751ffa 100644 --- a/libexec/ld.so/library_mquery.c +++ b/libexec/ld.so/library_mquery.c @@ -1,4 +1,4 @@ -/* $OpenBSD: library_mquery.c,v 1.75 2024/01/17 13:00:05 deraadt Exp $ */ +/* $OpenBSD: library_mquery.c,v 1.76 2024/04/05 13:51:47 deraadt Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -332,21 +332,10 @@ retry: } libc = _dl_islibc(dynp, LOFF); - if (libc) { - if (syscall_phdp) - _dl_pin(libfile, syscall_phdp, lowld->start, - (size_t)((exec_start + exec_size) - LOFF), - exec_start, exec_size); - - /* - * XXX msyscall() can be removed once pinsyscalls() - * is fully operational - */ - /* Request permission for system calls in libc.so's text segment */ - if (_dl_msyscall(exec_start, exec_size) == -1) - _dl_printf("msyscall %lx %lx error\n", - exec_start, exec_size); - } + if (libc && syscall_phdp) + _dl_pin(libfile, syscall_phdp, lowld->start, + (size_t)((exec_start + exec_size) - LOFF), + exec_start, exec_size); _dl_close(libfile); dynp = (Elf_Dyn *)((unsigned long)dynp + LOFF); diff --git a/libexec/ld.so/syscall.h b/libexec/ld.so/syscall.h index 59a8789151c..de08b237a56 100644 --- a/libexec/ld.so/syscall.h +++ b/libexec/ld.so/syscall.h @@ -1,4 +1,4 @@ -/* $OpenBSD: syscall.h,v 1.7 2024/01/19 14:16:42 deraadt Exp $ */ +/* $OpenBSD: syscall.h,v 1.8 2024/04/05 13:51:47 deraadt Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -50,7 +50,6 @@ int _dl_kbind(const struct __kbind *, size_t, int64_t); void *_dl_mmap(void *, size_t, int, int, int, off_t); int _dl_mprotect(const void *, size_t, int); void *_dl_mquery(void *, size_t, int, int, int, off_t); -int _dl_msyscall(void *addr, size_t len); int _dl_pinsyscalls(void *base, size_t len, u_int *pin, int pinlen); int _dl_munmap(const void *, size_t); int _dl_mimmutable(const void *, size_t); -- 2.20.1