On Thu, Jul 20, 2023 at 10:59 PM Theo de Raadt <dera...@openbsd.org> wrote:
> Andrew Hewus Fresh <and...@afresh1.com> wrote: > > > One thing to note, on the advice of miod@, I adjusted the mapping of > > size_t from u_int to u_long, but that means we no longer recognize > > getlogin_r. When I asked, miod@ suggested that syscalls.master was > > confused. > > > > $ grep getlogin_r /usr/src/sys/kern/syscalls.master /usr/include/unistd.h > > /usr/src/sys/kern/syscalls.master:141 STD { int > sys_getlogin_r(char *namebuf, u_int namelen); } > > /usr/include/unistd.h:int getlogin_r(char *, size_t) > > That's quite a surprise. > > syscalls.master will need to be changed, which will change > struct sys_getlogin_r_args, which is used inside sys_getlogin_r() in > kern_prot.c. Don't get fooled by the advisory /* */ block you see > there, it is using the generated struct. But the offset to load the > field isn't changing, and luckily the incorrect field is smaller than > the correct field, so I *think* there is no major ABI crank needed. > Yeah, at least for syscall args a u_int and a size_t both get passed in a register-sized space on all our platforms' ABIs, so sys_getlogin_r_args doesn't actually change size or offsets. (If it was off_t or long long vs an int or long-sized arg, that would be different, of course, on 32bit archs, but this change is in the clear.) It does mean the syscall is implicitly reducing the len argument mod 2^32 on ILP32 archs, so it may fail with ERANGE if passed a 4GB buffer when it should succeed, but I don't think that merits any sort of syspatch or such. Philip Guenther