Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: [netbsd-11] src/sys



Module Name:    src
Committed By:   martin
Date:           Tue Aug 25 20:04:59 UTC 2026

Modified Files:
        src/sys/arch/alpha/alpha [netbsd-11]: syscall.c
        src/sys/arch/mips/mips [netbsd-11]: syscall.c
        src/sys/arch/riscv/riscv [netbsd-11]: syscall.c
        src/sys/kern [netbsd-11]: init_sysent.c makesyscalls.sh syscalls.c
            syscalls_autoload.c systrace_args.c
        src/sys/sys [netbsd-11]: syscall.h syscallargs.h systm.h

Log Message:
Pull up following revision(s) (requested by tls in ticket #437):

        sys/sys/systm.h: revision 1.307
        sys/sys/syscall.h: revision 1.330
        sys/kern/syscalls.c: revision 1.335
        sys/kern/syscalls_autoload.c: revision 1.51
        sys/kern/systrace_args.c: revision 1.57
        sys/arch/alpha/alpha/syscall.c: revision 1.46
        sys/arch/riscv/riscv/syscall.c: revision 1.7
        sys/arch/mips/mips/syscall.c: revision 1.52
        sys/kern/init_sysent.c: revision 1.347
        sys/kern/makesyscalls.sh: revision 1.189
        sys/sys/syscallargs.h: revision 1.313

Fix a longstanding bug on 64 bit ports with ABIs requiring sign-extension when returning 32-bit values in registers.  Alpha, MIPS N64, RISCV.

With these ABIs it is necessary for the syscall return code to manually
sign-extend all 32-bit return values.  If we don't, everything may look
just fine, until a syscall return value is spilled to the stack and then
reloaded.  At that point, the zero-extended form produced by C assignment
into the 64-bit register for return to userspace will be sign-extended
upon reload, producing a different, corrupt value which will fail comparisons.

This was observed with a getuid() != geteuid() deep inside sshd on N64, on an
unusual system that had some very large UIDs with bit 31 set - but is quite
difficult to reproduce with small tests, since register pressure and compiler
behavior determine whether the conditions necessary to trigger the bug will
exist.

The easiest way to see whether a new target needs this treatment is to
look at its GCC configuratrion; if its PROMOTE_MODE has UNSIGNEDP = 0
for SImode, the sign-extension in syscall() is necessary.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.45.8.1 src/sys/arch/alpha/alpha/syscall.c
cvs rdiff -u -r1.51 -r1.51.8.1 src/sys/arch/mips/mips/syscall.c
cvs rdiff -u -r1.6 -r1.6.2.1 src/sys/arch/riscv/riscv/syscall.c
cvs rdiff -u -r1.346 -r1.346.2.1 src/sys/kern/init_sysent.c
cvs rdiff -u -r1.187 -r1.187.8.1 src/sys/kern/makesyscalls.sh
cvs rdiff -u -r1.334 -r1.334.2.1 src/sys/kern/syscalls.c
cvs rdiff -u -r1.50 -r1.50.2.1 src/sys/kern/syscalls_autoload.c
cvs rdiff -u -r1.56 -r1.56.2.1 src/sys/kern/systrace_args.c
cvs rdiff -u -r1.329 -r1.329.2.1 src/sys/sys/syscall.h
cvs rdiff -u -r1.312 -r1.312.2.1 src/sys/sys/syscallargs.h
cvs rdiff -u -r1.306 -r1.306.4.1 src/sys/sys/systm.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index