Skip to content

Commit 1d60349

Browse files
author
guenther
committed
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@
1 parent 72ad568 commit 1d60349

34 files changed

+319
-1392
lines changed

lib/libc/sys/Makefile.inc

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $OpenBSD: Makefile.inc,v 1.160 2021/06/11 10:29:33 kettenis Exp $
1+
# $OpenBSD: Makefile.inc,v 1.161 2021/12/23 18:50:32 guenther Exp $
22
# $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $
33
# @(#)Makefile.inc 8.1 (Berkeley) 6/17/93
44

@@ -16,9 +16,9 @@ SRCS+= posix_madvise.c pthread_sigmask.c \
1616
w_clock_gettime.c w_gettimeofday.c microtime.c
1717

1818
# glue for compat with old syscall interfaces.
19-
SRCS+= ftruncate.c lseek.c mquery.c mmap.c ptrace.c semctl.c truncate.c \
19+
SRCS+= ptrace.c semctl.c \
2020
timer_create.c timer_delete.c timer_getoverrun.c timer_gettime.c \
21-
timer_settime.c pread.c preadv.c pwrite.c pwritev.c
21+
timer_settime.c
2222

2323
# stack protector helper functions
2424
SRCS+= stack_protector.c
@@ -33,11 +33,11 @@ CANCEL= accept accept4 \
3333
msgrcv msgsnd msync \
3434
nanosleep \
3535
open openat \
36-
poll ppoll pselect \
36+
poll ppoll pread preadv pselect pwrite pwritev \
3737
read readv recvfrom recvmsg \
3838
select sendmsg sendto \
3939
wait4 write writev
40-
SRCS+= ${CANCEL:%=w_%.c} w_pread.c w_preadv.c w_pwrite.c w_pwritev.c
40+
SRCS+= ${CANCEL:%=w_%.c}
4141

4242
# modules with default implementations on all architectures, unless overridden
4343
# below:
@@ -50,17 +50,17 @@ ASM= __semctl.o __syscall.o __thrsigdivert.o \
5050
faccessat.o fchdir.o fchflags.o fchmod.o fchmodat.o fchown.o \
5151
fchownat.o fhopen.o fhstat.o fhstatfs.o \
5252
flock.o fpathconf.o fstat.o fstatat.o fstatfs.o \
53-
futex.o futimens.o futimes.o \
53+
ftruncate.o futex.o futimens.o futimes.o \
5454
getentropy.o getdents.o getfh.o getfsstat.o \
5555
getgroups.o getitimer.o getpeername.o getpgid.o \
5656
getpriority.o getresgid.o getresuid.o \
5757
getrlimit.o getrusage.o getsid.o getsockname.o \
5858
getsockopt.o ioctl.o \
5959
kevent.o kill.o kqueue.o ktrace.o lchown.o \
60-
link.o linkat.o listen.o lstat.o madvise.o \
61-
minherit.o mkdir.o mkdirat.o mkfifo.o mkfifoat.o \
62-
mknod.o mknodat.o mlock.o mlockall.o mount.o mprotect.o \
63-
msgctl.o msgget.o munlock.o munlockall.o munmap.o \
60+
link.o linkat.o listen.o lseek.o lstat.o \
61+
madvise.o minherit.o mkdir.o mkdirat.o mkfifo.o mkfifoat.o \
62+
mknod.o mknodat.o mlock.o mlockall.o mmap.o mount.o mprotect.o \
63+
mquery.o msgctl.o msgget.o munlock.o munlockall.o munmap.o \
6464
nfssvc.o \
6565
pathconf.o pipe.o pipe2.o pledge.o profil.o \
6666
quotactl.o \
@@ -73,7 +73,9 @@ ASM= __semctl.o __syscall.o __thrsigdivert.o \
7373
settimeofday.o setuid.o shmat.o shmctl.o shmdt.o \
7474
shmget.o shutdown.o sigaltstack.o socket.o \
7575
socketpair.o stat.o statfs.o swapctl.o symlink.o symlinkat.o \
76-
sysarch.o sysctl.o thrkill.o unlink.o unlinkat.o \
76+
sysarch.o sysctl.o \
77+
thrkill.o truncate.o \
78+
unlink.o unlinkat.o \
7779
unmount.o unveil.o utimensat.o utimes.o utrace.o
7880

7981
SRCS+= ${SRCS_${MACHINE_CPU}}

lib/libc/sys/ftruncate.c

Lines changed: 0 additions & 48 deletions
This file was deleted.

lib/libc/sys/lseek.c

Lines changed: 0 additions & 48 deletions
This file was deleted.

lib/libc/sys/mmap.c

Lines changed: 0 additions & 49 deletions
This file was deleted.

lib/libc/sys/mquery.c

Lines changed: 0 additions & 23 deletions
This file was deleted.

lib/libc/sys/pread.c

Lines changed: 0 additions & 50 deletions
This file was deleted.

lib/libc/sys/preadv.c

Lines changed: 0 additions & 50 deletions
This file was deleted.

lib/libc/sys/pwrite.c

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)