From patchwork Fri Feb 21 13:05:50 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: 38903 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 531D427BBEA; Fri, 21 Feb 2025 13:08:19 +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 01D9D27BBE2 for ; Fri, 21 Feb 2025 13:08:19 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tlSlD-00056E-53; Fri, 21 Feb 2025 08:08:07 -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 1tlSl9-00054v-9C for guix-patches@gnu.org; Fri, 21 Feb 2025 08:08:03 -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 1tlSl8-0004fe-Tj for guix-patches@gnu.org; Fri, 21 Feb 2025 08:08:02 -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=G7Jx1/74uyahpmNN6NOOyHz1Zj53iERfANavhA6dHdE=; b=iwGp9vel7T+YDbF7971NZXtvrxs1t4Ci4QebJb/BI7svWXwj43akOE7jIxDnhOFvbnFrLHkydXtQBIPTdkeNMn2X9zFtNctEFT870nttAJifbikhkxuVKVINGAtlMZ5lpdhiRBRuUJ+3ZFuz57b3fts0AivqlMyvUce9qnzxnEIbACWvjnvwSfUJi34773ZxeZnDTFwOGQQ1dCqHn8s8kQp/YWj6hOWB269xXbvTzbWMxUSXhnvZiB0wNTjrA3IZ3rETDnOTHSofcg1LbKO2gg2PBi+uih1eE4uieja8qbSnsRcgIxGaHv1sqnC2oKlUKhuz6bqmA49HOThLuvXe4w==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tlSl8-0005ci-Ml for guix-patches@gnu.org; Fri, 21 Feb 2025 08:08:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75810] [PATCH v3 02/11] daemon: Bind-mount all the inputs, not just directories. 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:02 +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.174014326421399 (code B ref 75810); Fri, 21 Feb 2025 13:08:02 +0000 Received: (at 75810) by debbugs.gnu.org; 21 Feb 2025 13:07:44 +0000 Received: from localhost ([127.0.0.1]:56673 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tlSkn-0005Ye-QL for submit@debbugs.gnu.org; Fri, 21 Feb 2025 08:07:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48276) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tlSjp-0005NF-Ey for 75810@debbugs.gnu.org; Fri, 21 Feb 2025 08:06:46 -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 1tlSjj-0004Y4-2y; Fri, 21 Feb 2025 08:06:35 -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=G7Jx1/74uyahpmNN6NOOyHz1Zj53iERfANavhA6dHdE=; b=aHpHVyGtVmH3uhPTi7qz tnA+Ktpn0x6MnFWexd6kGAfCOfj3YW5s9Vd40ulEX33pXEudpuPI4df1CyJc+oEujxhL6fplnIBL6 dqHYXvMO46Dom+VhYnXq7k5TS7t3JhNqyIZOFhHYprmnGRzIXngx7UKGi7JnKPB78Efjy+IBlDuEP 8Oa+44VDYw7pmoyW4Cn40Hcm5YPXPUS8o4Ny1sfttYx38Jl4matq13vXJw9tLM2QU11omhs8ZNy30 5VQL15slVibAWblv8xxh6TRRXLIRKF4NCeZxhw7nuunVapen/ssBsm5acstlBbM+f/MUiaCgViNtl CO5OjBuHyDdiDw==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Fri, 21 Feb 2025 14:05:50 +0100 Message-ID: <9819a4edaacbd5ed8d56094d6bb602f90f535be6.1740142328.git.ludo@gnu.org> 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::startBuilder): Add all of ‘inputPaths’ to ‘dirsInChroot’ instead of hard-linking regular files. Reported-by: Reepca Russelstein Change-Id: I070987f92d73f187f7826a975bee9ee309d67f56 --- nix/libstore/build.cc | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc index edd01bab34d..f4cd2131c84 100644 --- a/nix/libstore/build.cc +++ b/nix/libstore/build.cc @@ -1850,9 +1850,7 @@ void DerivationGoal::startBuilder() /* Make the closure of the inputs available in the chroot, rather than the whole store. This prevents any access - to undeclared dependencies. Directories are bind-mounted, - while other inputs are hard-linked (since only directories - can be bind-mounted). !!! As an extra security + to undeclared dependencies. !!! As an extra security precaution, make the fake store only writable by the build user. */ Path chrootStoreDir = chrootRootDir + settings.nixStore; @@ -1863,28 +1861,7 @@ void DerivationGoal::startBuilder() throw SysError(format("cannot change ownership of ‘%1%’") % chrootStoreDir); foreach (PathSet::iterator, i, inputPaths) { - struct stat st; - if (lstat(i->c_str(), &st)) - throw SysError(format("getting attributes of path `%1%'") % *i); - if (S_ISDIR(st.st_mode)) - dirsInChroot[*i] = *i; - else { - Path p = chrootRootDir + *i; - if (link(i->c_str(), p.c_str()) == -1) { - /* Hard-linking fails if we exceed the maximum - link count on a file (e.g. 32000 of ext3), - which is quite possible after a `nix-store - --optimise'. */ - if (errno != EMLINK) - throw SysError(format("linking `%1%' to `%2%'") % p % *i); - StringSink sink; - dumpPath(*i, sink); - StringSource source(sink.s); - restorePath(p, source); - } - - regularInputPaths.insert(*i); - } + dirsInChroot[*i] = *i; } /* If we're repairing, checking or rebuilding part of a