|
@@ -587,7 +587,7 @@ static int
|
|
sb_socket(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|
sb_socket(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|
{
|
|
{
|
|
int rc = 0;
|
|
int rc = 0;
|
|
- int i;
|
|
+ int i, j;
|
|
(void) filter;
|
|
(void) filter;
|
|
|
|
|
|
#ifdef __i386__
|
|
#ifdef __i386__
|
|
@@ -604,20 +604,20 @@ sb_socket(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|
|
|
|
|
for (i = 0; i < 2; ++i) {
|
|
for (i = 0; i < 2; ++i) {
|
|
const int pf = i ? PF_INET : PF_INET6;
|
|
const int pf = i ? PF_INET : PF_INET6;
|
|
-
|
|
+ for (j=0; j < 3; ++j) {
|
|
- rc = seccomp_rule_add_3(ctx, SCMP_ACT_ALLOW, SCMP_SYS(socket),
|
|
+ const int type = (j == 0) ? SOCK_STREAM :
|
|
- SCMP_CMP(0, SCMP_CMP_EQ, pf),
|
|
+ (j == 1) ? SOCK_DGRAM :
|
|
- SCMP_CMP_MASKED(1, SOCK_CLOEXEC|SOCK_NONBLOCK, SOCK_STREAM),
|
|
+ SOCK_DGRAM;
|
|
- SCMP_CMP(2, SCMP_CMP_EQ, IPPROTO_TCP));
|
|
+ const int protocol = (j == 0) ? IPPROTO_TCP :
|
|
- if (rc)
|
|
+ (j == 1) ? IPPROTO_IP :
|
|
- return rc;
|
|
+ IPPROTO_UDP;
|
|
-
|
|
+ rc = seccomp_rule_add_3(ctx, SCMP_ACT_ALLOW, SCMP_SYS(socket),
|
|
- rc = seccomp_rule_add_3(ctx, SCMP_ACT_ALLOW, SCMP_SYS(socket),
|
|
+ SCMP_CMP(0, SCMP_CMP_EQ, pf),
|
|
- SCMP_CMP(0, SCMP_CMP_EQ, pf),
|
|
+ SCMP_CMP_MASKED(1, SOCK_CLOEXEC|SOCK_NONBLOCK, type),
|
|
- SCMP_CMP_MASKED(1, SOCK_CLOEXEC|SOCK_NONBLOCK, SOCK_DGRAM),
|
|
+ SCMP_CMP(2, SCMP_CMP_EQ, protocol));
|
|
- SCMP_CMP(2, SCMP_CMP_EQ, IPPROTO_IP));
|
|
+ if (rc)
|
|
- if (rc)
|
|
+ return rc;
|
|
- return rc;
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
rc = seccomp_rule_add_3(ctx, SCMP_ACT_ALLOW, SCMP_SYS(socket),
|
|
rc = seccomp_rule_add_3(ctx, SCMP_ACT_ALLOW, SCMP_SYS(socket),
|