From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796202605; b=pkNqpusq4dt3NoY5n/ky1Av+LXRQdDNdUn6xz9nZ9MgUw6YmOjejF64kJtSRvpLy2A9a lFo31lzuN5rdyKC1yfrb5pCRYG1iK3Vnzro6lr/0wE97A25YszuEt6YUvHaoeLBgUlVDK t+oj1pjh3mAeBLoxQayjGPqjVhdw1z0cfJRabDqC6ya6toMW8Jcgc/4GFkyupThxtLnkk ThLy8h7/tmAiQfKiyMOaL5/AbFBRof7KWX/cK14kX3TquVUy5uyR0imXssMH+UZkDEM1H lj61507/erVradpdcd6qBuNrhcSFMLnmiD5/kqFXq3PtBnogNDtJgkt6ITZiFXiHkqA== 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=RfLLpUIpZ7WRiWInOFQF1tpuW4uCFjs+qQl2/xXlQX587B2SDDk/tEF4ffxUQSW1iQFd Zr/8Bha9vtGVpgBYSiVnZ+Src+a59ZXk5xxGYveHhR9vd2/7VU5jrXXENPoA3nNrz7nQA 2uykYVqhiziPHzS7y0RjRdmHopUp8voxSo2OdtWxrI7UpNtwJ9qY1eUh52OpIeRPOodTj SqDHI2jbvCXt/iC6QJ2zk1U0LYmKYzSULtwgnzlcTrTgcFNChvSZ2Vktsq37+n9LyCDaP E59xdlcOP42aUQ2ccQSsw15x3UneDdCftzL/dDdLzMDMlZwWzZiV1eRhGGTjUbpYQQQ== 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.51 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (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 BF6D4606A31A for ; Wed, 2 Dec 2026 09:10:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BF6D4606A31A 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-f51.google.com with SMTP id a640c23a62f3a-c5127c7abd5so1951464266b.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=JyCleHcU2lfRH2lZIbbC+/D11+0oPyIEue+ePVMYfOwaXQAdmo+p00lDqeme6QMpqb uHAfLpm3Z5nmWo94H2UGBw3PiDs8foQNTXSlzpGXFMLnRf4UyY2J+pvW9a3P+e11ABEV FzZfG2yKscJv2jvrtRk08Fm/vVPCxLJDtPXngbH/GOvsEUyl4+PMc2Z6UoBDRYAg01Vz /W9uM5KuYC3UoutbLrIKdNit4Giz0ZEeliEBQBf+8xwOPaybBiXDh78k461xyvC5FJbo AjjSfaKJ85s1+DTGLGQoj4XslwmXJR2ij05rrgtGrYUk8a+thttFKMv0a9vUboxfYl0d oatg== X-Forwarded-Encrypted: i=1; AL+hErGKTYsgVqIOZhtPPSjql0fvjkC/I6/6jDrfmbaRAmH5Cv9rt1pTHk7tbcu4KBHQGqpUZPSlPgRJK/1WkMEH@vger.kernel.org X-Gm-Message-State: APuU4Z9c+avX5LP2PkHXHNCrXKtMMPIfhJlq1dcbhIzF8ot4+Vk8Pu43 iC8J6yKwqddv67L6nXQe9zdx7a+KF39L3e6wrRqHkXdf2IOFNici5ADIfIy+l3f2Lcgx X-Gm-Gg: AZFdTZcAL+tPFH02Gauf6s17n3bdZ9to/4BiKgEHQ3QLxLNIH1kcdQbaj+nyk4c6Y+q hoXd1s3xNBAMlywIm58CvLGLm0CJ8AfVYjKjvPf59QaUtPK+HkC8PM53c4+NHP2mvrs1i6OjD6Z UJhavKl+wOXudBEbR6suWOlF/7Oz+chaqVKN2UqmEjNcKk2HbCc3NbPcN3Bbsex8ueNCmkmfpf9 TfXZ9STZvZ7cr6T3oj4rxyb4X6ceceCFSWS8EkmT6h1VgnHb5ARD7YuP6tPbYC7vCVQUJ+/+TiX Op6/qKep9TJ1NF7Ewh4StPC8BnwwG0uTOU8jOS4Cp9toCnXi0YzRd4cBMj6nXVvauhmjhPfRjcz fU0qDTlDbccDMF3MxGPi6BZeZ+Ms5eNoPe00aePqj9+SyPglVxPBcKdS2YIOz2fqJaSxNv99+JG IJ21oXKOO6Mw6y8YDCWwCBFYykdCGycbUVrdQ55YSMuDMWaWVtyPj8WsTHUXBQ+Eiv6nC+pdlsE arP2+Uhyr0gtfz2vSnL8BYd0leMPCkhH65jSYeyMEkKKt/zjCpWpBt3UfCQ1LSoJW3jj900TQVj EFKrfpNaU5uJp06fbVLY7sEU/oKWFfdElYRJwqQTn//RpalXZd1s1j2deCWvH/c+RA== 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: linux-fsdevel@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