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.
Andrew Childs [Tue, 12 May 2020 21:08:33 +0000 (06:08 +0900)]
Fix neighbor discovery option parsing (#16)
* make_option_mask: use `nd_` prefix for nd options
The prefix for neighbor discovery options was partially changed to
`nd6_` in d5700a48edf7006369f766d225e70bbca3d8055c. However
set_option_space continued to use `nd_`. This prevented either
`nd6_prefix_information` or `nd_prefix_information` from being parsed
since the former was in the wrong option space, and the latter did not
have the prefix removed.
Roy Marples [Tue, 12 May 2020 09:26:35 +0000 (10:26 +0100)]
privsep: Handle all file IO in the Priviledged Actioneer
This allows us to move the database directory back into the
root of the filesystem.
While here, harden the files by denying any user read access to them.
As part of this change, init the DUID from any machine data and
cache the default DHCP vendor field before dropping priviledges as we
may lose access to this later.
Roy Marples [Thu, 7 May 2020 19:57:22 +0000 (20:57 +0100)]
privsep: Enable capsicum for network facing processes
All fd's in network facing processes are fully limited.
Capability mode is only enabled for BPF processes because
it's too restrictive otherwise - the reasons are noted
in the commit.
Roy Marples [Wed, 29 Apr 2020 15:33:57 +0000 (16:33 +0100)]
inet6: Set default ND timers before a RA arrives after preservation
Other OS will just remove the RA's on carrier down and thus set
default values, but not so on NetBSD.
As such as need to set default values just before settings any values
from the incoming RA.
This allows us to change networks sensibly.
Roy Marples [Wed, 29 Apr 2020 13:55:23 +0000 (14:55 +0100)]
NetBSD: Gear up for kernel RA removal.
linkmtu will vanish from nd_ifinfo along with other things.
Also, there is not need to pre-fetch ifinfo because flags are no
longer updated when setting ifinfo back again.
Roy Marples [Sun, 26 Apr 2020 16:22:42 +0000 (17:22 +0100)]
DHCP6: Implement DECLINE support for duplicated addresses
This is the final piece of DHCP6 to implement!
Part of this change drops the use of the IPV6_AF_DUPLICATED flag
and we just use IN6_IFF_DUPLICATED now.