From 1d60349d0b961891264d426ffe1c0ced24b2374c Mon Sep 17 00:00:00 2001 From: guenther Date: Thu, 23 Dec 2021 18:50:31 +0000 Subject: [PATCH] Roll the syscalls that have an off_t argument to remove the explicit padding. Switch libc and ld.so to the generic stubs for these calls. WARNING: reboot to updated kernel before installing libc or ld.so! Time for a story... When gcc (back in 1.x days) first implemented long long, it didn't (always) pass 64bit arguments in 'aligned' registers/stack slots, with the result that argument offsets didn't match structure offsets. This affected the nine system calls that pass off_t arguments: ftruncate lseek mmap mquery pread preadv pwrite pwritev truncate To avoid having to do custom ASM wrappers for those, BSD put an explicit pad argument in so that the off_t argument would always start on a even slot and thus be naturally aligned. Thus those odd wrappers in lib/libc/sys/ that use __syscall() and pass an extra '0' argument. The ABIs for different CPUs eventually settled how things should be passed on each and gcc 2.x followed them. The only arch now where it helps is landisk, which needs to skip the last argument register if it would be the first half of a 64bit argument. So: add new syscalls without the pad argument and on landisk do that skipping directly in the syscall handler in the kernel. Keep compat support for the existing syscalls long enough for the transition. ok deraadt@ --- lib/libc/sys/Makefile.inc | 24 +++---- lib/libc/sys/ftruncate.c | 48 -------------- lib/libc/sys/lseek.c | 48 -------------- lib/libc/sys/mmap.c | 49 --------------- lib/libc/sys/mquery.c | 23 ------- lib/libc/sys/pread.c | 50 --------------- lib/libc/sys/preadv.c | 50 --------------- lib/libc/sys/pwrite.c | 49 --------------- lib/libc/sys/pwritev.c | 51 --------------- lib/libc/sys/truncate.c | 49 --------------- libexec/ld.so/Makefile | 19 +++--- libexec/ld.so/aarch64/syscall.h | 70 --------------------- libexec/ld.so/alpha/syscall.h | 70 --------------------- libexec/ld.so/amd64/syscall.h | 70 --------------------- libexec/ld.so/hppa/syscall.h | 70 --------------------- libexec/ld.so/i386/syscall.h | 77 ----------------------- libexec/ld.so/loader.c | 4 +- libexec/ld.so/m88k/rtld_machine.c | 3 +- libexec/ld.so/m88k/syscall.h | 72 --------------------- libexec/ld.so/mips64/syscall.h | 70 --------------------- libexec/ld.so/powerpc/syscall.h | 70 --------------------- libexec/ld.so/powerpc64/syscall.h | 70 --------------------- libexec/ld.so/riscv64/syscall.h | 70 --------------------- libexec/ld.so/sh/syscall.h | 70 --------------------- libexec/ld.so/sparc64/syscall.h | 70 --------------------- libexec/ld.so/{arm => }/syscall.h | 27 ++++---- sys/arch/hppa/hppa/trap.c | 13 +++- sys/arch/sh/sh/trap.c | 80 ++++++++++++----------- sys/kern/kern_ktrace.c | 6 +- sys/kern/kern_pledge.c | 14 ++++- sys/kern/syscalls.master | 49 +++++++++------ sys/kern/vfs_syscalls.c | 101 +++++++++++++++++++++++++++--- sys/uvm/uvm_mmap.c | 38 ++++++++++- usr.bin/kdump/kdump.c | 67 ++++++++++++++++---- 34 files changed, 319 insertions(+), 1392 deletions(-) delete mode 100644 lib/libc/sys/ftruncate.c delete mode 100644 lib/libc/sys/lseek.c delete mode 100644 lib/libc/sys/mmap.c delete mode 100644 lib/libc/sys/mquery.c delete mode 100644 lib/libc/sys/pread.c delete mode 100644 lib/libc/sys/preadv.c delete mode 100644 lib/libc/sys/pwrite.c delete mode 100644 lib/libc/sys/pwritev.c delete mode 100644 lib/libc/sys/truncate.c delete mode 100644 libexec/ld.so/aarch64/syscall.h delete mode 100644 libexec/ld.so/alpha/syscall.h delete mode 100644 libexec/ld.so/amd64/syscall.h delete mode 100644 libexec/ld.so/hppa/syscall.h delete mode 100644 libexec/ld.so/i386/syscall.h delete mode 100644 libexec/ld.so/m88k/syscall.h delete mode 100644 libexec/ld.so/mips64/syscall.h delete mode 100644 libexec/ld.so/powerpc/syscall.h delete mode 100644 libexec/ld.so/powerpc64/syscall.h delete mode 100644 libexec/ld.so/riscv64/syscall.h delete mode 100644 libexec/ld.so/sh/syscall.h delete mode 100644 libexec/ld.so/sparc64/syscall.h rename libexec/ld.so/{arm => }/syscall.h (89%) diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 5dafe60f57b..dd260c181be 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.160 2021/06/11 10:29:33 kettenis Exp $ +# $OpenBSD: Makefile.inc,v 1.161 2021/12/23 18:50:32 guenther Exp $ # $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $ # @(#)Makefile.inc 8.1 (Berkeley) 6/17/93 @@ -16,9 +16,9 @@ SRCS+= posix_madvise.c pthread_sigmask.c \ w_clock_gettime.c w_gettimeofday.c microtime.c # glue for compat with old syscall interfaces. -SRCS+= ftruncate.c lseek.c mquery.c mmap.c ptrace.c semctl.c truncate.c \ +SRCS+= ptrace.c semctl.c \ timer_create.c timer_delete.c timer_getoverrun.c timer_gettime.c \ - timer_settime.c pread.c preadv.c pwrite.c pwritev.c + timer_settime.c # stack protector helper functions SRCS+= stack_protector.c @@ -33,11 +33,11 @@ CANCEL= accept accept4 \ msgrcv msgsnd msync \ nanosleep \ open openat \ - poll ppoll pselect \ + poll ppoll pread preadv pselect pwrite pwritev \ read readv recvfrom recvmsg \ select sendmsg sendto \ wait4 write writev -SRCS+= ${CANCEL:%=w_%.c} w_pread.c w_preadv.c w_pwrite.c w_pwritev.c +SRCS+= ${CANCEL:%=w_%.c} # modules with default implementations on all architectures, unless overridden # below: @@ -50,17 +50,17 @@ ASM= __semctl.o __syscall.o __thrsigdivert.o \ faccessat.o fchdir.o fchflags.o fchmod.o fchmodat.o fchown.o \ fchownat.o fhopen.o fhstat.o fhstatfs.o \ flock.o fpathconf.o fstat.o fstatat.o fstatfs.o \ - futex.o futimens.o futimes.o \ + ftruncate.o futex.o futimens.o futimes.o \ getentropy.o getdents.o getfh.o getfsstat.o \ getgroups.o getitimer.o getpeername.o getpgid.o \ getpriority.o getresgid.o getresuid.o \ getrlimit.o getrusage.o getsid.o getsockname.o \ getsockopt.o ioctl.o \ kevent.o kill.o kqueue.o ktrace.o lchown.o \ - link.o linkat.o listen.o lstat.o madvise.o \ - minherit.o mkdir.o mkdirat.o mkfifo.o mkfifoat.o \ - mknod.o mknodat.o mlock.o mlockall.o mount.o mprotect.o \ - msgctl.o msgget.o munlock.o munlockall.o munmap.o \ + link.o linkat.o listen.o lseek.o lstat.o \ + madvise.o minherit.o mkdir.o mkdirat.o mkfifo.o mkfifoat.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 pledge.o profil.o \ quotactl.o \ @@ -73,7 +73,9 @@ ASM= __semctl.o __syscall.o __thrsigdivert.o \ settimeofday.o setuid.o shmat.o shmctl.o shmdt.o \ shmget.o shutdown.o sigaltstack.o socket.o \ socketpair.o stat.o statfs.o swapctl.o symlink.o symlinkat.o \ - sysarch.o sysctl.o thrkill.o unlink.o unlinkat.o \ + sysarch.o sysctl.o \ + thrkill.o truncate.o \ + unlink.o unlinkat.o \ unmount.o unveil.o utimensat.o utimes.o utrace.o SRCS+= ${SRCS_${MACHINE_CPU}} diff --git a/lib/libc/sys/ftruncate.c b/lib/libc/sys/ftruncate.c deleted file mode 100644 index b7d63b701da..00000000000 --- a/lib/libc/sys/ftruncate.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: ftruncate.c,v 1.17 2015/09/11 13:26:20 guenther Exp $ */ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include - -int __syscall(quad_t, ...); -PROTO_NORMAL(__syscall); - -DEF_SYS(ftruncate); - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -int -ftruncate(int fd, off_t length) -{ - return (__syscall(SYS_ftruncate, fd, 0, length)); -} -DEF_WEAK(ftruncate); diff --git a/lib/libc/sys/lseek.c b/lib/libc/sys/lseek.c deleted file mode 100644 index 5d6d7048b32..00000000000 --- a/lib/libc/sys/lseek.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: lseek.c,v 1.16 2015/09/11 13:26:20 guenther Exp $ */ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include - -off_t __syscall(quad_t, ...); -PROTO_NORMAL(__syscall); - -DEF_SYS(lseek); - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -off_t -lseek(int fd, off_t offset, int whence) -{ - return (__syscall(SYS_lseek, fd, 0, offset, whence)); -} -DEF_WEAK(lseek); diff --git a/lib/libc/sys/mmap.c b/lib/libc/sys/mmap.c deleted file mode 100644 index 30255677413..00000000000 --- a/lib/libc/sys/mmap.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: mmap.c,v 1.16 2015/09/11 13:26:20 guenther Exp $ */ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -void *__syscall(quad_t, ...); -PROTO_NORMAL(__syscall); - -DEF_SYS(mmap); - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -void * -mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (__syscall(SYS_mmap, addr, len, prot, flags, fd, 0, offset)); -} -DEF_WEAK(mmap); diff --git a/lib/libc/sys/mquery.c b/lib/libc/sys/mquery.c deleted file mode 100644 index 10d3d31a35e..00000000000 --- a/lib/libc/sys/mquery.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $OpenBSD: mquery.c,v 1.8 2015/09/11 13:26:20 guenther Exp $ */ -/* - * Written by Artur Grabowski Public Domain - */ - -#include -#include -#include - -void *__syscall(quad_t, ...); -PROTO_NORMAL(__syscall); - -DEF_SYS(mquery); - -/* - * This function provides 64-bit offset padding. - */ -void * -mquery(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (__syscall(SYS_mquery, addr, len, prot, flags, fd, 0, offset)); -} -DEF_WEAK(mquery); diff --git a/lib/libc/sys/pread.c b/lib/libc/sys/pread.c deleted file mode 100644 index 54f6134ae5f..00000000000 --- a/lib/libc/sys/pread.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $OpenBSD: pread.c,v 1.11 2016/05/07 19:05:22 guenther Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include - -ssize_t __syscall(quad_t, ...); -PROTO_NORMAL(__syscall); - - -DEF_SYS(pread); - - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -ssize_t -HIDDEN(pread)(int fd, void *buf, size_t nbyte, off_t offset) -{ - return (__syscall(SYS_pread, fd, buf, nbyte, 0, offset)); -} diff --git a/lib/libc/sys/preadv.c b/lib/libc/sys/preadv.c deleted file mode 100644 index 3b53ffafd76..00000000000 --- a/lib/libc/sys/preadv.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $OpenBSD: preadv.c,v 1.11 2016/05/07 19:05:22 guenther Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -ssize_t __syscall(quad_t, ...); -PROTO_NORMAL(__syscall); - - -DEF_SYS(preadv); - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -ssize_t -HIDDEN(preadv)(int fd, const struct iovec *iovp, int iovcnt, off_t offset) -{ - return (__syscall(SYS_preadv, fd, iovp, iovcnt, 0, offset)); -} diff --git a/lib/libc/sys/pwrite.c b/lib/libc/sys/pwrite.c deleted file mode 100644 index 2c99f4912a5..00000000000 --- a/lib/libc/sys/pwrite.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: pwrite.c,v 1.11 2016/05/07 19:05:22 guenther Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include - -ssize_t __syscall(quad_t, ...); -PROTO_NORMAL(__syscall); - - -DEF_SYS(pwrite); - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -ssize_t -HIDDEN(pwrite)(int fd, const void *buf, size_t nbyte, off_t offset) -{ - return (__syscall(SYS_pwrite, fd, buf, nbyte, 0, offset)); -} diff --git a/lib/libc/sys/pwritev.c b/lib/libc/sys/pwritev.c deleted file mode 100644 index 92b47c4e714..00000000000 --- a/lib/libc/sys/pwritev.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $OpenBSD: pwritev.c,v 1.11 2016/05/07 19:05:22 guenther Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -ssize_t __syscall(quad_t, ...); -PROTO_NORMAL(__syscall); - - -DEF_SYS(pwritev); - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -ssize_t -HIDDEN(pwritev)(int fd, const struct iovec *iovp, int iovcnt, off_t offset) -{ - - return (__syscall(SYS_pwritev, fd, iovp, iovcnt, 0, offset)); -} diff --git a/lib/libc/sys/truncate.c b/lib/libc/sys/truncate.c deleted file mode 100644 index 3b0adf685d2..00000000000 --- a/lib/libc/sys/truncate.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: truncate.c,v 1.14 2015/09/11 13:26:20 guenther Exp $ */ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include - -int __syscall(quad_t, ...); -PROTO_NORMAL(__syscall); - -DEF_SYS(truncate); - - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -int -truncate(const char *path, off_t length) -{ - return (__syscall(SYS_truncate, path, 0, length)); -} -DEF_WEAK(truncate); diff --git a/libexec/ld.so/Makefile b/libexec/ld.so/Makefile index 1fe64fdb9a2..b84590c911e 100644 --- a/libexec/ld.so/Makefile +++ b/libexec/ld.so/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.81 2021/06/26 14:46:48 kettenis Exp $ +# $OpenBSD: Makefile,v 1.82 2021/12/23 18:50:32 guenther Exp $ SUBDIR=ldconfig ldd MAN= ld.so.1 @@ -27,10 +27,17 @@ SRCS+= path.c util.c sod.c strsep.c strtol.c dir.c library_subr.c SRCS+= dl_uname.c dl_dirname.c strlcat.c strlen.c trace.c SRCS+= malloc.c reallocarray.c tib.c ffs.c -syscall=__syscall close exit fstat getdents getentropy getthrid issetugid \ - mprotect munmap msyscall open pledge read __realpath sendsyslog \ +syscall=close exit fstat getdents getentropy getthrid issetugid kbind \ + mmap mprotect munmap msyscall open pledge read __realpath sendsyslog \ __set_tcb sysctl thrkill utrace write +.if (${MACHINE_ARCH} == "i386") +syscall+=mquery +SRCS+= library_mquery.c +.else +SRCS+= library.c +.endif + GEN_PREFIX=\t.file "${@:R}.c"\n\#include "SYS.h" .for _i in ${syscall} OBJS+=dl_${_i}.o @@ -41,12 +48,6 @@ dl_${_i}.o: SYS.h ${.TARGET:R}.d -o ${.TARGET} .endfor -.if (${MACHINE_ARCH} == "i386") -SRCS+= library_mquery.c -.else -SRCS+= library.c -.endif - .include "${.CURDIR}/${MACHINE_CPU}/Makefile.inc" .PATH: ${.CURDIR}/${MACHINE_CPU} diff --git a/libexec/ld.so/aarch64/syscall.h b/libexec/ld.so/aarch64/syscall.h deleted file mode 100644 index b1a3a7b442f..00000000000 --- a/libexec/ld.so/aarch64/syscall.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: syscall.h,v 1.8 2019/11/29 06:34:44 deraadt Exp $ */ - -/* - * Copyright (c) 1998 Per Fogelstrom, Opsycon AB - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef __DL_SYSCALL_H__ -#define __DL_SYSCALL_H__ - -#include -#include - -#ifndef _dl_MAX_ERRNO -#define _dl_MAX_ERRNO 512L -#endif -#define _dl_mmap_error(__res) \ - ((long)__res < 0 && (long)__res >= -_dl_MAX_ERRNO) - -int _dl_close(int); -__dead -void _dl_exit(int); -int _dl_fstat(int, struct stat *); -ssize_t _dl_getdents(int, char *, size_t); -int _dl_issetugid(void); -int _dl_getthrid(void); -int _dl_mprotect(const void *, size_t, int); -int _dl_munmap(const void *, size_t); -int _dl_open(const char *, int); -int _dl_msyscall(void *addr, size_t len); -ssize_t _dl_read(int, const char *, size_t); -int _dl_pledge(const char *, const char **); -long _dl___syscall(quad_t, ...); -int _dl_sysctl(const int *, u_int, void *, size_t *, void *, size_t); -int _dl_utrace(const char *, const void *, size_t); -int _dl_getentropy(char *, size_t); -int _dl_sendsyslog(const char *, size_t, int); -void _dl___set_tcb(void *); -__dead -void _dl_thrkill(pid_t, int, void *); - -static inline void * -_dl_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (void *)_dl___syscall(SYS_mmap, addr, len, prot, - flags, fd, 0, offset); -} - -#endif /*__DL_SYSCALL_H__*/ diff --git a/libexec/ld.so/alpha/syscall.h b/libexec/ld.so/alpha/syscall.h deleted file mode 100644 index f8f322c9c11..00000000000 --- a/libexec/ld.so/alpha/syscall.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: syscall.h,v 1.42 2019/11/29 06:34:44 deraadt Exp $ */ - -/* - * Copyright (c) 1998 Per Fogelstrom, Opsycon AB - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef __DL_SYSCALL_H__ -#define __DL_SYSCALL_H__ - -#include -#include - -#ifndef _dl_MAX_ERRNO -#define _dl_MAX_ERRNO 512L -#endif -#define _dl_mmap_error(__res) \ - ((long)__res < 0 && (long)__res >= -_dl_MAX_ERRNO) - -int _dl_close(int); -__dead -void _dl_exit(int); -int _dl_fstat(int, struct stat *); -ssize_t _dl_getdents(int, char *, size_t); -int _dl_issetugid(void); -int _dl_getthrid(void); -int _dl_mprotect(const void *, size_t, int); -int _dl_munmap(const void *, size_t); -int _dl_open(const char *, int); -int _dl_msyscall(void *addr, size_t len); -ssize_t _dl_read(int, const char *, size_t); -int _dl_pledge(const char *, const char **); -long _dl___syscall(quad_t, ...); -int _dl_sysctl(const int *, u_int, void *, size_t *, void *, size_t); -int _dl_utrace(const char *, const void *, size_t); -int _dl_getentropy(char *, size_t); -int _dl_sendsyslog(const char *, size_t, int); -void _dl___set_tcb(void *); -__dead -void _dl_thrkill(pid_t, int, void *); - -static inline void * -_dl_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (void *)_dl___syscall(SYS_mmap, addr, len, prot, - flags, fd, 0, offset); -} - -#endif /*__DL_SYSCALL_H__*/ diff --git a/libexec/ld.so/amd64/syscall.h b/libexec/ld.so/amd64/syscall.h deleted file mode 100644 index a680d1bddd9..00000000000 --- a/libexec/ld.so/amd64/syscall.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: syscall.h,v 1.29 2019/11/29 06:34:44 deraadt Exp $ */ - -/* - * Copyright (c) 1998 Per Fogelstrom, Opsycon AB - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef __DL_SYSCALL_H__ -#define __DL_SYSCALL_H__ - -#include -#include - -#ifndef _dl_MAX_ERRNO -#define _dl_MAX_ERRNO 512L -#endif -#define _dl_mmap_error(__res) \ - ((long)__res < 0 && (long)__res >= -_dl_MAX_ERRNO) - -int _dl_close(int); -__dead -void _dl_exit(int); -int _dl_fstat(int, struct stat *); -ssize_t _dl_getdents(int, char *, size_t); -int _dl_issetugid(void); -int _dl_getthrid(void); -int _dl_mprotect(const void *, size_t, int); -int _dl_munmap(const void *, size_t); -int _dl_open(const char *, int); -int _dl_msyscall(void *addr, size_t len); -ssize_t _dl_read(int, const char *, size_t); -int _dl_pledge(const char *, const char **); -long _dl___syscall(quad_t, ...); -int _dl_sysctl(const int *, u_int, void *, size_t *, void *, size_t); -int _dl_utrace(const char *, const void *, size_t); -int _dl_getentropy(char *, size_t); -int _dl_sendsyslog(const char *, size_t, int); -void _dl___set_tcb(void *); -__dead -void _dl_thrkill(pid_t, int, void *); - -static inline void * -_dl_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (void *)_dl___syscall(SYS_mmap, addr, len, prot, - flags, fd, 0, offset); -} - -#endif /*__DL_SYSCALL_H__*/ diff --git a/libexec/ld.so/hppa/syscall.h b/libexec/ld.so/hppa/syscall.h deleted file mode 100644 index a680d1bddd9..00000000000 --- a/libexec/ld.so/hppa/syscall.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: syscall.h,v 1.29 2019/11/29 06:34:44 deraadt Exp $ */ - -/* - * Copyright (c) 1998 Per Fogelstrom, Opsycon AB - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef __DL_SYSCALL_H__ -#define __DL_SYSCALL_H__ - -#include -#include - -#ifndef _dl_MAX_ERRNO -#define _dl_MAX_ERRNO 512L -#endif -#define _dl_mmap_error(__res) \ - ((long)__res < 0 && (long)__res >= -_dl_MAX_ERRNO) - -int _dl_close(int); -__dead -void _dl_exit(int); -int _dl_fstat(int, struct stat *); -ssize_t _dl_getdents(int, char *, size_t); -int _dl_issetugid(void); -int _dl_getthrid(void); -int _dl_mprotect(const void *, size_t, int); -int _dl_munmap(const void *, size_t); -int _dl_open(const char *, int); -int _dl_msyscall(void *addr, size_t len); -ssize_t _dl_read(int, const char *, size_t); -int _dl_pledge(const char *, const char **); -long _dl___syscall(quad_t, ...); -int _dl_sysctl(const int *, u_int, void *, size_t *, void *, size_t); -int _dl_utrace(const char *, const void *, size_t); -int _dl_getentropy(char *, size_t); -int _dl_sendsyslog(const char *, size_t, int); -void _dl___set_tcb(void *); -__dead -void _dl_thrkill(pid_t, int, void *); - -static inline void * -_dl_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (void *)_dl___syscall(SYS_mmap, addr, len, prot, - flags, fd, 0, offset); -} - -#endif /*__DL_SYSCALL_H__*/ diff --git a/libexec/ld.so/i386/syscall.h b/libexec/ld.so/i386/syscall.h deleted file mode 100644 index b7f329a184a..00000000000 --- a/libexec/ld.so/i386/syscall.h +++ /dev/null @@ -1,77 +0,0 @@ -/* $OpenBSD: syscall.h,v 1.33 2019/11/29 06:34:44 deraadt Exp $ */ - -/* - * Copyright (c) 1998 Per Fogelstrom, Opsycon AB - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef __DL_SYSCALL_H__ -#define __DL_SYSCALL_H__ - -#include -#include - -#ifndef _dl_MAX_ERRNO -#define _dl_MAX_ERRNO 512L -#endif -#define _dl_mmap_error(__res) \ - ((long)__res < 0 && (long)__res >= -_dl_MAX_ERRNO) - -int _dl_close(int); -__dead -void _dl_exit(int); -int _dl_fstat(int, struct stat *); -ssize_t _dl_getdents(int, char *, size_t); -int _dl_issetugid(void); -int _dl_getthrid(void); -int _dl_mprotect(const void *, size_t, int); -int _dl_munmap(const void *, size_t); -int _dl_open(const char *, int); -int _dl_msyscall(void *addr, size_t len); -ssize_t _dl_read(int, const char *, size_t); -int _dl_pledge(const char *, const char **); -long _dl___syscall(quad_t, ...); -int _dl_sysctl(const int *, u_int, void *, size_t *, void *, size_t); -int _dl_utrace(const char *, const void *, size_t); -int _dl_getentropy(char *, size_t); -int _dl_sendsyslog(const char *, size_t, int); -void _dl___set_tcb(void *); -__dead -void _dl_thrkill(pid_t, int, void *); - -static inline void * -_dl_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (void *)_dl___syscall(SYS_mmap, addr, len, prot, - flags, fd, 0, offset); -} - -static inline void * -_dl_mquery(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (void *)_dl___syscall(SYS_mquery, addr, len, prot, - flags, fd, 0, offset); -} - -#endif /*__DL_SYSCALL_H__*/ diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c index 2063098a8b0..7fabcf7b3e3 100644 --- a/libexec/ld.so/loader.c +++ b/libexec/ld.so/loader.c @@ -1,4 +1,4 @@ -/* $OpenBSD: loader.c,v 1.193 2021/11/12 22:28:13 guenther Exp $ */ +/* $OpenBSD: loader.c,v 1.194 2021/12/23 18:50:32 guenther Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -491,7 +491,7 @@ _dl_boot(const char **argv, char **envp, const long dyn_loff, long *dl_data) if (_dl_bindnow) { /* Lazy binding disabled, so disable kbind */ - _dl___syscall(SYS_kbind, (void *)NULL, (size_t)0, (long long)0); + _dl_kbind(NULL, 0, 0); } DL_DEB(("ld.so loading: '%s'\n", __progname)); diff --git a/libexec/ld.so/m88k/rtld_machine.c b/libexec/ld.so/m88k/rtld_machine.c index 59a13f367f5..ca37e5eb2ca 100644 --- a/libexec/ld.so/m88k/rtld_machine.c +++ b/libexec/ld.so/m88k/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.29 2019/12/07 22:57:48 guenther Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.30 2021/12/23 18:50:32 guenther Exp $ */ /* * Copyright (c) 2013 Miodrag Vallat. @@ -55,6 +55,7 @@ #include "archdep.h" #include "resolve.h" +int _dl_cacheflush(unsigned long, size_t); Elf_Addr _dl_bind(elf_object_t *object, int reloff); void _dl_md_reloc_gotp_ent(Elf_Addr, Elf_Addr, Elf_Addr); diff --git a/libexec/ld.so/m88k/syscall.h b/libexec/ld.so/m88k/syscall.h deleted file mode 100644 index f0b4c20e7e6..00000000000 --- a/libexec/ld.so/m88k/syscall.h +++ /dev/null @@ -1,72 +0,0 @@ -/* $OpenBSD: syscall.h,v 1.25 2019/11/29 06:34:45 deraadt Exp $ */ - -/* - * Copyright (c) 1998 Per Fogelstrom, Opsycon AB - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef __DL_SYSCALL_H__ -#define __DL_SYSCALL_H__ - -#include -#include - -#ifndef _dl_MAX_ERRNO -#define _dl_MAX_ERRNO 512L -#endif -#define _dl_mmap_error(__res) \ - ((long)__res < 0 && (long)__res >= -_dl_MAX_ERRNO) - -int _dl_close(int); -__dead -void _dl_exit(int); -int _dl_fstat(int, struct stat *); -ssize_t _dl_getdents(int, char *, size_t); -int _dl_issetugid(void); -int _dl_getthrid(void); -int _dl_mprotect(const void *, size_t, int); -int _dl_munmap(const void *, size_t); -int _dl_open(const char *, int); -int _dl_msyscall(void *addr, size_t len); -ssize_t _dl_read(int, const char *, size_t); -int _dl_pledge(const char *, const char **); -long _dl___syscall(quad_t, ...); -int _dl_sysctl(const int *, u_int, void *, size_t *, void *, size_t); -int _dl_utrace(const char *, const void *, size_t); -int _dl_getentropy(char *, size_t); -int _dl_sendsyslog(const char *, size_t, int); -void _dl___set_tcb(void *); -__dead -void _dl_thrkill(pid_t, int, void *); - -static inline void * -_dl_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (void *)_dl___syscall(SYS_mmap, addr, len, prot, - flags, fd, 0, offset); -} - -int _dl_cacheflush(unsigned long, size_t); - -#endif /*__DL_SYSCALL_H__*/ diff --git a/libexec/ld.so/mips64/syscall.h b/libexec/ld.so/mips64/syscall.h deleted file mode 100644 index 0d2497e6f3d..00000000000 --- a/libexec/ld.so/mips64/syscall.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: syscall.h,v 1.31 2019/11/29 06:34:45 deraadt Exp $ */ - -/* - * Copyright (c) 1998 Per Fogelstrom, Opsycon AB - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef __DL_SYSCALL_H__ -#define __DL_SYSCALL_H__ - -#include -#include - -#ifndef _dl_MAX_ERRNO -#define _dl_MAX_ERRNO 512L -#endif -#define _dl_mmap_error(__res) \ - ((long)__res < 0 && (long)__res >= -_dl_MAX_ERRNO) - -int _dl_close(int); -__dead -void _dl_exit(int); -int _dl_fstat(int, struct stat *); -ssize_t _dl_getdents(int, char *, size_t); -int _dl_issetugid(void); -int _dl_getthrid(void); -int _dl_mprotect(const void *, size_t, int); -int _dl_munmap(const void *, size_t); -int _dl_open(const char *, int); -int _dl_msyscall(void *addr, size_t len); -ssize_t _dl_read(int, const char *, size_t); -int _dl_pledge(const char *, const char **); -long _dl___syscall(quad_t, ...); -int _dl_sysctl(const int *, u_int, void *, size_t *, void *, size_t); -int _dl_utrace(const char *, const void *, size_t); -int _dl_getentropy(char *, size_t); -int _dl_sendsyslog(const char *, size_t, int); -void _dl___set_tcb(void *); -__dead -void _dl_thrkill(pid_t, int, void *); - -static inline void * -_dl_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (void *)_dl___syscall(SYS_mmap, addr, len, prot, - flags, fd, 0, offset); -} - -#endif /*__DL_SYSCALL_H__*/ diff --git a/libexec/ld.so/powerpc/syscall.h b/libexec/ld.so/powerpc/syscall.h deleted file mode 100644 index ab8811f0615..00000000000 --- a/libexec/ld.so/powerpc/syscall.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: syscall.h,v 1.48 2019/11/29 06:34:45 deraadt Exp $ */ - -/* - * Copyright (c) 1998 Per Fogelstrom, Opsycon AB - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef __DL_SYSCALL_H__ -#define __DL_SYSCALL_H__ - -#include -#include - -#ifndef _dl_MAX_ERRNO -#define _dl_MAX_ERRNO 512L -#endif -#define _dl_mmap_error(__res) \ - ((long)__res < 0 && (long)__res >= -_dl_MAX_ERRNO) - -int _dl_close(int); -__dead -void _dl_exit(int); -int _dl_fstat(int, struct stat *); -ssize_t _dl_getdents(int, char *, size_t); -int _dl_issetugid(void); -int _dl_getthrid(void); -int _dl_mprotect(const void *, size_t, int); -int _dl_munmap(const void *, size_t); -int _dl_open(const char *, int); -int _dl_msyscall(void *addr, size_t len); -ssize_t _dl_read(int, const char *, size_t); -int _dl_pledge(const char *, const char **); -long _dl___syscall(quad_t, ...); -int _dl_sysctl(const int *, u_int, void *, size_t *, void *, size_t); -int _dl_utrace(const char *, const void *, size_t); -int _dl_getentropy(char *, size_t); -int _dl_sendsyslog(const char *, size_t, int); -void _dl___set_tcb(void *); -__dead -void _dl_thrkill(pid_t, int, void *); - -static inline void * -_dl_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (void *)_dl___syscall(SYS_mmap, addr, len, prot, - flags, fd, 0, offset); -} - -#endif /*__DL_SYSCALL_H__*/ diff --git a/libexec/ld.so/powerpc64/syscall.h b/libexec/ld.so/powerpc64/syscall.h deleted file mode 100644 index ca623a9e1a5..00000000000 --- a/libexec/ld.so/powerpc64/syscall.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: syscall.h,v 1.1 2020/06/25 04:00:58 drahn Exp $ */ - -/* - * Copyright (c) 1998 Per Fogelstrom, Opsycon AB - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef __DL_SYSCALL_H__ -#define __DL_SYSCALL_H__ - -#include -#include - -#ifndef _dl_MAX_ERRNO -#define _dl_MAX_ERRNO 512L -#endif -#define _dl_mmap_error(__res) \ - ((long)__res < 0 && (long)__res >= -_dl_MAX_ERRNO) - -int _dl_close(int); -__dead -void _dl_exit(int); -int _dl_fstat(int, struct stat *); -ssize_t _dl_getdents(int, char *, size_t); -int _dl_issetugid(void); -int _dl_getthrid(void); -int _dl_mprotect(const void *, size_t, int); -int _dl_munmap(const void *, size_t); -int _dl_open(const char *, int); -int _dl_msyscall(void *addr, size_t len); -ssize_t _dl_read(int, const char *, size_t); -int _dl_pledge(const char *, const char **); -long _dl___syscall(quad_t, ...); -int _dl_sysctl(const int *, u_int, void *, size_t *, void *, size_t); -int _dl_utrace(const char *, const void *, size_t); -int _dl_getentropy(char *, size_t); -int _dl_sendsyslog(const char *, size_t, int); -void _dl___set_tcb(void *); -__dead -void _dl_thrkill(pid_t, int, void *); - -static inline void * -_dl_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (void *)_dl___syscall(SYS_mmap, addr, len, prot, - flags, fd, 0, offset); -} - -#endif /*__DL_SYSCALL_H__*/ diff --git a/libexec/ld.so/riscv64/syscall.h b/libexec/ld.so/riscv64/syscall.h deleted file mode 100644 index 08a655123ad..00000000000 --- a/libexec/ld.so/riscv64/syscall.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: syscall.h,v 1.1 2021/04/28 15:16:26 drahn Exp $ */ - -/* - * Copyright (c) 1998 Per Fogelstrom, Opsycon AB - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef __DL_SYSCALL_H__ -#define __DL_SYSCALL_H__ - -#include -#include - -#ifndef _dl_MAX_ERRNO -#define _dl_MAX_ERRNO 512L -#endif -#define _dl_mmap_error(__res) \ - ((long)__res < 0 && (long)__res >= -_dl_MAX_ERRNO) - -int _dl_close(int); -__dead -void _dl_exit(int); -int _dl_fstat(int, struct stat *); -ssize_t _dl_getdents(int, char *, size_t); -int _dl_issetugid(void); -int _dl_getthrid(void); -int _dl_mprotect(const void *, size_t, int); -int _dl_munmap(const void *, size_t); -int _dl_open(const char *, int); -int _dl_msyscall(void *addr, size_t len); -ssize_t _dl_read(int, const char *, size_t); -int _dl_pledge(const char *, const char **); -long _dl___syscall(quad_t, ...); -int _dl_sysctl(const int *, u_int, void *, size_t *, void *, size_t); -int _dl_utrace(const char *, const void *, size_t); -int _dl_getentropy(char *, size_t); -int _dl_sendsyslog(const char *, size_t, int); -void _dl___set_tcb(void *); -__dead -void _dl_thrkill(pid_t, int, void *); - -static inline void * -_dl_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (void *)_dl___syscall(SYS_mmap, addr, len, prot, - flags, fd, 0, offset); -} - -#endif /*__DL_SYSCALL_H__*/ diff --git a/libexec/ld.so/sh/syscall.h b/libexec/ld.so/sh/syscall.h deleted file mode 100644 index dbb8084e6b2..00000000000 --- a/libexec/ld.so/sh/syscall.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: syscall.h,v 1.28 2019/11/29 06:34:45 deraadt Exp $ */ - -/* - * Copyright (c) 1998 Per Fogelstrom, Opsycon AB - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef __DL_SYSCALL_H__ -#define __DL_SYSCALL_H__ - -#include -#include - -#ifndef _dl_MAX_ERRNO -#define _dl_MAX_ERRNO 512L -#endif -#define _dl_mmap_error(__res) \ - ((long)__res < 0 && (long)__res >= -_dl_MAX_ERRNO) - -int _dl_close(int); -__dead -void _dl_exit(int); -int _dl_fstat(int, struct stat *); -ssize_t _dl_getdents(int, char *, size_t); -int _dl_issetugid(void); -int _dl_getthrid(void); -int _dl_mprotect(const void *, size_t, int); -int _dl_munmap(const void *, size_t); -int _dl_open(const char *, int); -int _dl_msyscall(void *addr, size_t len); -ssize_t _dl_read(int, const char *, size_t); -int _dl_pledge(const char *, const char **); -long _dl___syscall(quad_t, ...); -int _dl_sysctl(const int *, u_int, void *, size_t *, void *, size_t); -int _dl_utrace(const char *, const void *, size_t); -int _dl_getentropy(char *, size_t); -int _dl_sendsyslog(const char *, size_t, int); -void _dl___set_tcb(void *); -__dead -void _dl_thrkill(pid_t, int, void *); - -static inline void * -_dl_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (void *)_dl___syscall(SYS_mmap, addr, len, prot, - flags, fd, 0, offset); -} - -#endif /*__DL_SYSCALL_H__*/ diff --git a/libexec/ld.so/sparc64/syscall.h b/libexec/ld.so/sparc64/syscall.h deleted file mode 100644 index f597523e8ae..00000000000 --- a/libexec/ld.so/sparc64/syscall.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: syscall.h,v 1.41 2019/11/29 06:34:45 deraadt Exp $ */ - -/* - * Copyright (c) 1998 Per Fogelstrom, Opsycon AB - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef __DL_SYSCALL_H__ -#define __DL_SYSCALL_H__ - -#include -#include - -#ifndef _dl_MAX_ERRNO -#define _dl_MAX_ERRNO 512L -#endif -#define _dl_mmap_error(__res) \ - ((long)__res < 0 && (long)__res >= -_dl_MAX_ERRNO) - -int _dl_close(int); -__dead -void _dl_exit(int); -int _dl_fstat(int, struct stat *); -ssize_t _dl_getdents(int, char *, size_t); -int _dl_issetugid(void); -int _dl_getthrid(void); -int _dl_mprotect(const void *, size_t, int); -int _dl_munmap(const void *, size_t); -int _dl_open(const char *, int); -int _dl_msyscall(void *addr, size_t len); -ssize_t _dl_read(int, const char *, size_t); -int _dl_pledge(const char *, const char **); -long _dl___syscall(quad_t, ...); -int _dl_sysctl(const int *, u_int, void *, size_t *, void *, size_t); -int _dl_utrace(const char *, const void *, size_t); -int _dl_getentropy(char *, size_t); -int _dl_sendsyslog(const char *, size_t, int); -void _dl___set_tcb(void *); -__dead -void _dl_thrkill(pid_t, int, void *); - -static inline void * -_dl_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (void *)_dl___syscall(SYS_mmap, addr, len, prot, - flags, fd, 0, offset); -} - -#endif /*__DL_SYSCALL_H__*/ diff --git a/libexec/ld.so/arm/syscall.h b/libexec/ld.so/syscall.h similarity index 89% rename from libexec/ld.so/arm/syscall.h rename to libexec/ld.so/syscall.h index a680d1bddd9..b59540ae945 100644 --- a/libexec/ld.so/arm/syscall.h +++ b/libexec/ld.so/syscall.h @@ -1,4 +1,4 @@ -/* $OpenBSD: syscall.h,v 1.29 2019/11/29 06:34:44 deraadt Exp $ */ +/* $OpenBSD: syscall.h,v 1.1 2021/12/23 18:50:32 guenther Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -38,33 +38,30 @@ #define _dl_mmap_error(__res) \ ((long)__res < 0 && (long)__res >= -_dl_MAX_ERRNO) +struct __kbind; + int _dl_close(int); __dead void _dl_exit(int); int _dl_fstat(int, struct stat *); ssize_t _dl_getdents(int, char *, size_t); -int _dl_issetugid(void); +int _dl_getentropy(char *, size_t); int _dl_getthrid(void); +int _dl_issetugid(void); +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_munmap(const void *, size_t); int _dl_open(const char *, int); -int _dl_msyscall(void *addr, size_t len); -ssize_t _dl_read(int, const char *, size_t); int _dl_pledge(const char *, const char **); -long _dl___syscall(quad_t, ...); -int _dl_sysctl(const int *, u_int, void *, size_t *, void *, size_t); -int _dl_utrace(const char *, const void *, size_t); -int _dl_getentropy(char *, size_t); +ssize_t _dl_read(int, const char *, size_t); int _dl_sendsyslog(const char *, size_t, int); void _dl___set_tcb(void *); +int _dl_sysctl(const int *, u_int, void *, size_t *, void *, size_t); __dead void _dl_thrkill(pid_t, int, void *); - -static inline void * -_dl_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return (void *)_dl___syscall(SYS_mmap, addr, len, prot, - flags, fd, 0, offset); -} +int _dl_utrace(const char *, const void *, size_t); #endif /*__DL_SYSCALL_H__*/ diff --git a/sys/arch/hppa/hppa/trap.c b/sys/arch/hppa/hppa/trap.c index 2df8bb365ef..b052fa12904 100644 --- a/sys/arch/hppa/hppa/trap.c +++ b/sys/arch/hppa/hppa/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.155 2021/12/09 00:26:11 guenther Exp $ */ +/* $OpenBSD: trap.c,v 1.156 2021/12/23 18:50:32 guenther Exp $ */ /* * Copyright (c) 1998-2004 Michael Shalayeff @@ -849,6 +849,17 @@ syscall(struct trapframe *frame) case SYS_pwrite: i = 4; break; case SYS_mquery: case SYS_mmap: i = 6; break; +#ifdef SYS_pad_lseek + case SYS_pad_lseek: retq = 0; + case SYS_pad_truncate: + case SYS_pad_ftruncate: i = 2; break; + case SYS_pad_preadv: + case SYS_pad_pwritev: + case SYS_pad_pread: + case SYS_pad_pwrite: i = 4; break; + case SYS_pad_mquery: + case SYS_pad_mmap: i = 6; break; +#endif } if (i) { diff --git a/sys/arch/sh/sh/trap.c b/sys/arch/sh/sh/trap.c index 64e969df7be..ce345d3fc9f 100644 --- a/sys/arch/sh/sh/trap.c +++ b/sys/arch/sh/sh/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.49 2021/12/09 00:26:11 guenther Exp $ */ +/* $OpenBSD: trap.c,v 1.50 2021/12/23 18:50:32 guenther Exp $ */ /* $NetBSD: exception.c,v 1.32 2006/09/04 23:57:52 uwe Exp $ */ /* $NetBSD: syscall.c,v 1.6 2006/03/07 07:21:50 thorpej Exp $ */ @@ -513,13 +513,13 @@ syscall(struct proc *p, struct trapframe *tf) caddr_t params; const struct sysent *callp; int error, opc; - size_t argsize; - register_t code, args[8], rval[2], ocode; + int argoff, argsize; + register_t code, args[8], rval[2]; uvmexp.syscalls++; opc = tf->tf_spc; - ocode = code = tf->tf_r0; + code = tf->tf_r0; params = (caddr_t)tf->tf_r15; @@ -529,6 +529,7 @@ syscall(struct proc *p, struct trapframe *tf) * Code is first argument, followed by actual args. */ code = tf->tf_r4; + argoff = 1; break; case SYS___syscall: /* @@ -540,8 +541,10 @@ syscall(struct proc *p, struct trapframe *tf) #else code = tf->tf_r4; #endif + argoff = 2; break; default: + argoff = 0; break; } @@ -558,46 +561,41 @@ syscall(struct proc *p, struct trapframe *tf) } #endif - switch (ocode) { - case SYS_syscall: - if (argsize) { - args[0] = tf->tf_r5; - args[1] = tf->tf_r6; - args[2] = tf->tf_r7; - if (argsize > 3 * sizeof(int)) { - argsize -= 3 * sizeof(int); - if ((error = copyin(params, &args[3], - argsize))) - goto bad; - } + if (argsize) { + register_t *ap; + int off_t_arg; + + switch (code) { + default: off_t_arg = 0; break; + case SYS_lseek: + case SYS_truncate: + case SYS_ftruncate: off_t_arg = 1; break; + case SYS_preadv: + case SYS_pwritev: + case SYS_pread: + case SYS_pwrite: off_t_arg = 3; break; } - break; - case SYS___syscall: - if (argsize) { - args[0] = tf->tf_r6; - args[1] = tf->tf_r7; - if (argsize > 2 * sizeof(int)) { - argsize -= 2 * sizeof(int); - if ((error = copyin(params, &args[2], - argsize))) - goto bad; - } + + ap = args; + switch (argoff) { + case 0: *ap++ = tf->tf_r4; argsize -= sizeof(int); + case 1: *ap++ = tf->tf_r5; argsize -= sizeof(int); + case 2: *ap++ = tf->tf_r6; argsize -= sizeof(int); + /* + * off_t args aren't split between register + * and stack, but rather r7 is skipped and + * the entire off_t is on the stack. + */ + if (argoff + off_t_arg == 3) + break; + *ap++ = tf->tf_r7; argsize -= sizeof(int); + break; } - break; - default: - if (argsize) { - args[0] = tf->tf_r4; - args[1] = tf->tf_r5; - args[2] = tf->tf_r6; - args[3] = tf->tf_r7; - if (argsize > 4 * sizeof(int)) { - argsize -= 4 * sizeof(int); - if ((error = copyin(params, &args[4], - argsize))) - goto bad; - } + + if (argsize > 0) { + if ((error = copyin(params, ap, argsize))) + goto bad; } - break; } rval[0] = 0; diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 3d5408eadc0..23b2af5c88d 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_ktrace.c,v 1.104 2020/09/13 09:48:39 claudio Exp $ */ +/* $OpenBSD: kern_ktrace.c,v 1.105 2021/12/23 18:50:32 guenther Exp $ */ /* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */ /* @@ -204,6 +204,10 @@ ktrsysret(struct proc *p, register_t code, int error, else if (code == SYS_lseek) /* the one exception: lseek on ILP32 needs more */ len = sizeof(long long); +#if 1 + else if (code == SYS_pad_lseek) + len = sizeof(long long); +#endif else len = sizeof(register_t); ktrwrite2(p, &kth, &ktp, sizeof(ktp), retval, len); diff --git a/sys/kern/kern_pledge.c b/sys/kern/kern_pledge.c index 2b9a1a0abc2..c97091bf77f 100644 --- a/sys/kern/kern_pledge.c +++ b/sys/kern/kern_pledge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_pledge.c,v 1.276 2021/11/15 17:14:51 deraadt Exp $ */ +/* $OpenBSD: kern_pledge.c,v 1.277 2021/12/23 18:50:32 guenther Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott @@ -174,6 +174,18 @@ const uint64_t pledge_syscalls[SYS_MAXSYSCALL] = { [SYS_lseek] = PLEDGE_STDIO, [SYS_fpathconf] = PLEDGE_STDIO, +#if 1 + [SYS_pad_mquery] = PLEDGE_STDIO, + [SYS_pad_mmap] = PLEDGE_STDIO, + [SYS_pad_pread] = PLEDGE_STDIO, + [SYS_pad_preadv] = PLEDGE_STDIO, + [SYS_pad_pwrite] = PLEDGE_STDIO, + [SYS_pad_pwritev] = PLEDGE_STDIO, + [SYS_pad_ftruncate] = PLEDGE_STDIO, + [SYS_pad_lseek] = PLEDGE_STDIO, + [SYS_pad_truncate] = PLEDGE_WPATH, +#endif + /* * Address selection required a network pledge ("inet", * "unix", "dns". diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index 70157df3dce..38eee093cd4 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -1,4 +1,4 @@ -; $OpenBSD: syscalls.master,v 1.220 2021/11/29 16:30:30 mvs Exp $ +; $OpenBSD: syscalls.master,v 1.221 2021/12/23 18:50:31 guenther Exp $ ; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $ ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 @@ -126,7 +126,8 @@ struct sigaction *osa); } 47 STD NOLOCK { gid_t sys_getgid(void); } 48 STD NOLOCK { int sys_sigprocmask(int how, sigset_t mask); } -49 OBSOL ogetlogin +49 STD { void *sys_mmap(void *addr, size_t len, int prot, \ + int flags, int fd, off_t pos); } 50 STD { int sys_setlogin(const char *namebuf); } #ifdef ACCOUNTING 51 STD { int sys_acct(const char *path); } @@ -179,7 +180,8 @@ const struct timeval *tptr); } 77 STD { int sys_futimes(int fd, \ const struct timeval *tptr); } -78 UNIMPL mincore +78 STD { void *sys_mquery(void *addr, size_t len, int prot, \ + int flags, int fd, off_t pos); } 79 STD NOLOCK { int sys_getgroups(int gidsetsize, \ gid_t *gidset); } 80 STD { int sys_setgroups(int gidsetsize, \ @@ -309,16 +311,22 @@ 163 OBSOL osetdomainname 164 STD { int sys___tmpfd(int flags); } 165 STD { int sys_sysarch(int op, void *parms); } -166 UNIMPL -167 UNIMPL -168 UNIMPL -169 OBSOL semsys10 -170 OBSOL msgsys10 -171 OBSOL shmsys10 -172 UNIMPL -173 STD NOLOCK { ssize_t sys_pread(int fd, void *buf, \ +166 STD NOLOCK { off_t sys_lseek(int fd, off_t offset, int whence); } +167 STD { int sys_truncate(const char *path, off_t length); } +168 STD { int sys_ftruncate(int fd, off_t length); } +169 STD NOLOCK { ssize_t sys_pread(int fd, void *buf, \ + size_t nbyte, off_t offset); } +170 STD NOLOCK { ssize_t sys_pwrite(int fd, const void *buf, \ + size_t nbyte, off_t offset); } +171 STD NOLOCK { ssize_t sys_preadv(int fd, \ + const struct iovec *iovp, int iovcnt, \ + off_t offset); } +172 STD NOLOCK { ssize_t sys_pwritev(int fd, \ + const struct iovec *iovp, int iovcnt, \ + off_t offset); } +173 STD NOLOCK { ssize_t sys_pad_pread(int fd, void *buf, \ size_t nbyte, int pad, off_t offset); } -174 STD NOLOCK { ssize_t sys_pwrite(int fd, const void *buf, \ +174 STD NOLOCK { ssize_t sys_pad_pwrite(int fd, const void *buf, \ size_t nbyte, int pad, off_t offset); } 175 UNIMPL ntp_gettime 176 UNIMPL ntp_adjtime @@ -346,14 +354,14 @@ 195 STD NOLOCK { int sys_setrlimit(int which, \ const struct rlimit *rlp); } 196 OBSOL ogetdirentries48 -197 STD { void *sys_mmap(void *addr, size_t len, int prot, \ +197 STD { void *sys_pad_mmap(void *addr, size_t len, int prot, \ int flags, int fd, long pad, off_t pos); } 198 INDIR { quad_t sys___syscall(quad_t num, ...); } -199 STD NOLOCK { off_t sys_lseek(int fd, int pad, off_t offset, \ +199 STD NOLOCK { off_t sys_pad_lseek(int fd, int pad, off_t offset, \ int whence); } -200 STD { int sys_truncate(const char *path, int pad, \ +200 STD { int sys_pad_truncate(const char *path, int pad, \ off_t length); } -201 STD { int sys_ftruncate(int fd, int pad, off_t length); } +201 STD { int sys_pad_ftruncate(int fd, int pad, off_t length); } 202 STD { int sys_sysctl(const int *name, u_int namelen, \ void *old, size_t *oldlenp, void *new, \ size_t newlen); } @@ -452,10 +460,10 @@ 264 STD { int sys_fhopen(const fhandle_t *fhp, int flags); } 265 UNIMPL 266 UNIMPL -267 STD NOLOCK { ssize_t sys_preadv(int fd, \ +267 STD NOLOCK { ssize_t sys_pad_preadv(int fd, \ const struct iovec *iovp, int iovcnt, \ int pad, off_t offset); } -268 STD NOLOCK { ssize_t sys_pwritev(int fd, \ +268 STD NOLOCK { ssize_t sys_pad_pwritev(int fd, \ const struct iovec *iovp, int iovcnt, \ int pad, off_t offset); } 269 STD NOLOCK { int sys_kqueue(void); } @@ -479,8 +487,9 @@ 284 STD { int sys_setresgid(gid_t rgid, gid_t egid, \ gid_t sgid); } 285 OBSOL sys_omquery -286 STD { void *sys_mquery(void *addr, size_t len, int prot, \ - int flags, int fd, long pad, off_t pos); } +286 STD { void *sys_pad_mquery(void *addr, size_t len, \ + int prot, int flags, int fd, long pad, \ + off_t pos); } 287 STD NOLOCK { int sys_closefrom(int fd); } 288 STD { int sys_sigaltstack(const struct sigaltstack *nss, \ struct sigaltstack *oss); } diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 51861367a45..3f7403980d0 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls.c,v 1.353 2021/10/02 14:05:10 semarie Exp $ */ +/* $OpenBSD: vfs_syscalls.c,v 1.354 2021/12/23 18:50:31 guenther Exp $ */ /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */ /* @@ -1903,7 +1903,6 @@ sys_lseek(struct proc *p, void *v, register_t *retval) { struct sys_lseek_args /* { syscallarg(int) fd; - syscallarg(int) pad; syscallarg(off_t) offset; syscallarg(int) whence; } */ *uap = v; @@ -1934,6 +1933,20 @@ sys_lseek(struct proc *p, void *v, register_t *retval) return (error); } +#if 1 +int +sys_pad_lseek(struct proc *p, void *v, register_t *retval) +{ + struct sys_pad_lseek_args *uap = v; + struct sys_lseek_args unpad; + + SCARG(&unpad, fd) = SCARG(uap, fd); + SCARG(&unpad, offset) = SCARG(uap, offset); + SCARG(&unpad, whence) = SCARG(uap, whence); + return sys_lseek(p, &unpad, retval); +} +#endif + /* * Check access permissions. */ @@ -2802,7 +2815,6 @@ sys_truncate(struct proc *p, void *v, register_t *retval) { struct sys_truncate_args /* { syscallarg(const char *) path; - syscallarg(int) pad; syscallarg(off_t) length; } */ *uap = v; struct vnode *vp; @@ -2837,7 +2849,6 @@ sys_ftruncate(struct proc *p, void *v, register_t *retval) { struct sys_ftruncate_args /* { syscallarg(int) fd; - syscallarg(int) pad; syscallarg(off_t) length; } */ *uap = v; struct vattr vattr; @@ -2868,6 +2879,30 @@ bad: return (error); } +#if 1 +int +sys_pad_truncate(struct proc *p, void *v, register_t *retval) +{ + struct sys_pad_truncate_args *uap = v; + struct sys_truncate_args unpad; + + SCARG(&unpad, path) = SCARG(uap, path); + SCARG(&unpad, length) = SCARG(uap, length); + return sys_truncate(p, &unpad, retval); +} + +int +sys_pad_ftruncate(struct proc *p, void *v, register_t *retval) +{ + struct sys_pad_ftruncate_args *uap = v; + struct sys_ftruncate_args unpad; + + SCARG(&unpad, fd) = SCARG(uap, fd); + SCARG(&unpad, length) = SCARG(uap, length); + return sys_ftruncate(p, &unpad, retval); +} +#endif + /* * Sync an open file. */ @@ -3241,7 +3276,6 @@ sys_pread(struct proc *p, void *v, register_t *retval) syscallarg(int) fd; syscallarg(void *) buf; syscallarg(size_t) nbyte; - syscallarg(int) pad; syscallarg(off_t) offset; } */ *uap = v; struct iovec iov; @@ -3270,7 +3304,6 @@ sys_preadv(struct proc *p, void *v, register_t *retval) syscallarg(int) fd; syscallarg(const struct iovec *) iovp; syscallarg(int) iovcnt; - syscallarg(int) pad; syscallarg(off_t) offset; } */ *uap = v; struct iovec aiov[UIO_SMALLIOV], *iov = NULL; @@ -3303,7 +3336,6 @@ sys_pwrite(struct proc *p, void *v, register_t *retval) syscallarg(int) fd; syscallarg(const void *) buf; syscallarg(size_t) nbyte; - syscallarg(int) pad; syscallarg(off_t) offset; } */ *uap = v; struct iovec iov; @@ -3332,7 +3364,6 @@ sys_pwritev(struct proc *p, void *v, register_t *retval) syscallarg(int) fd; syscallarg(const struct iovec *) iovp; syscallarg(int) iovcnt; - syscallarg(int) pad; syscallarg(off_t) offset; } */ *uap = v; struct iovec aiov[UIO_SMALLIOV], *iov = NULL; @@ -3354,3 +3385,57 @@ sys_pwritev(struct proc *p, void *v, register_t *retval) iovec_free(iov, iovcnt); return (error); } + +#if 1 +int +sys_pad_pread(struct proc *p, void *v, register_t *retval) +{ + struct sys_pad_pread_args *uap = v; + struct sys_pread_args unpad; + + SCARG(&unpad, fd) = SCARG(uap, fd); + SCARG(&unpad, buf) = SCARG(uap, buf); + SCARG(&unpad, nbyte) = SCARG(uap, nbyte); + SCARG(&unpad, offset) = SCARG(uap, offset); + return sys_pread(p, &unpad, retval); +} + +int +sys_pad_preadv(struct proc *p, void *v, register_t *retval) +{ + struct sys_pad_preadv_args *uap = v; + struct sys_preadv_args unpad; + + SCARG(&unpad, fd) = SCARG(uap, fd); + SCARG(&unpad, iovp) = SCARG(uap, iovp); + SCARG(&unpad, iovcnt) = SCARG(uap, iovcnt); + SCARG(&unpad, offset) = SCARG(uap, offset); + return sys_preadv(p, &unpad, retval); +} + +int +sys_pad_pwrite(struct proc *p, void *v, register_t *retval) +{ + struct sys_pad_pwrite_args *uap = v; + struct sys_pwrite_args unpad; + + SCARG(&unpad, fd) = SCARG(uap, fd); + SCARG(&unpad, buf) = SCARG(uap, buf); + SCARG(&unpad, nbyte) = SCARG(uap, nbyte); + SCARG(&unpad, offset) = SCARG(uap, offset); + return sys_pwrite(p, &unpad, retval); +} + +int +sys_pad_pwritev(struct proc *p, void *v, register_t *retval) +{ + struct sys_pad_pwritev_args *uap = v; + struct sys_pwritev_args unpad; + + SCARG(&unpad, fd) = SCARG(uap, fd); + SCARG(&unpad, iovp) = SCARG(uap, iovp); + SCARG(&unpad, iovcnt) = SCARG(uap, iovcnt); + SCARG(&unpad, offset) = SCARG(uap, offset); + return sys_pwritev(p, &unpad, retval); +} +#endif diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c index 5d8570c2c12..0a31c622210 100644 --- a/sys/uvm/uvm_mmap.c +++ b/sys/uvm/uvm_mmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_mmap.c,v 1.166 2021/12/10 05:34:42 guenther Exp $ */ +/* $OpenBSD: uvm_mmap.c,v 1.167 2021/12/23 18:50:32 guenther Exp $ */ /* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */ /* @@ -122,7 +122,6 @@ sys_mquery(struct proc *p, void *v, register_t *retval) syscallarg(int) prot; syscallarg(int) flags; syscallarg(int) fd; - syscallarg(long) pad; syscallarg(off_t) pos; } */ *uap = v; struct file *fp; @@ -212,7 +211,6 @@ sys_mmap(struct proc *p, void *v, register_t *retval) syscallarg(int) prot; syscallarg(int) flags; syscallarg(int) fd; - syscallarg(long) pad; syscallarg(off_t) pos; } */ *uap = v; vaddr_t addr; @@ -439,6 +437,38 @@ out: return error; } +#if 1 +int +sys_pad_mquery(struct proc *p, void *v, register_t *retval) +{ + struct sys_pad_mquery_args *uap = v; + struct sys_mquery_args unpad; + + SCARG(&unpad, addr) = SCARG(uap, addr); + SCARG(&unpad, len) = SCARG(uap, len); + SCARG(&unpad, prot) = SCARG(uap, prot); + SCARG(&unpad, flags) = SCARG(uap, flags); + SCARG(&unpad, fd) = SCARG(uap, fd); + SCARG(&unpad, pos) = SCARG(uap, pos); + return sys_mquery(p, &unpad, retval); +} + +int +sys_pad_mmap(struct proc *p, void *v, register_t *retval) +{ + struct sys_pad_mmap_args *uap = v; + struct sys_mmap_args unpad; + + SCARG(&unpad, addr) = SCARG(uap, addr); + SCARG(&unpad, len) = SCARG(uap, len); + SCARG(&unpad, prot) = SCARG(uap, prot); + SCARG(&unpad, flags) = SCARG(uap, flags); + SCARG(&unpad, fd) = SCARG(uap, fd); + SCARG(&unpad, pos) = SCARG(uap, pos); + return sys_mmap(p, &unpad, retval); +} +#endif + /* * sys_msync: the msync system call (a front-end for flush) */ @@ -1105,6 +1135,8 @@ sys_kbind(struct proc *p, void *v, register_t *retval) /* a NULL paramp disables the syscall for the process */ if (paramp == NULL) { + if (pr->ps_kbind_addr != 0) + sigexit(p, SIGILL); pr->ps_kbind_addr = BOGO_PC; return 0; } diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 52356862c40..c6e4f1786ad 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kdump.c,v 1.144 2021/07/12 15:09:19 beck Exp $ */ +/* $OpenBSD: kdump.c,v 1.145 2021/12/23 18:50:32 guenther Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -62,9 +62,10 @@ #include #include #include +#include +#include #include #include -#include #include #include #include @@ -468,6 +469,10 @@ poctint(int arg) #define Phexlonglong Phexlong #define phexll NULL /* not actually used on LP64 */ +/* no padding before long long arguments, nor at end */ +#define PAD64 0 +#define END64 end_of_args + #else /* __LP64__ */ /* on ILP32, long long arguments are passed as two 32bit args */ @@ -491,6 +496,17 @@ phexll(long arg2) return (0); } +/* + * Some ILP32 archs naturally align off_t arguments to 8byte boundaries + * Get the compiler to tell if this arch is one of them. + */ +struct padding_test { + int padtest_one; + off_t padtest_two; +}; +#define PAD64 (offsetof(struct padding_test,padtest_two) == 8) +#define END64 (PAD64 ? PASS_LONGLONG : end_of_args) + #endif /* __LP64__ */ static int (*long_formatters[])(long) = { @@ -799,8 +815,12 @@ static const formatter scargs[][8] = { [SYS_nfssvc] = { Phexint, Pptr }, [SYS_getfh] = { Ppath, Pptr }, [SYS_sysarch] = { Pdecint, Pptr }, - [SYS_pread] = { Pfd, Pptr, Pbigsize, PAD, Poff_t }, - [SYS_pwrite] = { Pfd, Pptr, Pbigsize, PAD, Poff_t }, + [SYS_pread] = { Pfd, Pptr, Pbigsize, Poff_t, END64 }, + [SYS_pwrite] = { Pfd, Pptr, Pbigsize, Poff_t, END64 }, +#ifdef SYS_pad_pread + [SYS_pad_pread] = { Pfd, Pptr, Pbigsize, PAD, Poff_t }, + [SYS_pad_pwrite] = { Pfd, Pptr, Pbigsize, PAD, Poff_t }, +#endif [SYS_setgid] = { Gidname }, [SYS_setegid] = { Gidname }, [SYS_seteuid] = { Uidname }, @@ -809,10 +829,16 @@ static const formatter scargs[][8] = { [SYS_swapctl] = { Swapctlname, Pptr, Pdecint }, [SYS_getrlimit] = { Rlimitname, Pptr }, [SYS_setrlimit] = { Rlimitname, Pptr }, - [SYS_mmap] = { Pptr, Pbigsize, Mmapprotname, Mmapflagsname, Pfd, PAD, Poff_t }, - [SYS_lseek] = { Pfd, PAD, Poff_t, Whencename }, - [SYS_truncate] = { Ppath, PAD, Poff_t }, - [SYS_ftruncate] = { Pfd, PAD, Poff_t }, + [SYS_mmap] = { Pptr, Pbigsize, Mmapprotname, Mmapflagsname, Pfd, Poff_t, END64 }, + [SYS_lseek] = { Pfd, Poff_t, Whencename, END64 }, + [SYS_truncate] = { Ppath, Poff_t, END64 }, + [SYS_ftruncate] = { Pfd, Poff_t, END64 }, +#ifdef SYS_pad_mmap + [SYS_pad_mmap] = { Pptr, Pbigsize, Mmapprotname, Mmapflagsname, Pfd, PAD, Poff_t }, + [SYS_pad_lseek] = { Pfd, PAD, Poff_t, Whencename }, + [SYS_pad_truncate] = { Ppath, PAD, Poff_t }, + [SYS_pad_ftruncate] = { Pfd, PAD, Poff_t }, +#endif [SYS_sysctl] = { Pptr, Pcount, Pptr, Pptr, Pptr, Psize }, [SYS_mlock] = { Pptr, Pbigsize }, [SYS_munlock] = { Pptr, Pbigsize }, @@ -831,14 +857,21 @@ static const formatter scargs[][8] = { [SYS_msync] = { Pptr, Pbigsize, Msyncflagsname }, [SYS_pipe] = { Pptr }, [SYS_fhopen] = { Pptr, Openflagsname }, - [SYS_preadv] = { Pfd, Pptr, Pcount, PAD, Poff_t }, - [SYS_pwritev] = { Pfd, Pptr, Pcount, PAD, Poff_t }, + [SYS_preadv] = { Pfd, Pptr, Pcount, Poff_t, END64 }, + [SYS_pwritev] = { Pfd, Pptr, Pcount, Poff_t, END64 }, +#ifdef SYS_pad_preadv + [SYS_pad_preadv] = { Pfd, Pptr, Pcount, PAD, Poff_t }, + [SYS_pad_pwritev] = { Pfd, Pptr, Pcount, PAD, Poff_t }, +#endif [SYS_mlockall] = { Mlockallname }, [SYS_getresuid] = { Pptr, Pptr, Pptr }, [SYS_setresuid] = { Uidname, Uidname, Uidname }, [SYS_getresgid] = { Pptr, Pptr, Pptr }, [SYS_setresgid] = { Gidname, Gidname, Gidname }, - [SYS_mquery] = { Pptr, Pbigsize, Mmapprotname, Mmapflagsname, Pfd, PAD, Poff_t }, + [SYS_mquery] = { Pptr, Pbigsize, Mmapprotname, Mmapflagsname, Pfd, Poff_t, END64 }, +#ifdef SYS_pad_mquery + [SYS_pad_mquery] = { Pptr, Pbigsize, Mmapprotname, Mmapflagsname, Pfd, PAD, Poff_t }, +#endif [SYS_closefrom] = { Pfd }, [SYS_sigaltstack] = { Pptr, Pptr }, [SYS_shmget] = { Pkey_t, Pbigsize, Semgetname }, @@ -922,8 +955,11 @@ ktrsyscall(struct ktr_syscall *ktr, size_t ktrlen) } else if (ktr->ktr_code < nitems(scargs)) { const formatter *fmts = scargs[ktr->ktr_code]; int fmt; + int arg = 0; - while (narg && (fmt = *fmts) != 0) { + while (arg < narg && (fmt = *fmts) != 0) { + if (PAD64 && fmt == PASS_LONGLONG && (arg & 1)) + goto skip; if (sep) putchar(sep); sep = ','; @@ -934,9 +970,11 @@ ktrsyscall(struct ktr_syscall *ktr, size_t ktrlen) else if (long_formatters[-fmt](*ap)) sep = '\0'; fmts++; +skip: ap++; - narg--; + arg++; } + narg -= arg; } while (narg > 0) { @@ -1106,6 +1144,9 @@ doerr: if (fancy) { switch (code) { case SYS_lseek: +#ifdef SYS_pad_lseek + case SYS_pad_lseek: +#endif (void)printf("%lld", retll); if (retll < 0 || retll > 9) (void)printf("/%#llx", retll); -- 2.20.1