Roy Marples [Fri, 5 Jun 2020 10:12:21 +0000 (11:12 +0100)]
privsep: Remove pledges inet and dns from the master process
Achieved by adding IPC to ignore interfaces names based on
the interface group.
This means every process just pledges stdio for IPC which the
exception of the master process which also pledges route so it
can access the routing table.
Roy Marples [Wed, 3 Jun 2020 22:30:08 +0000 (23:30 +0100)]
eloop: Just use ppoll(2)
epoll and kqueue are really too heavy weight.
With privsep, we now favour more processes for BPF and per address sockets.
As such, the number of fds to monitor will always be quite small.
All modern OS now have ppoll(2) (NetBSD has pollts, which is the same)
which works perfectly for us.
If neither are present, the a wrapper around pselect(2) is provided,
which can be found on all POSIX systems.
This makes the code a lot smaller and easier to follow.
The reduced binary size and memory usage is a nice win here.
Roy Marples [Tue, 2 Jun 2020 14:50:17 +0000 (15:50 +0100)]
privsep: harden process handling
If eloop is exited, only allow explicit re-entry.
Only exit on read/write error if a forked process and not root.
If the root process fails to read/write to a sub-process,
stop the sub-process.
Roy Marples [Tue, 2 Jun 2020 02:01:37 +0000 (03:01 +0100)]
auth: Only accept RECONFIGURE messages from LL hosts
This has to be authentiated, and there is a chance we cannot know
the token if IP address sharing.
The initial messages are send via LL anyway, so the peer address
the server should record is the LL.
While here, drop the lease at exit if we accepted a reconfigure token.
The token may not be in all the replies from the server and we
always save the last reply.
Roy Marples [Thu, 28 May 2020 08:02:13 +0000 (09:02 +0100)]
DHCP6: Revert part of prior - only allow vendorclassid to disable
Not set.
dhcpcd owns the IANA_PEN defined.
Either use it as is, or get your own.
This restores the prior behaviour but still allows the option
as a whole to be disabled by vendorclassid being disabled.
Roy Marples [Thu, 21 May 2020 17:28:27 +0000 (18:28 +0100)]
dhcpcd: Move the script file from per interface to global context
This *should* affect no-one, but you never know.
The primary motivation for this is to ensure that nothing arbitary
can be executed by the root process if anyone breaks into the
chrooted unprivileged master process.
Roy Marples [Thu, 21 May 2020 15:12:25 +0000 (16:12 +0100)]
dhcpcd: Silence console output entirely with more -q
SystemD logs console ouput and syslog to the same place.
Pretty daft if you ask me, but heh.
-qq disables console output entirely to make SystemD logs easier to read.
Roy Marples [Wed, 20 May 2020 15:44:19 +0000 (15:44 +0000)]
privsep: Ensure we don't scribble garbage to BPF
Well, it's not garbage, it's a privsep IPC message telling us to
start BPF which the BPF process should not have recieved!
Add code to ensure this cannot happen.
Roy Marples [Tue, 19 May 2020 15:19:05 +0000 (16:19 +0100)]
privsep: Enable Capsicum for all processes.
Except for the priviledged process.
This is quite an in-depth change:
* ARP is now one process per address
* BPF flags are now returned via privsep
* BPF write filters are locked when supported
* The root process sends to the network
The last step is done by opening RAW sockets and then sending a UDP
header (where applicable) to avoid binding to an address
which is already in use by the reader sockets.
This is slightly wasteful for OS's without sandboxing but does
have the very nice side effect of not needing a source address
to unicast DHCPs replies from which makes the code smaller.
Roy Marples [Fri, 15 May 2020 21:29:30 +0000 (22:29 +0100)]
ARP: Remove ability to filter specific addresses
This is only really needed for long lasting ARP, which is only
used for IPv4 address defence.
Modern NetBSD does not need this and it fails to work with
OpenBSD Pledge. FreeBSD Capsicum is more secure without this
as the BPF fd can then be locked for other changes [1].
That just leaves Linux and Solaris.
If anyone feels dhcpcd is processing to much ARP then please
implement RFC 5227 in the kernel like NetBSD.
[1] Locking the BPF fd is questionable because the inet proxy
using sendmsg can send any packet to any destination.
Roy Marples [Thu, 14 May 2020 00:15:39 +0000 (01:15 +0100)]
privsep: sockaddr len should be socklen_t
While ps_root_getifaddrs is only for capsicum, it's highly portable
and thus in the privsep-root rather than privsep-bsd.
As such, store the sockaddr len as socklen_t because that's what
POSIX demands.
It's only a few more bytes and I'd rather make this change now
than it potentially bite me later.