Commit Graph

260901 Commits

Author SHA1 Message Date
martin 48f4f2396c Bump date 2018-08-24 11:43:13 +00:00
martin bf2f242dcd Add support for remapping requested paths via a .bzredirect file.
Fixes PR 52772. Ok: mrg@
2018-08-24 11:41:16 +00:00
mrg 05225295cb fix output since protocol agnostic change went in.
XXX: i thought someone hooked this into atf already, please do :)
2018-08-24 10:04:41 +00:00
maxv 9533071f67 Note kASan support. 2018-08-24 05:39:04 +00:00
riastradh ab7ebb91dd opt_dtrace.h for KDTRACE_HOOKS. Use __nothing for empty expansion. 2018-08-24 03:25:01 +00:00
jmcneill fd68eca2c7 Remove unused file. 2018-08-24 02:10:46 +00:00
jmcneill 36105be28c Add MI EFI bootloader and AArch64 glue. 2018-08-24 02:01:06 +00:00
jmcneill c0afa15f08 Sprinkle __unused 2018-08-24 01:59:40 +00:00
jmcneill 1228fccb09 Deal with reserved memory ranges that start before mem start 2018-08-23 22:34:03 +00:00
skrll b080f9c147 Whitespace 2018-08-23 21:01:43 +00:00
skrll f2f585bf4c WIP checkpoint 2018-08-23 20:54:43 +00:00
jmcneill 740e40f459 Fix LOADADDR on aarch64 and use memmove for bcopy instead of memcpy 2018-08-23 19:01:22 +00:00
jmcneill b655919a97 Support loading read-only data sections. ARM64 ELF kernels need this. ok skrll@ 2018-08-23 17:35:42 +00:00
snj 101004f6a9 mark netbsd-6* as Terminated 2018-08-23 16:25:37 +00:00
jmcneill 8256152684 Add of_getprop_uint64 2018-08-23 13:24:44 +00:00
maxv 177c084b60 Add kASan redzones on pools and pool_caches. Also enable POOL_REDZONE
on DIAGNOSTIC.
2018-08-23 12:18:02 +00:00
maxv 3fc5b07399 Improve the detection on global variables, no need to round up. 2018-08-23 11:56:10 +00:00
maxv de34ad68d6 Fix buffer overflow, detected by kASan.
[    1.044878] kASan: Unauthorized Access In 0xffffffff804ec7e2: Addr 0xffffffff818a51e4 [2 bytes, read]
[    1.044878] #0 0xffffffff804ec7e2 in mskc_probe <netbsd>
[    1.044878] #1 0xffffffff80e92a77 in mapply <netbsd>
[    1.044878] #2 0xffffffff80e92e5f in config_search_loc <netbsd>
[    1.044878] #3 0xffffffff80e93fb5 in config_found_sm_loc <netbsd>
[    1.044878] #4 0xffffffff802ca9ea in pci_probe_device <netbsd>
[    1.044878] #5 0xffffffff802cad97 in pci_enumerate_bus <netbsd>
[    1.044878] #6 0xffffffff802caf00 in pcirescan <netbsd>
[    1.044878] #7 0xffffffff802cb1ee in pciattach <netbsd>
[    1.044878] #8 0xffffffff80e93e5b in config_attach_loc <netbsd>
[    1.044878] #9 0xffffffff80e93fce in config_found_sm_loc <netbsd>
[    1.044878] #10 0xffffffff80271212 in mp_pci_scan <netbsd>
[    1.044878] #11 0xffffffff8022d9ee in mainbus_attach <netbsd>
[    1.044878] #12 0xffffffff80e93e5b in config_attach_loc <netbsd>
[    1.044878] #13 0xffffffff8021e38b in cpu_configure <netbsd>
[    1.044878] #14 0xffffffff814a7068 in main <netbsd>
2018-08-23 11:53:15 +00:00
christos 944c86d92b PR/53544: Add a dependency on the Makefile to fix incremental builds. 2018-08-23 06:21:37 +00:00
msaitoh f45d53144a Regen. 2018-08-23 05:19:11 +00:00
msaitoh 561e3fb162 - Add C62x to the descriptions of Intel C620 series devices.
- Add 0xa1ca for Intel C629 LPC or eSPI.
2018-08-23 05:18:45 +00:00
msaitoh 94d8805114 Remove inclusion of old m68k/sysctl.h 2018-08-23 04:04:34 +00:00
ozaki-r f549b43cb1 Don't call key_ismyaddr, which may sleep, in a pserialize read section
Use mutex here instead of pserialize because using mutex is simpler than
using psz+ref, which is another solution, and key_checkspidup isn't called in
any performance-sensitive paths.
2018-08-23 01:55:38 +00:00
jmcneill 34a1573c7d Support building libfdt with _STANDALONE 2018-08-23 01:25:22 +00:00
riastradh 6e759abcd0 Fix edge case of reference counting, oops.
PR kern/53441

XXX pullup-7
XXX pullup-8
2018-08-23 01:10:36 +00:00
riastradh a93746ddd6 Attempt to make sense of return values of nouveau_fence_wait.
PR kern/53441

XXX pullup-7
XXX pullup-8
2018-08-23 01:10:28 +00:00
riastradh 4d04cdce96 Defer nouveau_fence_unref until spin unlock.
- kfree while holding a spin lock is not a good idea.
- Make sure we GC every time we might signal fences.

PR kern/53441

XXX pullup-7
XXX pullup-8
2018-08-23 01:10:21 +00:00
riastradh bacf1c1229 Fences may last longer than their channels.
- Use a reference count on the nouveau_fence_chan object.
- Acquire it with kpreemption disabled.
- Use xcall to wait for kpreempt-disabled sections to complete.

PR kern/53441

XXX pullup-7
XXX pullup-8
2018-08-23 01:10:04 +00:00
riastradh ddf02d80a3 Rewrite nouveau_fence in an attempt to make it make sense.
PR kern/53441

XXX pullup-7
XXX pullup-8
2018-08-23 01:06:50 +00:00
kre 70696c0161 Fix (hopefully) the problem reported on current-users by Patrick Welche.
we had incorrect usage of setstackmark()/popstackmark()

There was an ancient idiom (imported from CSRG in 1993) where code
can do:
	setstackmark(&smark); loop until whatever condition {
		/* do lots of code */ popstackmark(&smark);
	} popstackmark(&smark);

The 1st (inner) popstackmark() resets the stack, conserving memory,
The 2nd one is needed just in case the "whatever condition" was never
true, and the first one was never executed.

This is (was) safe as all popstackmark() did was reset the stack.
That could be done over and over again with no harm.

That is, until 2000 when a fix from FreeBSD for another problem was
imported.  That connected all the stack marks as a list (so they can be
located).  That caused the problem, as the idiom was not changed, now
there is this list of marks, and popstackmark() was removing an entry.

It rarely (never?) caused any problems as the idiom was rarely used
(the shell used to do loops like above, mostly, without the inner
popstackmark()).  Further, the stack mark list is only ever used when
a memory block is realloc'd.

That is, until last weekend - with the recent set of changes.

Part of that copied code from FreeBSD introduced the idiom above
into more functions - functions used much more, and with a greater
possibility of stack marks being set on blocks that are realloc'd
and so cause the problem.   In the FreeBSD code, they changed the idiom,
and always do a setstackmark() immediately after the inner popstackmark().
But not for reasons related to a list of stack marks, as in the
intervening period, FreeBSD deleted that, but for another reason.

We do not have their issue, and I did not believe that their
updated idiom was needed (I did some analysis of exactly this issue -
just missed the important part!), and just continued using the old one.
Hence Patrick's core dump....

The solution used here is to split popstackmark() into 2 halves,
popstackmark() continues to do what it has (recently) done,
but is now implemented as a call of (a new func) rststackmark()
which does all the original work of popstackmark - but not removing
the entry from the stack mark list (which remains in popstackmark()).
Then in the idiom above, the inner popstackmark() turns into a call of
rststackmark() so the stack is reset, but the stack mark list is
unchanged.  Tail recursion elimination makes this essentially free.
2018-08-22 20:08:54 +00:00
christos 4a99e7bfda lint library for pmc is gone. 2018-08-22 17:38:38 +00:00
maxv 6398fab2c1 Unwind the stack on error, to get the full path that led to the illegal
access. Example of output:

kASan: Unauthorized Access In 0xffffffff80e6219c: Addr 0xffffbb007a39fd03 [1 byte, read]
#0 0xffffffff80e6219c in ras_purgeall <netbsd>
#1 0xffffffff80e62330 in sys_rasctl <netbsd>
#2 0xffffffff80265008 in syscall <netbsd>

(I manually added a one-byte stack read overflow in rasctl to demonstrate.)
2018-08-22 17:25:02 +00:00
maxv 2ef4334b7d Explicitly unpoison the stack when entering a softint.
Softints are the only place where we "discard" a part of the stack: we may
have left the thread without allowing the asan instrumentation to clear
the poison, and in this case, we can get false positives when we hit a
poisoned area of the stack while executing another handler within the same
softint thread.

(I was actually getting a rare false positive in ip6intr.)
2018-08-22 17:04:36 +00:00
christos 008bce6ffe - opt_kasan.h is included from <sys/asan.h>
- now that we are not using inlines, we need one more ifdef.
2018-08-22 14:12:30 +00:00
christos daac777442 - since we include asan.h unconditionally now, make sure opt_kasan.h is
included here, following the practice from other header files.
- don't use inline functions, adds complexity (and broke the build)
2018-08-22 14:11:26 +00:00
rin 4cef75f3f2 Explicitly disable v3d, pixelvalve, and hvs for bcm283x at the moment.
When these devices or hdmi are enabled, firmware turns off GPU functionality of
VideoCore, expecting OS drivers handle it appropriately:

https://github.com/raspberrypi/firmware/issues/763

This breaks userland applications using /dev/vchiq, such as omxplayer.

XXX We need enable them back when we import vc4 drm driver.

Fix PR port-evbarm/52984 and
PR port-arm/53042.

OK jmcneill, skrll
2018-08-22 13:16:41 +00:00
maxv 740156e942 Add back the KASAN ifdefs in kern_malloc until we sort out the type issue,
and fix sys/asan.h. Tested on i386, amd64 and amd64-kasan.
2018-08-22 12:42:06 +00:00
kre 1191b9bc38 Temporarily disable the dummy inline funcs, and replace them with
__nothing until maxv sorts out the type issues - kern_malloc()
(for historical reasons) takes an unsigned long parameter, not a
size_t - on 64 bit arch's this makes no difference (size_t is unsigned
long) but that's not true on 32 bit archs (or not all of them anyway).

This should unbreak the i386 build (others?) - hopefully without
damaging anything too badly.    Note the type issues need fixing,
just making this change permanent is not the solution.
2018-08-22 12:14:29 +00:00
maxv 7c492317e5 Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
	shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
	shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
	shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
	     = [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
	shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
	              = 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
	              = 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.
2018-08-22 12:07:42 +00:00
martin 129023e38b Change __always_inline to simple __inline to unbreak the build. 2018-08-22 11:55:28 +00:00
maxv 5cb6db9d84 Actually add __unused on the functions themselves in case a .c file does
not use one function.
2018-08-22 10:09:21 +00:00
maxv 7f4e877eeb Reduce the number of KASAN ifdefs, suggested by Christos/Taylor. 2018-08-22 09:38:21 +00:00
maxv 66ac031ddb Fix the computation in kasan_shadow_map, we may need one more page because
of the rounddown.
2018-08-22 09:11:47 +00:00
skrll 6d3974352c Use banner 2018-08-22 07:47:33 +00:00
skrll abbc7c8263 Traiing whitespace 2018-08-22 07:43:02 +00:00
christos d8fc255716 Den't set SA_RESTART in the signal handler allowing the process to get
interrupted durning recv and exit (pointed out by kre@)
2018-08-22 06:31:37 +00:00
msaitoh fba7dcecac - SIOCGIFINDEX was added in 2013, but if_freenameindex(3) have not used it
for years. Use it to improve performance. Same as FreeBSD.
- KNF.
2018-08-22 03:12:31 +00:00
msaitoh 61e1eb0d0b - Cleanup for dynamic sysctl:
- Remove unused *_NAMES macros for sysctl.
  - Remove unused *_MAXID for sysctls.
- Move CTL_MACHDEP sysctl definitions for m68k into m68k/include/cpu.h and
  use them on all m68k machines.
2018-08-22 01:05:21 +00:00
kamil 93433c2a83 Mark kernel-asan as done (by maxv) 2018-08-21 23:34:56 +00:00
jmcneill 437c3bed20 Define BOOT_ELF64 for aarch64 2018-08-21 20:13:13 +00:00