Skip to content

Commit 0f62fdd

Browse files
committed
privsep: Fix valgrind and hardened-malloc on Linux with SECCOMP
Valgrind will still error by default at exit as the syscall to unlink the pipe files is denied. This can be avoided by compiling with -DVALGRIND. The pipe files still won't be removed as dhcpcd has already dropped to the non root user. This is a Vagrind issue really. hardened-malloc should now run as well as their documented syscalls are now allowed by default. Fixes #497.
1 parent 4db8ddd commit 0f62fdd

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

BUILDING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ still. If you do this, please report the issue so that we can adjust the
129129
SECCOMP filter so that dhcpcd can use SECCOMP once more.
130130
Or convince the libc/kernel people to adpot something more maintainable
131131
like FreeBSD's capsicum or OpenBSD's pledge.
132+
To test ASAN with privsep you need to add ASAN to CPPFLAGS.
133+
To test Valgrind with privsep you can optionally add VALGRIND to CPPFLAGS.
134+
For both they need some syscalls which are potentially dangerous and thus
135+
are disabled by default.
136+
For Valgrind, it needs to unlink the pipe files which it can't do anyway
137+
as it's dropped permissions. Otherwise it works fine.
132138

133139
## Init systems
134140
We try and detect how dhcpcd should interact with system services at runtime.

src/privsep-linux.c

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,6 @@ static struct sock_filter ps_seccomp_filter[] = {
468468

469469
/* These are for compiling with address sanitization */
470470
#ifdef ASAN
471-
#ifdef __NR_futex
472-
SECCOMP_ALLOW(__NR_futex),
473-
#endif
474471
#ifdef __NR_openat
475472
SECCOMP_ALLOW(__NR_openat),
476473
#endif
@@ -482,12 +479,42 @@ static struct sock_filter ps_seccomp_filter[] = {
482479
#endif
483480

484481
/* coredumps */
482+
#ifdef __NR_tgkill
483+
SECCOMP_ALLOW(__NR_tgkill),
484+
#endif
485+
#endif
486+
487+
/* valgrind */
488+
#ifdef __NR_futex
489+
SECCOMP_ALLOW(__NR_futex),
490+
#endif
485491
#ifdef __NR_gettid
486492
SECCOMP_ALLOW(__NR_gettid),
487493
#endif
488-
#ifdef __NR_tgkill
489-
SECCOMP_ALLOW(__NR_tgkill),
494+
#ifdef __NR_rt_sigtimedwait
495+
SECCOMP_ALLOW(__NR_rt_sigtimedwait),
496+
#endif
497+
#ifdef VALGRIND
498+
#ifdef __NR_unlink
499+
/* This is dangerous, and also pointless as in privsep
500+
* we are no longer root and thus cannot unlink the valgrind
501+
* pipes anyway. */
502+
SECCOMP_ALLOW(__NR_unlink),
503+
#endif
504+
#endif
505+
506+
/* hardened-malloc */
507+
#ifdef __NR_mprotect
508+
SECCOMP_ALLOW(__NR_mprotect),
509+
#endif
510+
#ifdef __NR_mremap
511+
SECCOMP_ALLOW(__NR_mremap),
512+
#endif
513+
#ifdef __NR_pkey_alloc
514+
SECCOMP_ALLOW(__NR_pkey_alloc),
490515
#endif
516+
#ifdef __NR_pkey_mprotect
517+
SECCOMP_ALLOW(__NR_pkey_mprotect),
491518
#endif
492519

493520
/* Deny everything else */

0 commit comments

Comments
 (0)