Commit Graph

260833 Commits

Author SHA1 Message Date
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
jdolecek
989d36f08b (only commit message for rev 1.85, no actual change)
shuffle code in xbd_handler() response loop so that req_bp is never
touched for non I/O responses; unknown commands are now just skipped, also
without touching neither xbdreq, nor req_bp

add some KASSERTS() for xbdreq->req_nr_segments and xbdreq->req_bp,
and reset req_bp after it's processed to ensure the buf can never
be processed twice

intended to simplify debugging in cases like PR port-xen/53506
2018-08-21 18:55:08 +00:00
jdolecek
8c8c5a03ef *** empty log message *** 2018-08-21 18:45:16 +00:00
jdolecek
c5ba8f5c88 remove code handling buffers not aligned to 512-byte boundary, simply return
EINVAL straight away

the condition doesn't seem to be actually hit for normal boots and
tools like fsck, which is good thing since it allocated memory
separately for each such I/O
2018-08-21 18:31:55 +00:00
jdolecek
775e33e0fa avoid race condition between I/O submission in xbd_diskstart() and
interrupt handling in xbd_handler() - need to protect it with splbio()

fixes PR port-xen/53506 by Emmanuel Dreyfus, and likely also port-xen/53074
by Brad Spencer
2018-08-21 18:11:10 +00:00
christos
70aed070fa support SIGINFO 2018-08-21 15:37:33 +00:00
plunky
1834dc7936 Result of audit to check that mbuf length is checked before m_copydata()
and that any data supposedly copied out is valid before use.

prompted by maxv@, I have checked every usage of m_copydata() and made
the following corrections

hci_event.c:
	hci_event_command_compl()
		check that the packet does contain enough data for there to
		be a status code before noting possible failures.

	hci_event_num_compl_pkts()
		check that the packet does contain data to cover the
		stated number of handle/num pairs

l2cap_signal.c:
	l2cap_recv_signal()
		just ignore packets with not enough data rather than
		trying to reject them (may not have cmd.ident)

	l2cap_recv_command_rej()
		check we have a valid reason and/or data before use
2018-08-21 14:59:13 +00:00
bsiegert
83927ccc37 Fix two typos in the Sunxi thermal driver.
Noticed by rudolf in PR port-arm/53537.

ok jmcneill@
2018-08-21 14:09:41 +00:00
christos
ba5bbf0545 Add missing lint library, sort 2018-08-21 13:00:16 +00:00
christos
39fdb694cb regen 2018-08-21 11:47:37 +00:00
christos
3310f921b5 Unlike gnu sed our sed does not recognize inline labels (separated by
semi-colons) so split the lines, and make sure that command lists end
with a semi-colon.
2018-08-21 11:45:23 +00:00
christos
4d65f54cf8 add new tests, sort 2018-08-21 11:07:40 +00:00
christos
510866dcf6 mark failed 2018-08-21 11:04:49 +00:00
christos
1cd154f24d should terminate and does with ktrace, but it does not normally. 2018-08-21 11:03:27 +00:00
christos
fd6a62a9fd Now add the file I really meant to add. 2018-08-21 10:41:00 +00:00
christos
1d33257c91 revert copyright change. 2018-08-21 10:39:21 +00:00
christos
a80aa007a5 more tests 2018-08-21 10:38:09 +00:00
rin
0ed1205e68 Correctly report memory size, not clock rate when VERBOSE_INIT_ARM. 2018-08-21 08:45:17 +00:00
msaitoh
1b96770f4a rumpdefs.h, rumperr.h and rumperrno2host.h are generated from makerumpdefs.sh.
Don't edit those files directly. Use __inline instead of inline in the
script file. OK'd by christos.
2018-08-21 08:22:33 +00:00