275903 Commits

Author SHA1 Message Date
jmcneill
5b81bbd6c0 Apply similar fix from gic.c that fixed "left shift of 255 by 24 places
cannot be represented in type 'int'" warnings from UBSan.
2020-04-13 12:14:55 +00:00
jmcneill
0078d67e22 Fix "left shift of 255 by 24 places cannot be represented in type 'int'"
warning from UBSan.
2020-04-13 12:14:04 +00:00
jmcneill
3d5831c7f9 Work around a compiler issue when building on aarch64 with KUBSAN. 2020-04-13 12:08:05 +00:00
maxv
d569689e5d Add KUBSAN. 2020-04-13 11:44:20 +00:00
skrll
15572d36c9 Handle "no count" properly in db_kernhist_print_cmd 2020-04-13 11:43:27 +00:00
jdolecek
5e41e58686 unhook umass_isdata.c from here too 2020-04-13 11:27:22 +00:00
simonb
1c61f00504 Add xref to umodem(4). Mistake picked up by wizd(8), but somewhat
unexpectedly it didn't correct the reference to the one I meant but
got wrong.  Need to remember to file a bug report against wizd(8).
2020-04-13 11:17:27 +00:00
jdolecek
c61cfedcc1 fix use-after-free for ata xfer on bio submission found by KASAN
driver ata_bio hooks read parts of the xfer after ata_exec_xfer()
call in order to determine return value, change so that the hook
doesn't return any value - callers do not care already,
as all I/O requests are asynchronous

this problem was uncovered by recent change for wd(4) to not hold
wd mutex during ata_bio call, the interrupt for the xfer might
thus actually fire immediately

adjust also ata_exec_command driver hooks similarily - remove all
completion and waiting logic from drivers, upper layer ata code
using AT_WAIT/AT_POLL changed to call ata_wait_cmd() itself

PR kern/55169 by Nick Hudson
2020-04-13 10:49:34 +00:00
maxv
f2ff8d2611 Make KASAN compatible with LLVM. Same as GCC, except that LLVM aggressively
inlines the shadow checks, and this causes problems at boot time; so we
pass -asan-instrumentation-with-call-threshold=0 to force callbacks instead
of inlines.
2020-04-13 09:34:02 +00:00
jdolecek
01fe8969c6 remove wd* at umass?, it was dropped 2020-04-13 09:30:42 +00:00
jdolecek
28c26a1cc2 note removal of ISD-ATA for umass(4) 2020-04-13 09:28:14 +00:00
jdolecek
63933e9518 remove obsolete support for ISD-ATA umass(4) adapters 2020-04-13 09:26:43 +00:00
jdolecek
9bf815cd66 drop note about wd not being supported for umass 2020-04-13 09:18:10 +00:00
jdolecek
a6db9077db remove the In-System design note, related code is about to be dropped and
it doesn't make sense to have a note about things we don't support
2020-04-13 09:15:54 +00:00
wiz
6618bd8ba0 Remove superfluous whitespace & macros. 2020-04-13 08:59:14 +00:00
wiz
5f0ae7a9b4 Fix date. Remove Xr to non-existent modem(4). Serial comma. Use more macros. 2020-04-13 08:46:39 +00:00
wiz
0e961a0fbe Bump date for previous 2020-04-13 08:45:11 +00:00
skrll
d2599c324c Trailing whitespace 2020-04-13 08:05:22 +00:00
maxv
babb6cb124 constify 2020-04-13 08:05:02 +00:00
maxv
ca0e57e059 Add KASAN instrumentation on on-stack VLAs, same as amd64. 2020-04-13 07:32:36 +00:00
skrll
fe8087d6bb Oops, forgot the empty macro version of UVMHIST_CALLARGS 2020-04-13 07:11:08 +00:00
maxv
72d0b9e79b Add KASAN-DMA support on aarch64, same as amd64. Discussed with skrll@. 2020-04-13 07:09:50 +00:00
maxv
802484fb54 Note PAC and BTI. 2020-04-13 06:24:52 +00:00
maxv
c555b23ca7 Meant to do a store here, not a load. Ie we want to replace the initial
weak key by the stronger one we just generated.

Rototilled this place too many times.
2020-04-13 06:02:03 +00:00
maxv
2ddb9fdee7 Add support for Branch Target Identification (BTI).
On the executable pages that have the GP (Guarded Page) bit, the semantic
of the "br" and "blr" instructions is changed: the CPU expects the first
instruction of the jump/call target to be "bti", and faults if it isn't.

We add the GP bit on the kernel .text pages (and incidentally the .rodata
pages, but we don't care). The compiler adds a "bti c" instruction at the
beginning of each C function. We modify the ENTRY() macros to manually add
"bti c" in the asm functions.

cpuswitch.S needs a specific change: with "br x27" the CPU expects "bti j",
which is bad because the functions begin with "bti c"; switch to "br x16",
for the CPU to accept "bti c".

BTI helps defend against JOP/COP. Tested on Qemu.
2020-04-13 05:40:25 +00:00
chs
328da78dac slightly change and fix the semantics of pool_set*wat(), pool_sethardlimit()
and pool_prime() (and their pool_cache_* counterparts):

 - the pool_set*wat() APIs are supposed to specify thresholds for the count of
   free items in the pool before pool pages are automatically allocated or freed
   during pool_get() / pool_put(), whereas pool_sethardlimit() and pool_prime()
   are supposed to specify minimum and maximum numbers of total items
   in the pool (both free and allocated).  these were somewhat conflated
   in the existing code, so separate them as they were intended.

 - change pool_prime() to take an absolute number of items to preallocate
   rather than an increment over whatever was done before, and wait for
   any memory allocations to succeed.  since pool_prime() can no longer fail
   after this, change its return value to void and adjust all callers.

 - pool_setlowat() is documented as not immediately attempting to allocate
   any memory, but it was changed some time ago to immediately try to allocate
   up to the lowat level, so just fix the manpage to describe the current
   behaviour.

 - add a pool_cache_prime() to complete the API set.
2020-04-13 00:27:16 +00:00
christos
97cf9247a5 make sure that 0 length files get their extattrs cleaned up on deletion
(there was an optimization to not call truncate if size == 0).
2020-04-12 23:52:20 +00:00
christos
44988dfe00 put back the MODULAR attributes accidentally removed. 2020-04-12 22:06:17 +00:00
jdolecek
edaf68a84d convert to bus_dma(9)
simplify and fix error handling in xbd_handler(), expect backend
to not use the grant once request is finished, and avoid leaking
bounce buffer when the request using it happens to end with error

in xbd_diskstart() only do the RING_PUSH_REQUESTS_AND_CHECK_NOTIFY()
when actually the request was pushed successfully
2020-04-12 20:17:36 +00:00
christos
576580f188 Oops missed one more NULL -> NOCRED 2020-04-12 19:56:14 +00:00
jdolecek
dc571659e3 add KASSERT() for unaligned case to make sure it indeed happens only
for requests via physio
2020-04-12 18:14:09 +00:00
leot
b3e8ee064c Hack removed in src/external/bsd/nvi/usr.bin/nvi/Makefile,-r1.21
It is no longer needed, per PR bin/54656.
2020-04-12 17:49:00 +00:00
martin
43c6dc4bfb Remove no longer needed workaround for PR/54656. 2020-04-12 17:28:57 +00:00
tsutsui
e68b02666c Fix typo. 2020-04-12 17:13:29 +00:00
jdolecek
928ca612c6 fix wapbl_discard() to actually discard the queued bufs properly - need
to set BC_INVAL for them, and also need to explicitly remove them
from the BQ_LOCKED queue

fixes DIAGNOSTIC panic when force unmounting unresponsive disk device
PR kern/51178 by Michael van Elst
2020-04-12 17:02:52 +00:00
christos
3df74130fb delete debugging printf. 2020-04-12 15:55:53 +00:00
skrll
e4535b97c1 Use UVMHIST_CALLARGS 2020-04-12 15:36:18 +00:00
jdolecek
f34e84b48d move IFNET_UNLOCK() immediatelly after xennet_stop() call in detach,
doesn't need to be held for the disestablish
2020-04-12 13:57:07 +00:00
jdolecek
50cec821c5 fix locking against myself panic in xennet_stop() on 'ifconfig xennet0 down'
xennet_stop() is called with IFNET already held
2020-04-12 13:55:06 +00:00
christos
cbdaa54f3d change ' \t' to '\t' 2020-04-12 13:37:12 +00:00
christos
26abce9608 Change STD[:random-whitespace:]RUMP to STD\tRUMP 2020-04-12 13:30:16 +00:00
christos
edebee1e1b Pass NOCRED instead of NULL for credentials. These routines are supposed
to be accessing system ACL's on behalf of the kernel. This code appears
to be copied from FreeBSD, but there it works because in FreeBSD NOCRED
is 0, ours is -1. I guess nobody has used system extended attributes on
NetBSD yet :-)
2020-04-12 13:12:42 +00:00
roy
6530896d01 nd6: RTM_MISS reports RTA_AUTHOR once more
Just moves the logic to send RTM_MISS after the ICMP6 report as we
rely on that function to extract the requesting address.

Fixes PR kern/55164.
2020-04-12 12:13:52 +00:00
jdolecek
cc83ef657f fix race between wapbl_discard() and wapbl_biodone() on forced
unmount on shutdown with slow I/O device

wapbl_discard() needs to hold both wl_mtx and bufcache_lock while
manipulating wl_entries - the rw lock is not enough, because
wapbl_biodone() only takes wl_mtx while removing the finished entry
from list

wapbl_biodone() must take bufcache_lock before reading we->we_wapbl,
so it's blocked until wapbl_discard() finishes, and takes !wl path
appropriately

this is supposed to fix panic on shutdown:
[ 67549.6304123] forcefully unmounting / (/dev/wd0a)...
...
[ 67549.7272030] panic: mutex_vector_enter,510: uninitialized lock (lock=0xffffa722a4f4f5b0, from=ffffffff80a884fa)
...
[ 67549.7272030] wapbl_biodone() at netbsd:wapbl_biodone+0x4d
[ 67549.7272030] biointr() at netbsd:biointr+0x7d
[ 67549.7272030] softint_dispatch() at netbsd:softint_dispatch+0x12c
[ 67549.7272030] Xsoftintr() at netbsd:Xsoftintr+0x4f
2020-04-12 08:51:41 +00:00
maxv
6d94ff13c3 Add support for Pointer Authentication (PAC).
We use the "pac-ret" option, to sign the return instruction pointer on
function entry, and authenticate it on function exit. This acts as a
mitigation against ROP.

The authentication uses a per-lwp (secret) I-A key stored in the 128bit
APIAKey register and part of the lwp context. During lwp creation, the
kernel generates a random key, and during context switches, it installs
the key of the target lwp on the CPU.

Userland cannot read the APIAKey register directly. However, it can sign
its pointers with it, because the register is architecturally shared
between userland and the kernel. Although part of the CPU design, it is
a bit of an undesired behavior, because it allows to forge valid kernel
pointers from userland. To avoid that, we don't share the key with
userland, and rather switch it in EL0<->EL1 transitions. This means that
when userland executes, a different key is loaded in APIAKey than the one
the kernel uses. For now the userland key is a fixed 128bit zero value.

The DDB stack unwinder is changed to strip the authentication code from
the pointers in lr.

Two problems are known:

 * Currently the idlelwps' keys are not really secret. This is because
   the RNG is not yet available when we spawn these lwps. Not overly
   important, but would be nice to fix with UEFI RNG.
 * The key switching in EL0<->EL1 transitions is not the most optimized
   code on the planet. Instead of checking aarch64_pac_enabled, it would
   be better to hot-patch the code at boot time, but there currently is
   no hot-patch support on aarch64.

Tested on Qemu.
2020-04-12 07:49:58 +00:00
jdolecek
432235c8f9 further tweaks for USB_PRODUCT_MICROSOFT_24GHZ_XCVR80 from PR kern/55161
remove case for USB_PRODUCT_MICROSOFT_24GHZ_XCVR70, likely needs similar
tweaks and can't really be added untested
2020-04-12 07:41:11 +00:00
maxv
0c76280ca7 Don't inline cprng_strong{32,64}(), so they can be called from asm. 2020-04-12 07:16:09 +00:00
mrg
978f119b92 base INSTALL kernel upon GENERIC with many "no ...". 2020-04-12 06:05:34 +00:00
simonb
cddaf0cb47 Add NetBSD CVS tag. 2020-04-12 02:04:12 +00:00
htodd
ee948d74b4 Remove ufs_wapbl.c from Makefile. 2020-04-12 01:39:57 +00:00