For those building -current themselves, when you update past the commit
below you must be sure to build *and reboot to* a new kernel with the
change before you install a new libc or ld.so!

If you fail to do so then anything using the newer-than-kernel libc/ld.so
will coredump immediately, generally on the first mmap(2), and you'll need
to reboot to a bsd.rd or similar and put a matching kernel+libc+ld.so in
place.

This might be a good time to just install an official snapshot instead.

---------- Forwarded message ---------
From: Philip Guenther <guent...@cvs.openbsd.org>
Date: Thu, Dec 23, 2021 at 10:51 AM
Subject: CVS: cvs.openbsd.org: src
To: <source-chan...@cvs.openbsd.org>


CVSROOT:        /cvs
Module name:    src
Changes by:     guent...@cvs.openbsd.org        2021/12/23 11:50:33

Modified files:
        sys/kern       : syscalls.master vfs_syscalls.c kern_ktrace.c
                         kern_pledge.c
        sys/arch/sh/sh : trap.c
        sys/arch/hppa/hppa: trap.c
        sys/uvm        : uvm_mmap.c
        lib/libc/sys   : Makefile.inc
        libexec/ld.so  : Makefile loader.c
        libexec/ld.so/m88k: rtld_machine.c
        usr.bin/kdump  : kdump.c
Added files:
        libexec/ld.so  : syscall.h
Removed files:
        lib/libc/sys   : ftruncate.c lseek.c mmap.c mquery.c pread.c
                         preadv.c pwrite.c pwritev.c truncate.c
        libexec/ld.so/m88k: syscall.h
        libexec/ld.so/aarch64: syscall.h
        libexec/ld.so/alpha: syscall.h
        libexec/ld.so/amd64: syscall.h
        libexec/ld.so/arm: syscall.h
        libexec/ld.so/hppa: syscall.h
        libexec/ld.so/i386: syscall.h
        libexec/ld.so/mips64: syscall.h
        libexec/ld.so/powerpc: syscall.h
        libexec/ld.so/powerpc64: syscall.h
        libexec/ld.so/riscv64: syscall.h
        libexec/ld.so/sh: syscall.h
        libexec/ld.so/sparc64: syscall.h

Log message:
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@

Reply via email to