From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id eC0PFGOT8mJwUgAAbAwnHQ (envelope-from ) for ; Tue, 09 Aug 2022 19:03:31 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id CE7iEmOT8mLfXQAAG6o9tA (envelope-from ) for ; Tue, 09 Aug 2022 19:03:31 +0200 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 F340DB351 for ; Tue, 9 Aug 2022 19:03:30 +0200 (CEST) Received: from localhost ([::1]:57680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLSde-00048T-0Z for larch@yhetil.org; Tue, 09 Aug 2022 13:03:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLSd4-00047S-66 for guix-devel@gnu.org; Tue, 09 Aug 2022 13:02:55 -0400 Received: from sender4-of-o50.zoho.com ([136.143.188.50]:21069) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLSd1-0001Wi-9G for guix-devel@gnu.org; Tue, 09 Aug 2022 13:02:53 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1660064563; cv=none; d=zohomail.com; s=zohoarc; b=m/4Ma53j+8bj9m2FHk+9AHaMwr7/+ik1cR7Kikdc2/ox5AIaN6/OyZZib/NVfVCH2eFZY3/uRf6LDpVCvkhlXhGM/M1T1DlTq4dgcErW+h6MVWFh9IbEV1iqmnmmqNOjkRCaOLmryCcp6NRxDrwjoOMLZRKPscgWZNoVfGqHV88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660064563; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=7s+hPi8tpqizU4b1rSkPfZ8NaK0LOLiJ9LFNJ15fE+8=; b=HKGi7fOr9A8jSxPPWH15lGmn1I09vHAJcwdzIoL4DfEnoFAu2pqTfjFSKOQnqKVO9FsVHWV4txg/atTPO+ewyazTDesc5JFphieMvP7Y184IJWHoKXLznkC5k5dp5OH8qr2gwHOVIRBhzEuQxobFqtDt5XqUiNnv7cDjqc6qhXU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1660064563; s=zoho; d=elephly.net; i=rekado@elephly.net; h=References:From:From:To:To:Subject:Subject:Date:Date:In-reply-to:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To:Cc; bh=7s+hPi8tpqizU4b1rSkPfZ8NaK0LOLiJ9LFNJ15fE+8=; b=Dn8Cpco6f57rUJ7mSF28mAGIgqErWl+/paMmQm76ks2u8uAL4d++nBLKqyU/seiK pKV8APPn5SN1A/0EkOWbhN8r0Q9fXncDaHWD4gLZVT1jzRmmUOHLcCNKm79ez42R427 N7lzgelkYocxndgDCUxSKb0ldPufy686iAchAXDg= Received: from localhost (i5E862C49.versanet.de [94.134.44.73]) by mx.zohomail.com with SMTPS id 1660064561237490.3969485375512; Tue, 9 Aug 2022 10:02:41 -0700 (PDT) References: <87y1vxv2q3.fsf@elephly.net> User-agent: mu4e 1.8.7; emacs 28.1 From: Ricardo Wurmus To: guix-devel@gnu.org Subject: Re: =?utf-8?Q?=E2=80=9Cguix?= system =?utf-8?Q?container=E2=80=9D?= script must run as root Date: Tue, 09 Aug 2022 18:23:14 +0200 In-reply-to: <87y1vxv2q3.fsf@elephly.net> X-URL: https://elephly.net X-PGP-Key: https://elephly.net/rekado.pubkey X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC Message-ID: <87tu6luz81.fsf@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Received-SPF: pass client-ip=136.143.188.50; envelope-from=rekado@elephly.net; helo=sender4-of-o50.zoho.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1660064611; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=7s+hPi8tpqizU4b1rSkPfZ8NaK0LOLiJ9LFNJ15fE+8=; b=XGKMJouGA61mJjYXqRxzVjS6HsE6LG/XoGyivxnatqeivoCa/0oDMYqfIl+CtSVtlALkuk tqoN3c6EP/Nd6uDbOlXl64GbZsG8mn6AB/nujhtFKlmTxqNiy9hNHKdTWEMssiZUcSgYek NtjuOH+LFeM1Yl+yvT2rI7l8lzva6NWs67EVWS7wElE+uq37wiDigJhJKEYkvmyY8R9FfQ EE9LEMFMhYH929keoSxxzRiNLja1Be8IV0satGDPR9gSFqkB4cYhFNazI3m6stjzW3IQnH 4Dt/jECsNmWvq7MKUo6ibdLY56/bsAf//GCETMuTpo28TZvlLoQW7h3H7KGfaw== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1660064611; a=rsa-sha256; cv=pass; b=JpTlIhQdVoDfv/FoeMITWwnWlxHvX/dRWVrPz57JJNuN3KwKnUd68hgoK3yvl/jWX5oHav HTrCWZGAuvFalg2XOgsG4j2WQfbgqatN7ll0Qf59tAZASMT7zhkGcAm7FdeCr95+qFKlLX FQbbDyq/nUe6lIougne3Omq2HK2U+uMKpTlxH8CVTaRzq/h+c0RmmCpBLZ3naN1DaX7+RT S9N1d19OvzFVj9BmSyBUc8NwiTW+fkYoNTAF6pthNhPp/JwoyIaBEPKkpzpYBfFI0O5HDg 6E5YpqfyZTiQ28icpJ3S+Q0KPxyBc8zYcXXfXFHtIbRTVFte36+qHkqOqdmNmg== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=elephly.net header.s=zoho header.b=Dn8Cpco6; arc=pass ("zohomail.com:s=zohoarc:i=1"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.39 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=elephly.net header.s=zoho header.b=Dn8Cpco6; arc=pass ("zohomail.com:s=zohoarc:i=1"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: F340DB351 X-Spam-Score: -4.39 X-Migadu-Scanner: scn1.migadu.com X-TUID: hi7J3Fro+BUS Ricardo Wurmus writes: > Hi Guix, > > I see that the container script generated by =E2=80=9Cguix system contain= er=E2=80=9D > must be run as root. Looking at =E2=80=9Cinitialize-user-namespace=E2=80= =9D in (gnu > build linux-container) there is conditional code to be executed only > when running as an unprivileged user, namely writing to > /proc/pid/setgroups. This makes me think that this was originally meant > to be usable without root privileges. > > Without root privileges write access to /proc/pid/* is denied. The > child process here is the result of issuing a clone syscall. > > Why can=E2=80=99t the parent process write to the child=E2=80=99s /proc/p= id/* files? =E2=80=9Cman 7 user_namespaces=E2=80=9D explains what conditions must be me= t for a parent process to write to /proc/childpid/uid_map. There are many conditions that could lead to EPERM. It seems that writing to /proc/pid/setgroups succeeds and only writing to uid_map and gid_map fails. The parent process should be able to write to these files at least once; as the parent it should have the capabilities CAP_SETUID and CAP_SETGID in the child process namespace. --=20 Ricardo