From patchwork Fri Feb 21 13:05:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 38904 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 9847A27BBEA; Fri, 21 Feb 2025 13:08:40 +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=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham 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 51BF427BBE2 for ; Fri, 21 Feb 2025 13:08:40 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tlSlI-00058c-UV; Fri, 21 Feb 2025 08:08:12 -0500 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 1tlSlG-000583-Uj for guix-patches@gnu.org; Fri, 21 Feb 2025 08:08:10 -0500 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 1tlSlF-0004ga-At for guix-patches@gnu.org; Fri, 21 Feb 2025 08:08:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=udLBw4qw0envZeVnNl6X7JHSGVVjKh3qwYLpmJ5s2vI=; b=fSrEqp1RjwIzvYbvdAz4er5qGpzYiOntJw44OZyJtCmOQRxb4WrzWC8JRbqC/VhkIwsjial28NTWDqShG95I+Vxd34lwX+hqB4VTJq8Of+Ec3V1SmO1MqnmjTOKJ4cD6zZAFKPvRZ71WWwMysNY8VkQbTmxQ2NRDb9hQJcdzJNRhDmRzmeFRzgUXrkwqRRwq1Q588y1wYF1FM1VjCn+A8CWo2PyTenm6LprXm9F/TfJifSk18sONsLNzYnhLPmrFbQtnsektpA5Ajsd9270RtPwYTgEEVWbsKdi/EjLcVn/f71pA0oEAq5wn+YlqVpX4NNaWzak9owTShH7IxHhdXA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tlSlE-0005e1-RA for guix-patches@gnu.org; Fri, 21 Feb 2025 08:08:08 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75810] [PATCH v3 03/11] daemon: Remount inputs as read-only. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 21 Feb 2025 13:08:08 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75810 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75810@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Reepca Russelstein Received: via spool by 75810-submit@debbugs.gnu.org id=B75810.174014327021469 (code B ref 75810); Fri, 21 Feb 2025 13:08:08 +0000 Received: (at 75810) by debbugs.gnu.org; 21 Feb 2025 13:07:50 +0000 Received: from localhost ([127.0.0.1]:56677 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tlSks-0005Zh-Ta for submit@debbugs.gnu.org; Fri, 21 Feb 2025 08:07:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48278) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tlSjq-0005NX-NM for 75810@debbugs.gnu.org; Fri, 21 Feb 2025 08:06:49 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tlSjk-0004YS-E4; Fri, 21 Feb 2025 08:06:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=udLBw4qw0envZeVnNl6X7JHSGVVjKh3qwYLpmJ5s2vI=; b=gqyslp3G9o2/wxdo48xj ihL0DR7t+TeRNoFxv/94wfW8uFgwpJxNVrGO5cb5HtR01wjLMFZcbK2+daFhJTHPHKUSEVIGKwLSs ZzyD4f+e/9huSej3FK03lDgaHXhS9K+xfmUF7a7A/b+mW6YDVjU6kariWxcyEwGOaWUwOda2wgpy6 2sgZAWngi194os2gNLxHWfPFru41IJt8/9zqgyctM67fRpsCNxYZ5rQL5349hBVWXNlENvUIZc67X HBX5oapz3vCrZEF9sNTAfkCCf1BqVe1X2HADq26cWmBA9qmveBuGWLHfaeu2zYG0g35OOseWNG2DT tGymk+kLsZEgfg==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Fri, 21 Feb 2025 14:05:51 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * nix/libstore/build.cc (DerivationGoal::runChild): Remount ‘target’ as read-only. Reported-by: Reepca Russelstein Change-Id: Ib7201bcf4363be566f205d23d17fe2f55d3ad666 --- nix/libstore/build.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc index f4cd2131c84..6244c99e751 100644 --- a/nix/libstore/build.cc +++ b/nix/libstore/build.cc @@ -2094,8 +2094,15 @@ void DerivationGoal::runChild() createDirs(dirOf(target)); writeFile(target, ""); } + + /* Extra flags passed with MS_BIND are ignored, hence the + extra MS_REMOUNT. */ if (mount(source.c_str(), target.c_str(), "", MS_BIND, 0) == -1) throw SysError(format("bind mount from `%1%' to `%2%' failed") % source % target); + if (source.compare(0, settings.nixStore.length(), settings.nixStore) == 0) { + if (mount(source.c_str(), target.c_str(), "", MS_BIND | MS_REMOUNT | MS_RDONLY, 0) == -1) + throw SysError(format("read-only remount of `%1%' failed") % target); + } } /* Bind a new instance of procfs on /proc to reflect our