From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id mNo3I+7fJGZSRgAAe85BDQ:P1 (envelope-from ) for ; Sun, 21 Apr 2024 11:44:14 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id mNo3I+7fJGZSRgAAe85BDQ (envelope-from ) for ; Sun, 21 Apr 2024 11:44:14 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1713692654; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=UaivadE0QQHyPq9yq6p5wYRzoEnaTlMHulSuyaIrrPQ=; b=h9co81wqYhRNLQc68tB1zh47mikKKvpURolWMIW6hGi6mvCSLIcHuWjLy6H5t0SVJrjzPP t6nRJfrO07EazHEanKFXW0Ei0ZOhTUcvGJJwNn3g8/0EUHpOprPiXoGpBmQzq72M2ySGOx U5RhnmTedDvImCU7Ow+GFrJsu00f7kbBmNN2V1bRftjglFzZVgjf74Y+Xf0XC6rX0HJIMt Q9OJYaFzZmwZmTliQDqNo4wfg/YMllc/uayxRiPlv2Nxo3kMqZwHkzuURqo97JuYEhL4Ok i5o6j01lkfqn1Tz4FOx7gFy++CvTmZVumoYLWSRl9Wi7911r3JOw2zoAcDFpUQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1713692654; a=rsa-sha256; cv=none; b=YjpbgB1bh2y321RQU4UgHBF+mMoJLJ6SHpfOEEAFKY5+1ow79nwtxLnsYHlvm+PKLdx912 E5V8Y4luRzbPVe48bcc28i1sriOPcF3vrscdZUgltBO4YtgrWFtbTQYJs/UiDjDCxteFFC uZCUahH0/2TIbHfFhFGZ1xsWypxTtJ9NK0ImH4WWn3fMONb/MXXxqoXSSae/z3hyvPQie5 h/pltCFLXvgIzPIaYPMfSFP8PL1bY59/W2P1chc/Wyco8KL8Dii09lVZ5z8V0xE536uFk4 EExsTh6DR0OdbiiX/t2qCSnh7g4SQcKeOd5pozyxC2SlImQ+WmjMALFLgM7kvQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6350D1F802 for ; Sun, 21 Apr 2024 11:44:14 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ryTji-0005OO-J4; Sun, 21 Apr 2024 05:43:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ryTjg-0005LL-5S for guix-patches@gnu.org; Sun, 21 Apr 2024 05:43:48 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ryTjf-0002jU-Pl for guix-patches@gnu.org; Sun, 21 Apr 2024 05:43:47 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ryTju-0006TK-Vo for guix-patches@gnu.org; Sun, 21 Apr 2024 05:44:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70494] [PATCH 02/23] gnu: linux-container: Make it more suitable for derivation-building. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 21 Apr 2024 09:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70494 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70494@debbugs.gnu.org Cc: Christopher Baines Received: via spool by 70494-submit@debbugs.gnu.org id=B70494.171369259124296 (code B ref 70494); Sun, 21 Apr 2024 09:44:02 +0000 Received: (at 70494) by debbugs.gnu.org; 21 Apr 2024 09:43:11 +0000 Received: from localhost ([127.0.0.1]:41753 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ryTj1-0006Il-0n for submit@debbugs.gnu.org; Sun, 21 Apr 2024 05:43:10 -0400 Received: from mira.cbaines.net ([212.71.252.8]:43360) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ryTiw-0006HP-6X for 70494@debbugs.gnu.org; Sun, 21 Apr 2024 05:43:03 -0400 Received: from localhost (unknown [212.132.255.10]) by mira.cbaines.net (Postfix) with ESMTPSA id 351AB27BBE9; Sun, 21 Apr 2024 10:42:46 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id c0512a2a; Sun, 21 Apr 2024 09:42:46 +0000 (UTC) From: Christopher Baines Date: Sun, 21 Apr 2024 10:42:20 +0100 Message-ID: <01702a23fe5bb7ae3b5d800b69e8d6bc59c488f2.1713692561.git.mail@cbaines.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: <87bk632h36.fsf@cbaines.net> References: <87bk632h36.fsf@cbaines.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -4.88 X-Spam-Score: -4.88 X-Migadu-Queue-Id: 6350D1F802 X-Migadu-Scanner: mx12.migadu.com X-TUID: BBMwr2zH1/JP From: Caleb Ristvedt * gnu/build/linux-container.scm (mount-file-systems): First remount all filesystems in the current mount namespace as private (by mounting / with MS_PRIVATE and MS_REC), so that the set of mounts cannot increase except from within the container. Also, the tmpfs mounted over the chroot directory now inherits the chroot directory's permissions (p11-kit, for example, has a test that assumes that the root directory is not writable for the current user, and tmpfs is by default 1777 when created). * guix/build/syscalls.scm (MS_PRIVATE, MS_REC): new variables. Signed-off-by: Christopher Baines Change-Id: Ie26e3ac4a12bbf9087180c56ab775a0f75c40100 --- gnu/build/linux-container.scm | 9 ++++++++- guix/build/syscalls.scm | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gnu/build/linux-container.scm b/gnu/build/linux-container.scm index dee6885400..2e4e0d3bf3 100644 --- a/gnu/build/linux-container.scm +++ b/gnu/build/linux-container.scm @@ -99,7 +99,14 @@ (define* (mount-file-systems root mounts #:key mount-/sys? mount-/proc?) ;; The container's file system is completely ephemeral, sans directories ;; bind-mounted from the host. - (mount "none" root "tmpfs") + ;; Make this private in the container namespace so everything mounted under + ;; it is local to this namespace. + (mount "none" "/" "none" (logior MS_REC MS_PRIVATE)) + (let ((current-perms (stat:perms (stat root)))) + (mount "none" root "tmpfs" 0 (string-append "mode=" + (number->string current-perms + 8)))) + ;; A proc mount requires a new pid namespace. (when mount-/proc? diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 39bcffd516..92f2bb21fc 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -54,6 +54,8 @@ (define-module (guix build syscalls) MS_REC MS_SHARED MS_LAZYTIME + MS_PRIVATE + MS_REC MNT_FORCE MNT_DETACH MNT_EXPIRE @@ -551,6 +553,7 @@ (define MS_MOVE 8192) (define MS_REC 16384) (define MS_SHARED 1048576) (define MS_RELATIME 2097152) +(define MS_PRIVATE 262144) (define MS_STRICTATIME 16777216) (define MS_LAZYTIME 33554432) -- 2.41.0