Commit Graph

5985 Commits

Author SHA1 Message Date
simonb a6c0d32ea0 In the compat setitimer(2) calls, don't validate which timer is being
used since dosetitimer() does this anyway.  The compat functions hadn't
been updated since ITIMER_MONOTONIC was introduced, so they reported
that that ITIMER_MONOTONIC timer was invalid.
2021-02-18 12:54:03 +00:00
simonb 562353e3cc In netbsd32___mount50() zero out the native fs_args union before use so
we don't pass stack garbage to the lower layers in the MNT_GETARGS case.

Fixes random errors like "Bad address" from "mount -vv" with nfs mounts.
2021-02-16 14:47:20 +00:00
skrll 496e2b659f G/C some old code that was for acorn26 2021-02-01 19:31:34 +00:00
wiz 833b5e5e34 Fix syntax error 2021-01-19 08:10:17 +00:00
simonb 3daa70af17 The read/write/send/recv system calls return ssize_t because -1 is
returned on error.  Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
2021-01-19 03:41:22 +00:00
simonb 650cb29c0b KNF consistency: No parentheses are needed around the return value. 2021-01-19 03:20:13 +00:00
simonb 59099a5539 Whitespace nits. 2021-01-19 02:40:07 +00:00
simonb d625a73d15 Also print mmap return value and error code #ifdef DEBUG_MMAP. 2021-01-19 01:47:58 +00:00
simonb ec694a9214 s/u_intN_t/uintN_t/ 2021-01-18 23:14:22 +00:00
simonb 9742d8845a Handle the SIOCGNBRINFO_IN6 ioctl for compat32. ndp -a works with
compat32 now.
2021-01-17 10:50:01 +00:00
simonb ee136dc536 Remove unused LIMITCHECK() macro (now contained in netbsd32_rlimit.c). 2021-01-15 03:51:41 +00:00
simonb 66fc845698 Remove some blank lines to group the VND and FSS ioctls together. 2021-01-14 23:30:50 +00:00
simonb 2b90ec0a6e Handle the KFILTER_BYFILTER and KFILTER_BYNAME ioctls for compat32.
Passes "atf kernel/kqueue/t_ioctl".
2021-01-14 08:22:51 +00:00
simonb f89159bb0d Handle FSSIOCSET and FSSIOCGET; vndconfig(8) works with compat32 now.
XXX: FSSIOCSET50 and FSSIOCGET50 are not (yet) handled.
2021-01-14 08:00:45 +00:00
simonb 57e3a030a7 Handle rev 1.62 of kern/sys_lwp.c
make _lwp_park return the remaining time to sleep in the "ts" argument
   if it is a relative timestamp, as discussed in tech-kern.
for compat32.  Thanks skrll@ for some cleanup tips.
2021-01-14 02:51:52 +00:00
simonb e07073e587 Use netbsd32_* types instead of relying on __packed in the vnd ioctl
structures.  __packed didn't work on archs where 64-bit types were
64-bit aligned with a 32-bit ABI (eg MIPS n32).

OK mrg@
2021-01-14 02:43:04 +00:00
thorpej 1142b3532f malloc(9) -> kmem(9) 2020-12-19 22:10:56 +00:00
thorpej 30e584e46a Rewrite linux_sys_alarm() to use dogetitimer() / dosetitimer(), rather
than fiddling with process timers directly.
2020-12-04 00:26:16 +00:00
rin e07975543c Fix typo; s/__LP64/_LP64/ 2020-11-08 07:30:09 +00:00
pgoyette 7f78906306 Use opt_execfmt.h to get build options.
Only include elf32 hooks if we have elf32 defined and elf32 is not the
"native" emulation.  This allows for having compat_netbsd32 without
elf32 (although it's probably not too useful), and also enables arm's
old-ABI usage of compat_netbsd32.
2020-11-04 20:54:20 +00:00
christos f5c7935f9c PR/55780: Bernd Sieker: setsockopt in Linux emulation misses some options 2020-11-03 22:08:44 +00:00
pgoyette 575be43dde Separate the compat_netbsd32_coredump from the compat_netbsd32 and
coredump modules, into its own module.

Welcome to 7.99.75 !!!
2020-11-01 18:51:02 +00:00
mgorny 62a92db07d Fix compat with Linux programs that use longer namelen for sockets
Linux is less strict than NetBSD and permits namelen to be larger
than valid struct sockaddr_in*.  If this is the case, truncate the value
to the correct size, so that NetBSD networking does not return an error.

Reviewed by kamil
2020-10-24 09:01:56 +00:00
rin 7e5bbe7eb4 wait4(2): make error paths match with that of native wait4(2):
https://nxr.netbsd.org/xref/src/sys/kern/kern_exit.c#720
2020-10-15 23:06:06 +00:00
christos 0a6d6ce0fd TIOCGSID is used by tcgetsid() so it is not really compat :-)
This should reduce loading the compat module.
2020-10-10 15:59:41 +00:00
rin 94d6852a4a regen for getrandom(2) 2020-10-10 00:03:52 +00:00
rin 99d6145575 Teach about getrandom(2) to COMPAT_NETBSD32. 2020-10-10 00:00:54 +00:00
nia c32467e149 tty_43: Check a bitset from userspace is valid before shifting it
Passing a negative value to these legacy compat ioctls results in
left shift on a negative value which is undefined behaviour and results
in the tty (at least, possibly other things) locking up.

The argument to the ioctl should always be > 0. Return EINVAL otherwise.

While here, adjustments to code style to match current guidelines.

Found by UBSan.

Reported-by: syzbot+39cd551a05298b222756@syzkaller.appspotmail.com
2020-10-09 10:41:53 +00:00
christos 7c02b47ba1 make MAXTSIZ optional 2020-10-06 13:38:49 +00:00
msaitoh 811d5a8b03 s/parition/partition/ 2020-09-29 02:49:55 +00:00
mrg b8b349010a remove __packed from struct netbsd32_lsdisable. the structure
is already properly aligned (the embedded int64 already has
align(4) marker applied where needed.)

same size structure generated.
2020-09-07 03:12:51 +00:00
riastradh 9fc453562f Round of uvm.h cleanup.
The poorly named uvm.h is generally supposed to be for uvm-internal
users only.

- Narrow it to files that actually need it -- mostly files that need
  to query whether curlwp is the pagedaemon, which should maybe be
  exposed by an external header.

- Use uvm_extern.h where feasible and uvm_*.h for things not exposed
  by it.  We should split up uvm_extern.h but this will serve for now
  to reduce the uvm.h dependencies.

- Use uvm_stat.h and #ifdef UVMHIST uvm.h for files that use
  UVMHIST(ubchist), since ubchist is declared in uvm.h but the
  reference evaporates if UVMHIST is not defined, so we reduce header
  file dependencies.

- Make uvm_device.h and uvm_swap.h independently includable while
  here.

ok chs@
2020-09-05 16:30:10 +00:00
thorpej c1a69249ed The conversion of FPU tracking to PCU rendered the fpcurlwp variable
unmaintained, which broke FP status info in the COMPAT_LINUX sigcontext.
Use the new API, which will at least be closer to correct.
2020-09-03 14:26:31 +00:00
christos c988d5c135 PR/55547: Dan Plassche: Fix BSD/OS binary emulation.
Centralize lcall sniffer and recognize the BSD/OS flavor.
2020-08-08 19:08:48 +00:00
christos bed7e9544b Fix the OTIOCGETD emulation. Line discipline 0 is NTTYDISC. 2020-08-08 19:04:58 +00:00
simonb 41b59d1a20 Add lockstat(1) ioctl handling.
mrg@: "looks ok."
2020-07-21 05:33:51 +00:00
maxv fdf397881b don't include opt_user_ldt.h when it is not needed 2020-07-19 13:55:08 +00:00
jmcneill 3e4f2cbfff Add BIOCSETWF32 (bpf) 2020-07-18 12:46:19 +00:00
msaitoh 0be10c48cf Don't accept negative value.
Reported-by: syzbot+e71a77402d6668f1868d@syzkaller.appspotmail.com
2020-07-16 15:02:08 +00:00
christos 5a80c6a868 sync with mount.h, always use the structure size. 2020-07-03 19:00:01 +00:00
jdolecek 6471d774f6 don't overallocate (follows similar change to compat/sys/statvfs.h) 2020-07-03 18:49:37 +00:00
christos d6527692c4 don't overallocate (requested by maxv@) 2020-07-03 14:08:53 +00:00
christos c3242d1442 Fix struct entry size (thanks kre@) 2020-06-28 14:37:53 +00:00
christos 28e771c9fc Ignore the supplied size, and always use the argument size that we know.
Found by maxv@
2020-06-27 15:49:30 +00:00
maxv f2af77cb3a Yet another idiotic compat syscall that was developed with literally zero
test made. Simply invoking this syscall with _valid parameters_ triggers a
fatal fault, because the kernel tries to write to userland addresses.

With specially-crafted parameters it is easy to completely escalate
privileges into the kernel.

Also the size of the allocation is just obviously wrong, but it looks like
the callers are even more wrong, so not gonna fix it for now.

Reported-by: syzbot+b05096f3114b2820d81c@syzkaller.appspotmail.com
2020-06-27 07:00:43 +00:00
jdolecek 039c10d987 reduce stack usage in compat_60_ptmget_ioctl() - allocate struct ptmget
via kmem_alloc()
2020-06-24 17:47:52 +00:00
jdolecek 3e5fbb6583 remove special handling for symbolic links for COMPAT_43 lstat, it's
not necessary; this removes the only places in kernel which did namei
LOOKUP with LOCKPARENT

fixes diagnostic KASSERT() in namei() code

Reported-by: syzbot+628382ecf1438e53d08d@syzkaller.appspotmail.com
2020-06-24 10:28:16 +00:00
roy a8f6cc004f Add nd6.h compat header 2020-06-12 15:25:26 +00:00
roy b05648aa26 Remove in-kernel handling of Router Advertisements
This is much better handled by a user-land tool.
Proposed on tech-net here:
https://mail-index.netbsd.org/tech-net/2020/04/22/msg007766.html

Note that the ioctl SIOCGIFINFO_IN6 no longer sets flags. That now
needs to be done using the pre-existing SIOCSIFINFO_FLAGS ioctl.

Compat is fully provided where it makes sense, but trying to turn on
RA handling will obviously throw an error as it no longer exists.

Note that if you use IPv6 temporary addresses, this now needs to be
turned on in dhcpcd.conf(5) rather than in sysctl.conf(5).
2020-06-12 11:04:44 +00:00
ad ba90a6ba38 Counter tweaks:
- Don't need to count anonpages+filepages any more; clean+unknown+dirty for
  each kind of page can be summed to get the totals.

- Track the number of free pages with a counter so that it's one less thing
  for the allocator to do, which opens up further options there.

- Remove cpu_count_sync_one().  It has no users and doesn't save a whole lot.
  For the cheap option, give cpu_count_sync() a boolean parameter indicating
  that a cached value is okay, and rate limit the updates for cached values
  to hz.
2020-06-11 22:21:05 +00:00