From patchwork Thu Dec 30 03:52:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Sundberg X-Patchwork-Id: 35761 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A593527BBE9; Thu, 30 Dec 2021 03:54:12 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id DBDEF27BBEA for ; Thu, 30 Dec 2021 03:54:10 +0000 (GMT) Received: from localhost ([::1]:46006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2mW1-0003WK-VA for patchwork@mira.cbaines.net; Wed, 29 Dec 2021 22:54:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2mVu-0003W8-RJ for guix-patches@gnu.org; Wed, 29 Dec 2021 22:54:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:39296) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2mVu-0002ae-IH for guix-patches@gnu.org; Wed, 29 Dec 2021 22:54:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n2mVu-00081t-Gk for guix-patches@gnu.org; Wed, 29 Dec 2021 22:54:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52887] [PATCH staging] containers: Add CLONE_NEWCGROUP cgroup namespace support Resent-From: Ryan Sundberg Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 30 Dec 2021 03:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52887 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 52887@debbugs.gnu.org Cc: Ryan Sundberg X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164083638430776 (code B ref -1); Thu, 30 Dec 2021 03:54:02 +0000 Received: (at submit) by debbugs.gnu.org; 30 Dec 2021 03:53:04 +0000 Received: from localhost ([127.0.0.1]:50842 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2mUy-00080K-8v for submit@debbugs.gnu.org; Wed, 29 Dec 2021 22:53:04 -0500 Received: from lists.gnu.org ([209.51.188.17]:47662) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2mUw-000802-NU for submit@debbugs.gnu.org; Wed, 29 Dec 2021 22:53:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2mUv-0003UD-RA for guix-patches@gnu.org; Wed, 29 Dec 2021 22:53:01 -0500 Received: from mail.arctype.co ([138.68.9.245]:42661) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2mUt-0001CQ-Ou for guix-patches@gnu.org; Wed, 29 Dec 2021 22:53:01 -0500 Received: from authenticated-user (mail.arctype.co [138.68.9.245]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by mail.arctype.co (Postfix) with ESMTPSA id 70F4913B22C; Thu, 30 Dec 2021 03:52:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=arctype.co; s=mail; t=1640836346; bh=eo3JTf1A4eSXvlGbTeDy0wnQmd5ETyyyakDjxJUTIUE=; h=From:To:Cc:Subject:Date:From; b=O6qD6HdvfYgE2CSqdZ24QVYcvSvT2s9AbpUnJDHaVq2aSjXa9f8k2p+mXufk5ecu5 UfEJFIiCq6Ukp1G4VD4i1mFWhvuiCugOmylWU7yfqWnV4OraQMGylbbijKwueCsM8i VJnegW3WUpf5nWa5IHmuaS/GM4FJ0xvtigmM/UeUYFipcduMjAjiTkrAA05EHHgI5k jn33fghLE5d2eWY7+c8dgvXSdcgr5PLtH6BliV5o8v/iN7s8IlR2HGT3FmUileLAsU eFfVbL4836nD+JHm3vVuufE/A5Ea+ABpuQqVYd+juPo51eUK5KtFk9flOPF/J4uumN YaIC/1bHjIRRw== Date: Wed, 29 Dec 2021 19:52:16 -0800 Message-Id: <20211230035215.14477-1-ryan@arctype.co> MIME-Version: 1.0 Received-SPF: pass client-ip=138.68.9.245; envelope-from=ryan@arctype.co; helo=mail.arctype.co X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Ryan Sundberg X-ACL-Warn: , Ryan Sundberg via Guix-patches X-Patchwork-Original-From: Ryan Sundberg via Guix-patches via From: Ryan Sundberg X-getmail-retrieved-from-mailbox: Patches Adds low-level support for launching linux containers with cgroup namespaces. gnu/build/linux-container.scm (%namespaces): Add 'cgroup guix/build/syscalls.scm (CLONE_NEWCGROUP): Add flag definition --- gnu/build/linux-container.scm | 3 ++- guix/build/syscalls.scm | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gnu/build/linux-container.scm b/gnu/build/linux-container.scm index 4a8bed5a9a..bdeca2cdb9 100644 --- a/gnu/build/linux-container.scm +++ b/gnu/build/linux-container.scm @@ -52,7 +52,7 @@ exists." (file-exists? "/proc/self/setgroups")) (define %namespaces - '(mnt pid ipc uts user net)) + '(cgroup mnt pid ipc uts user net)) (define (call-with-clean-exit thunk) "Apply THUNK, but exit with a status code of 1 if it fails." @@ -210,6 +210,7 @@ corresponds to the symbols in NAMESPACES." ;; Use the same flags as fork(3) in addition to the namespace flags. (apply logior SIGCHLD (map (match-lambda + ('cgroup CLONE_NEWCGROUP) ('mnt CLONE_NEWNS) ('uts CLONE_NEWUTS) ('ipc CLONE_NEWIPC) diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 45f95c509d..a7401fd73f 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -132,6 +132,7 @@ CLONE_CHILD_CLEARTID CLONE_CHILD_SETTID + CLONE_NEWCGROUP CLONE_NEWNS CLONE_NEWUTS CLONE_NEWIPC @@ -1025,6 +1026,7 @@ caller lacks root privileges." ;; Linux clone flags, from linux/sched.h (define CLONE_CHILD_CLEARTID #x00200000) (define CLONE_CHILD_SETTID #x01000000) +(define CLONE_NEWCGROUP #x02000000) (define CLONE_NEWNS #x00020000) (define CLONE_NEWUTS #x04000000) (define CLONE_NEWIPC #x08000000)