From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796202605; b=xGC6AP3aDelWGxi+Bufav/HaD6RemG58N7DzrDrKzlB6b3DLY8afXsIClpO4yKHSXvhH ZWm9jB/J+ioA7i/BuGFS8Zfc0VIMfgpJUamcQGa5SRR+/f2uePTFR6BxbbR6J1PnluqvP kA24Zv954TX2FFVlWsVNTNAXyxHJliJyeKMx0WCO6m1WIY+tw4v07BWUI+0c4uWZSSO51 qybXhqDqeL3vp39hu78zDfs7pxaQm1kkVTvqkMUEqkUbAUXx3ADHDUa+QDcFtsdvd6Syz cfcItX0BaCl44QRWsqxEWitTaNHKReQKJMdjJWSa9NXoCyYd3h7ebfsO/xf7NEDeNhQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796202605; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:Content-Transfer-Encoding:User-Agent:MIME-Version; bh=oz9p4VCIJWcEUPsZjj8g8XVO/iLHfTT3r95oNn2rZrI=; b=YqAaUj3yTo7dHBa8LzrToJoge7yu4oeggSPSPI5ihMUR0zLV9dnSuUeOJJeQauwUg7hZ gymIYurhCFujrH0s4WaaanM1R3mX6mfoeyXUzuvM8y0Q4P7AK9rZKEDoLmLIZgqNBxS8f l7/aOO6o83asGpDhovVW93dHZqGyz5tqT80BmgcN8e2PaesgXfZUjEXXz16gns3gMeDBZ Kedy5lJ4oMTl2++IjZ9+coiA0fSkfUzNkgwNtg9E8CE7BXkCjBaUrSmwrXARwXK6J/Awu twHc0+uCrfvgnlBEQ8YIQoa8gGTmWufrIt+cC3U7Dmv4nvW0/TuHgm/0XBddg7Pw1Lw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=amutable.com; spf=pass smtp.mailfrom=amutable.com; dkim=pass header.d=amutable-com.20260707.gappssmtp.com header.i=@amutable-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b="E4n/bxXx"; arc=none smtp.remote-ip=209.85.218.50 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDD53606A325 for ; Wed, 2 Dec 2026 09:10:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CDD53606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=amutable.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amutable.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amutable-com.20260707.gappssmtp.com header.i=@amutable-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=E4n/bxXx Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-c5127c7abd5so1951464066b.3 for ; Wed, 02 Dec 2026 01:10:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amutable-com.20260707.gappssmtp.com; s=20260707; t=1796202603; x=1796807403; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to:content-type; bh=oz9p4VCIJWcEUPsZjj8g8XVO/iLHfTT3r95oNn2rZrI=; b=E4n/bxXxMFqwHT5S8Rv3A3LuzgEeS4Vp/IHDB1KCYKYa2iawQzcO0+yIyKotWo/gFa Es6Zz9iA4ig697W1d5u518XeJ+AvWW4yjd5U1ggG/i3sHb5qAXkiIOEjFQTvcb1VYvdq 8jS0WWZWLQP6Dmlx4h4xH+fcdyWlo9C958X60ki1tvIxjdQBxsfBcEfzZNGfU7Uj0Lyi 7IN+/5CiNjTrmoIDcNenawGRhlOUFS21/ufnZhAG+UCnQCHyilP4LatQcjRC676wSO+n dlD1zgjEL/WA6BLeMQxq87aGYG8f8blXgnjYacAphqLevg8o7DEpaBwJiiBCbP+CsjTk Av8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796202603; x=1796807403; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=oz9p4VCIJWcEUPsZjj8g8XVO/iLHfTT3r95oNn2rZrI=; b=cBVNZlGSRVQd2dXdVxhLDBcN7xqobv/SKic/pQkxdaT0Z2lZvOrdWwTsv1DjTUuqSs aokO8kNquwdFV2xOI4qajQLdxbO+afdPiluBrqPWTle11ELmZrfU2L9sUEsnn+d1Cmoi czTXHAf9M89DKdot9hD3F5TvsopaKSFFyKPIv0KHwivL8Zgmp5VDnewxCuwGJs6Rw5da vYYeX8A3uhOmPAtqoieTrXRb3JRvoCYAnQxGS5ou3fp7A5hvqy5EvNgQ306DjwmjSw5s ik34EHfzqBI7LVpgGwcmX3vlWelowjTSOat9r+qOZNRQBjyqVjBkbOOVuPei8dDh/cje kb7Q== X-Forwarded-Encrypted: i=1; AL+hErHVBsBz1u5TxabCo5MyQsl/Wtrs2tQeapqQISfZQRrkxx9QnrzLmvqYj2biY/PcMr9IVb7uQ4o=@vger.kernel.org X-Gm-Message-State: APuU4Z83uUl8tST1frJJ7n6F1/eYhqFTHQHnkNPyhl35K6vBq6RIDABp Ec4dkYjK04/vR9/oMkY1B0FB6hu9KyIHz60miBII7wRdG1WIDnYBsxCaWlem6tS1qOUT X-Gm-Gg: AZFdTZfgc0W02316wNjhaDB6o1xK95syOKthcF/FVYNOMTm/Bq0pG+c/NrfgvnR6jUR YfoY5wqC4vO8DG9Pp7EPfMK0Rt1WOV90sI4dZCPUfrR5kRhjVZQNYxXhJt+eDy72TSKou2LnTkY E0uDFVcYe3yWzqEtZeZsM4wf9z/HtKhGO7jrkp5ZaWnAAGF7UtcC2tGmt9899/WZ1aDT6NoIDfl kFswdpa4nuRbeCKYgLnRNtbUrsoJsyvGxLu/LlsKEKCXk8hpSuBplfeaYp5dNFKO69uPzODvrxv DWEBnNO635IKPQn9o//qAEI1xdo6hg8F4lOoBOShOMS5U/6kh/UTQQYo/M/qjCASI2f6cakpLfe HIERFUJlBLLexXmB4ELZwsWi1dbo7a9e9eanDG6ptx0BZhAAnXMw8RlDccguZjzElpMOs9BrZXW 6Urt3LJEtpcYlafeFChJttm4YvcihwCA3hL9Ez0COKkyiTL33ax8PDGKpm7WEo2fxV5/uUuXmok l1lUHh6klFXoeAHkfRnp0RX5T0RvOX6JK5qJTuqzUwb8kayqOntU1wrSip1fbC0tvK4Kq6tOak3 wyD0aYWMMMOQtTbWn9AKHIPz9g4ffdI/r2fA9IlE3xT3gkAsBGyvsxoVzYSrqpblLA== X-Received: by 2002:a17:906:6954:b0:c25:504a:1e25 with SMTP id a640c23a62f3a-c513a5ebc65mr2496612666b.13.1796202603083; Wed, 02 Dec 2026 01:10:03 -0800 (PST) Received: from [10.0.0.233] (tmo-084-240.customers.d1-online.com. [80.187.84.240]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513b01e242sm1286561966b.82.2026.12.02.01.10.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 01:10:02 -0800 (PST) Message-ID: <7a6173cc3cce42a100b202dfbc50587134ceafdb.camel@amutable.com> Subject: Re: [PATCH 0/4] namespaces: close two ways out of a chroot From: Alexander Mikhalitsyn To: Christian Brauner , linux-fsdevel@vger.kernel.org Cc: Jann Horn , Josef Bacik , Serge Hallyn , linux-kernel@vger.kernel.org, Alexander Viro , Jan Kara , stable@vger.kernel.org, Ozan =?UTF-8?Q?A=C4=9Fdepe?= "(NullSecurityX)" , Forest Huang Date: Wed, 02 Dec 2026 10:10:01 +0100 In-Reply-To: <20261201-work-mount-empty_mntns_chroot-v1-0-070c96c234bc@kernel.org> References: <20261201-work-mount-empty_mntns_chroot-v1-0-070c96c234bc@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2-0+deb13u1 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Tue, 2026-12-01 at 13:37 +0100, Christian Brauner wrote: > CLONE_EMPTY_MNTNS lets a chrooted caller with only CAP_SYS_ADMIN > reset > its root to the empty root of a new mount namespace. That doesn't > make > any files reachable but afterwards the caller isn't chrooted anymore > and > can create user namespaces again. setns() requires CAP_SYS_CHROOT for > the same thing. So require it here as well if the caller is chrooted. >=20 > Ozan pointed out that joining a user namespace never got the chroot > restriction that creating one has. A chrooted task without any > capabilities can setns() into a user namespace owned by its uid that > some unchrooted process created and chroot() its way out. That one is > a > lot older. Refuse it unless the caller has CAP_SYS_CHROOT in its > current > user namespace, i.e., unless it could chroot() its way out anyway. >=20 > A task without CAP_SYS_CHROOT that setns()es into a user namespace > from > inside a chroot gets EPERM now. Creating one there already fails so I > don't expect anyone to rely on that. >=20 > Both come with selftests. >=20 > Signed-off-by: Christian Brauner (Amutable) LGTM Reviewed-by: Alexander Mikhalitsyn > --- > Christian Brauner (4): > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 user: don't let a chrooted task join a use= r namespace > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mount: don't let an empty mount namespace = undo a chroot > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 selftests/namespaces: test joining a user = namespace from a > chroot > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 selftests/filesystems: test empty mount na= mespaces from a > chroot >=20 > =C2=A0fs/namespace.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 |=C2=A0=C2=A0 9 ++ > =C2=A0kernel/user_namespace.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 9 ++ > =C2=A0.../empty_mntns/clone3_empty_mntns_test.c=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 36 ++++++ > =C2=A0.../filesystems/empty_mntns/empty_mntns.h=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 18 +++ > =C2=A0.../filesystems/empty_mntns/empty_mntns_test.c=C2=A0=C2=A0=C2=A0=C2= =A0 |=C2=A0 85 > ++++++++++++++ > =C2=A0.../selftests/filesystems/failfs/failfs_test.c=C2=A0=C2=A0=C2=A0=C2= =A0 |=C2=A0 38 +++++++ > =C2=A0tools/testing/selftests/namespaces/.gitignore=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 |=C2=A0=C2=A0 1 + > =C2=A0tools/testing/selftests/namespaces/Makefile=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 4 +- > =C2=A0.../selftests/namespaces/userns_chroot_test.c=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 | 124 > +++++++++++++++++++++ > =C2=A09 files changed, 323 insertions(+), 1 deletion(-) > --- > base-commit: a63f17c4cacafcc9ff8c88651b42cd62b936d729 > change-id: 20261201-work-mount-empty_mntns_chroot-7372785b88f6