258443 Commits

Author SHA1 Message Date
maxv
37402c2ad5 Remove references to m_copy in comments. 2018-04-29 07:13:10 +00:00
maxv
31407650d2 Replace
m_copym(m, 0, M_COPYALL, M_DONTWAIT)
by
	m_copypacket(m, M_DONTWAIT)
when it is obvious that 'm' has M_PKTHDR set.
2018-04-29 07:05:13 +00:00
maxv
d0685720cb Add KASSERTs in the rcvif functions. 2018-04-29 06:52:55 +00:00
spz
3d2ae3570c avoid busy-waiting on a dead child 2018-04-29 05:36:04 +00:00
kamil
3e684ebdec Harden the NetBSD PT_TRACE_ME operation
You can't say to the parent of a process to start tracing if:
	(1) the parent is initproc,
	(2) the child is already traced.

Rationale:
 (1) - It has a side effect of being an anti-debugger functionality,
       as we cannot kill initproc (PID1) and reset the traced flag.
     - initproc is not a debugger, raising debugging events from a child
       to initproc can result in at least a stopped/hanging process
       in the system.
 (2) - It does not make sense to be simultanously traced by two debuggers.
     - It does not make sense to be traced twice by the same debugger.

Permit enable tracing for a parent that has been chroot(8)ed, as this is
harmless and the parent is already monitoring for child signals.

The same semantics exist in FreeBSD.

If you are looking for an antidebugging trick for old NetBSD (pre 8.0)
or other popular kernels, here is an example:

$ cat antidebug.c
#include <sys/types.h>
#include <sys/ptrace.h>

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>

int
main(int argc, char **argv)
{
	pid_t child;
	int rv;
	int n = 0;

	child = fork();
	if (child == 0) {
		while (getppid() != 1)
			continue;
		rv = ptrace(PT_TRACE_ME, 0, 0, 0);
		if (rv != 0)
			abort();
		printf("Try to detach to me with a debugger!! ");
		printf("haha My PID is %d\n", getpid());
		while (1) {
			printf("%d\n", n++);
			sleep(1);
		}
	}
	exit(0);
}

A developer is no longer able to attach GDB, strace or LLDB to this program
without killing the initproc (your favourite system daemon).. this action
would be fatal for the operation of the whole Operating System stability.

Examples from a current non-NetBSD popular kernel:

$ ps -o ppid= -p 17904
    1

$ strace -p 17904
strace: attach: ptrace(PTRACE_SEIZE, 17904): Operation not permitted

$ gdb -p 17904
[...]
Attaching to process 17904
warning: process 17904 is already traced by process 1
ptrace: Operation not permitted.
(gdb)

$ lldb-3.9 -p 17904
(lldb) process attach --pid 17904
error: attach failed: unable to attach


On NetBSD 8.0 and newer it is now guaranteed to have an option to kill
a malevolent (fake?) debugger and attach with a new tracer to the process.


Sponsored by <The NetBSD Foundation>
2018-04-29 04:28:09 +00:00
jmcneill
04e10e3e38 Enable motg 2018-04-28 20:35:05 +00:00
jmcneill
8fa5d113ea Enable Allwinner SID and thermal sensor controller 2018-04-28 20:30:50 +00:00
kamil
7c9ce7b74f Enable traceme_raise1 in the ATF ptrace(2) tests
This test checks raise(SIGKILL). If we enter the kernel with this signal
we report a signaled child in a debugger, not stopped with an option to
make an action.

FreeBSD behaves differently and allows intercepting this event in a tracer.
Follow the Linux behavior.

If we really want to prevent raise(SIGKILL) from signaling the tracee, we
still can breakpoint raise(3) and alter the syscall arguments (or use
the PT_SYSCALL mode). If we are already in the kernel, SIGKILL always means
killing the process, whether or not traced and the source of SIGKILL.

This tests passes on NetBSD without kernel changes.

Sponsored by <The NetBSD Foundation>
2018-04-28 19:00:25 +00:00
jmcneill
33212e89bd Add sun7i-a20-olimex-som204-evb-emmc.dts, sun7i-a20-olimex-som204-evb.dts, sun8i-h2-plus-bananapi-m2-zero.dts, sun8i-h2-plus-orangepi-r1.dts, sun8i-h3-libretech-all-h3-cc.dts, sun50i-a64-teres-i.dts, sun50i-h5-orangepi-zero-plus.dts 2018-04-28 18:47:53 +00:00
jmcneill
1eecc1e024 Add sun50i-a64-teres-i.dts, sun50i-h5-orangepi-zero-plus.dts 2018-04-28 18:42:20 +00:00
jmcneill
5985fb0710 Update to Linux dts 4.17-rc2 2018-04-28 18:29:21 +00:00
jmcneill
c6ee38088e merge conflicts 2018-04-28 18:28:25 +00:00
jakllsch
f6c244b639 Cover all pic_maxsources lines for armgic_cpu_init_priorities() and
armgic_cpu_update_priorities().

Previously only the first 32 lines were covered, which is significantly
less than the 1000-some interrupt lines possible.

Only relevant to MULTIPROCESSOR configurations.
2018-04-28 18:26:53 +00:00
jmcneill
a2acc37588 Import dts from Linux 4.17-rc2 2018-04-28 18:25:52 +00:00
kamil
736f73b24b Refactor the traceme3 ATF ptrace(2) test
Replace traceme3 with new ATF tests using diverse signals:

 - traceme_signal_nohandler1 SIGKILL
 - traceme_signal_nohandler2 SIGSTOP (temporarily disabled)
 - traceme_signal_nohandler3 SIGABRT (emits core dump)
 - traceme_signal_nohandler4 SIGHUP
 - traceme_signal_nohandler5 SIGCONT

These SIGSTOP test does not work properly right now as it unstops the
traccee.

Sponsored by <The NetBSD Foundation>
2018-04-28 18:07:15 +00:00
kamil
f738c48337 Handle core dumps in ATF ptrace(2) tests easier
Cast WCOREDUMP() to either 1 or 0.

It could be changed to a boolean type, but it's already good enough.

Sponsored by <The NetBSD Foundation>
2018-04-28 17:56:55 +00:00
ryo
e11b270d28 Oops, my previous commit is totally wrong. recast mask/pattern list.
pointed out by David Binderman in PR/53224, thanks.
2018-04-28 17:42:07 +00:00
maxv
68df48a8f0 Remove IPSEC_SPLASSERT_SOFTNET, it has always been a no-op. 2018-04-28 15:45:16 +00:00
jmcneill
a756758d12 Initialize clk domain name and call clk_attach to register sysctl nodes 2018-04-28 15:21:05 +00:00
jmcneill
ed41487b0c Create private sysctl nodes for inspecting clock trees. 2018-04-28 15:20:33 +00:00
maxv
f193022c1a Inline M_EXT_WRITABLE directly, and remove the XXX, there's nothing wrong
in the use of !M_READONLY.
2018-04-28 14:39:34 +00:00
maxv
c075b705a8 Move the ipsec6_input prototype into ipsec6.h, and style. 2018-04-28 14:25:56 +00:00
maxv
19f9cae6f8 Stop using a macro, rename the function to ipsec_init_pcbpolicy directly. 2018-04-28 14:21:03 +00:00
maxv
6f320ea66c Style and remove unused stuff. 2018-04-28 14:01:50 +00:00
maxv
ab18d0d461 Fix the net.inet6.ipsec6.def_policy node, the variable should be
&ip6_def_policy.policy, otherwise we're overwriting other fields of the
structure.
2018-04-28 13:44:19 +00:00
riastradh
7bc66ed4ff Add -f option to ftpd to stay in foreground with -D.
From nia in PR bin/53221.
2018-04-28 13:38:00 +00:00
maxv
2489795f85 Remove unused ipsec_var.h includes. 2018-04-28 13:26:57 +00:00
maxv
2f2fea5f0e Remove unused macros. 2018-04-28 13:23:17 +00:00
jmcneill
3117ca5607 Create bpf and openfirm devices 2018-04-28 12:45:03 +00:00
jmcneill
6320cfdbae Define __HAVE_OLD_DISKLABEL for compatibility with the arm32 port. 2018-04-28 12:33:17 +00:00
nonaka
d54c6989c4 gmake: Apply patch to support GLIBC glob interface v2
http://git.savannah.gnu.org/cgit/make.git/commit/?id=48c8a116

Fix a build failure on Ubuntu 18.04.
2018-04-28 12:20:40 +00:00
jmcneill
7ee63b91ad Add support for Pinebook lid switch and eMMC 2018-04-28 11:49:48 +00:00
jmcneill
75dc1f1c7e Add support for lid switch event codes. 2018-04-28 11:49:06 +00:00
jmcneill
11e00a763e Increase default MSGBUFSIZE to match arm32 defaults 2018-04-28 10:53:02 +00:00
maxv
70fbd42a2e Rename the 'flags' and 'nowait' arguments to 'how'. The other BSDs did the
same. Also, in m_defrag, rename 'mold' to 'm'.
2018-04-28 08:34:45 +00:00
maxv
7155a9b4d8 Modify m_defrag, so that it never frees the first mbuf of the chain. While
here use the given 'flags' argument, and not M_DONTWAIT.

We have a problem with several drivers: they poll an mbuf chain from their
queues and call m_defrag on them, but m_defrag could update the mbuf
pointer, so the mbuf in the queue is no longer valid. It is not easy to
fix each driver, because doing pop+push will reorder the queue, and we
don't really want that to happen.

This problem was independently spotted by me, Kengo, Masanobu, and other
people too it seems (perhaps PR/53218).

Now m_defrag leaves the first mbuf in place, and compresses the chain
only starting from the second mbuf in the chain.

It is important not to compress the first mbuf with hacks, because the
storage of this first mbuf may be shared with other mbufs.
2018-04-28 08:16:15 +00:00
mlelstv
ac6073da9a regen 2018-04-28 05:12:54 +00:00
mlelstv
ba623ebf71 Add Symbios/LSI RAID and SAS controllers. 2018-04-28 05:11:49 +00:00
kamil
5abe8ef7df Refactor the traceme2 ATF ptrace(2) tests
Replace traceme2 with 3 tests:
 - traceme_sighandler_catch1
 - traceme_sighandler_catch2
 - traceme_sighandler_catch3

These tests are verified with PT_TRACE_ME for: SIGHUP, SIGCONT and SIGABRT.

We don't want tests all signals (this is a domain for a fuzzer), but we want
to cover tests with signals from different groups.

All tests pass.

Sponsored by <The NetBSD Foundation>
2018-04-28 00:14:37 +00:00
kamil
0165d5af91 Refactor the traceme1 and traceme4 ATF ptrace(2) tests
Use common bode for these tests and a macro 1-liner to define a new test.

Test the same scenarios for 5 signals:
 - SIGKILL (temporarily disabled)
 - SIGSTOP
 - SIGABRT
 - SIGHUP
 - SIGCONT

These tests call: raise(sig). It's actually important to assert their
behavior for tests that are from different kinds.

The SIGKILL test is work in progress. It can be caught by a debugger on the
FreeBSD kernel, but it's causing a signaled event in a debugger on Linux.

NetBSD is right now in one of the camps, but research whether this is a bug
or feature is in progress.

Sponsored by <The NetBSD Foundation>
2018-04-27 21:36:45 +00:00
maxv
10ed9cc7a2 Remove unused debug code. 2018-04-27 19:06:48 +00:00
maxv
0f993de4ce Remove reference to m_ext.ext_type (doesn't exist). 2018-04-27 18:40:40 +00:00
christos
860a01d976 Canonicalize the interpreter path in #! scripts since check_exec() expects
an absolute path, and we KASSERT if that's not the case later.
2018-04-27 18:33:24 +00:00
kamil
8f414e6476 Correct XXX comment in the ptrace(2) kernel code
Explain I and D read/write operations and its history, removing dummy XXX
comments.

Sponsored by <The NetBSD Foundation>
2018-04-27 16:50:56 +00:00
maxv
4d2bf052af Remove unused ext_flags field in struct _m_ext_storage.
Also, simplify MEXTMALLOC, mbtypes[] doesn't exist anymore, but the code
still compiled correctly because "malloc" is a macro and the argument
was dropped.
2018-04-27 16:32:03 +00:00
maxv
bdebf53f25 Stop passing the pool as argument of the storage. M_EXT_CLUSTER mbufs
are supposed to take their area from mcl_cache only.
2018-04-27 16:18:40 +00:00
christos
213d895173 use the proper station nodeid read command. 2018-04-27 12:04:23 +00:00
knakahara
b0c61d654b Fix LOCKDEBUG kernel panic when many(about 200) tunnel interfaces is created.
The tunnel interfaces are gif(4), l2tp(4), and ipsecif(4). They use mutex
itself in percpu area. When percpu_cpu_enlarge() run, the address of the
mutex in percpu area becomes different from the address which lockdebug
saved. That can cause "already initialized" false detection.
2018-04-27 09:55:27 +00:00
wiz
d4593e87a1 Fix xrefs. 2018-04-27 09:33:43 +00:00
wiz
e54c25f543 New sentence, new line. 2018-04-27 09:33:09 +00:00