From 4c7304db85bd4e8ae641ab946a5b3832f24b6eca Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Tue, 25 Jan 2022 20:08:00 +0100 Subject: conf, pasta: Explicitly pass CLONE_{NEWUSER,NEWNET} to setns() Only allow the intended types of namespaces to be joined via setns() as a defensive measure. Signed-off-by: Stefano Brivio --- conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index ab91b7f..6810144 100644 --- a/conf.c +++ b/conf.c @@ -347,8 +347,8 @@ static int conf_ns_check(void *arg) { struct ctx *c = (struct ctx *)arg; - if ((!c->netns_only && setns(c->pasta_userns_fd, 0)) || - setns(c->pasta_netns_fd, 0)) + if ((!c->netns_only && setns(c->pasta_userns_fd, CLONE_NEWUSER)) || + setns(c->pasta_netns_fd, CLONE_NEWNET)) c->pasta_userns_fd = c->pasta_netns_fd = -1; return 0; -- cgit v1.2.3