From 16d2bce89310d68804bacabf5e87a90e8f7322af Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 5 Jul 2017 13:09:21 -0400 Subject: [PATCH] Allow setsockopt(IPV6_V6ONLY) in sandbox. Fixes bug 20247. We started setting V6ONLY in 0.2.3.13-alpha and added the sandbox on 0.2.5.1-alpha. --- changes/bug20247 | 4 ++++ src/common/sandbox.c | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 changes/bug20247 diff --git a/changes/bug20247 b/changes/bug20247 new file mode 100644 index 000000000..731cf0046 --- /dev/null +++ b/changes/bug20247 @@ -0,0 +1,4 @@ + o Minor bugfixes (linux seccomp2 sandbox): + - Avoid a sandbox failure when trying to re-bind to a socket and mark + it as IPv6-only. Fixes bug 20247; bugfix on 0.2.5.1-alpha. + diff --git a/src/common/sandbox.c b/src/common/sandbox.c index da96ad824..7f4511db2 100644 --- a/src/common/sandbox.c +++ b/src/common/sandbox.c @@ -728,6 +728,14 @@ sb_setsockopt(scmp_filter_ctx ctx, sandbox_cfg_t *filter) return rc; #endif +#ifdef IPV6_V6ONLY + rc = seccomp_rule_add_2(ctx, SCMP_ACT_ALLOW, SCMP_SYS(setsockopt), + SCMP_CMP(1, SCMP_CMP_EQ, IPPROTO_IPV6), + SCMP_CMP(2, SCMP_CMP_EQ, IPV6_V6ONLY)); + if (rc) + return rc; +#endif + return 0; }