Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2742010rwd; Fri, 2 Jun 2023 14:06:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6+NKPsDfPyREpl4WR1BRqdyEicHRsikdiKOGOaizraqFFo/jSOQhxQXEd6GfhAzpBwYjjD X-Received: by 2002:a17:90b:38cd:b0:256:6e9b:1398 with SMTP id nn13-20020a17090b38cd00b002566e9b1398mr852375pjb.2.1685739998847; Fri, 02 Jun 2023 14:06:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685739998; cv=none; d=google.com; s=arc-20160816; b=Y9Lh0mYBz1ZpHvMWWbYZuRFj/WMgVoffii4ipe/dwSW7uwubVbvCrpEXYIuuumD4pU J+2pV0DJyLnCF2O0HCXK7ZBDX+wcHuYLF4fN8JckfK3ScLqLwMqfJQP7hQ3xgqGfiy3l iNrexcC4PxtRAK5o0VeZY2vU22tFBGfZvXc5qJJsiEfrjMZ7TjK8n76fB7kk7tyzAlc3 KX6/Mmdccvq92sdusaBbxsLr0VXi/1eWUNm5eZb8In4jiy8Ug2MdcgtNtgj+S5rOGzlI g/e+3QekxAL0JtPeyfXUr64fixxr9KO96i+k1xQasS2miLiK0OFbCb/Y2rGhA6dy1Qom MDug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=kRGX/7FVcKXywnk21BiSZROJV8xYMUqrqkGkpYOfQwY=; b=g+NnfBiD1t+4tsM2BbopYNm9lA3rQWRPHYSfQNkEN44VqsKAEUqB91JM7TkWkdw06q HF8jmq7X4w0BV+IGAvQvxwCylOTcHvhuvS1yNyt29F/mxSjb4TTmFtLtLJYb+H9emlkl dFSOKpqcuOYzvax8+YBTB12dnv48+FfpBvvlydnscaWR4wVXoi2EGQMfj6oHZIT0c0jX ieyCF8O4Q+izuvegeJtEQ0rmiYzAjRPLZHtgzqiQOmh2u432Ql+1yDty+cVHCKJgXDOJ cmpUTMdSzzFabg5fhkPw8eu1C+lOPR1QLjkzY4BFqqKnQlOpVdeWDj7cWGmGRWW2roV9 iRUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="Oy8N/RIk"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j12-20020a17090a94cc00b002535e5e607asi1530245pjw.150.2023.06.02.14.06.24; Fri, 02 Jun 2023 14:06:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="Oy8N/RIk"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236225AbjFBVCp (ORCPT + 99 others); Fri, 2 Jun 2023 17:02:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235898AbjFBVCo (ORCPT ); Fri, 2 Jun 2023 17:02:44 -0400 Received: from mail-yb1-xb2d.google.com (mail-yb1-xb2d.google.com [IPv6:2607:f8b0:4864:20::b2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F651197 for ; Fri, 2 Jun 2023 14:02:43 -0700 (PDT) Received: by mail-yb1-xb2d.google.com with SMTP id 3f1490d57ef6-ba818eb96dcso2398041276.0 for ; Fri, 02 Jun 2023 14:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685739762; x=1688331762; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kRGX/7FVcKXywnk21BiSZROJV8xYMUqrqkGkpYOfQwY=; b=Oy8N/RIkZHE7Ca9DK2TAOVdN2mdqX2GzIN7en9kr0rJrnFR8LesI5uLuIhIOC35YeC OAD57nZ29rcWqbpMcfv3QJadMbwAFjppOx16wbLbHLghBoYCBsxKYm9GH0EtLDuajuUs V2nrkwKtMMtjUX2I36oFib2qNyGtiTk+iWJfofKZv8V8ufmx42lhAuFYkqimMBXlzvFR hRtuu6v9yTm6b2NLfldSQZFGXfPmBAVivBRDPfvOVsLRK9qS6WGXPbZRWjKNbpZkIpw0 gxd3PkpdPEZAe2puKHcAzAqWT/3x5qdCHTIphakvoVVK8QoSsqBLrMas3nJhUmmhzOjH hs5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685739762; x=1688331762; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kRGX/7FVcKXywnk21BiSZROJV8xYMUqrqkGkpYOfQwY=; b=JLHqKlGe3SzYooXhGT9S3jB0WEbI0u3Olom5JZ0njyAhJCgd32MGVi251AtwueMKxs A3TYV8i/w5sY7CW7f3MahD04hEvX/MuwJ4XCjFikgU2D9C6vMfJH7TLFqOnFowNMrOp9 E+/r7SOWXlSauqaFZNII27iM9rdnbtkhkgsBPOem8ftJ9MU6e5Eg9vxTkeDk1FyEwWAp u3axTj10SXJGpj/ssXTlB+4ogTT0U/c5mvXvmfJ8m63XEadeAHaCbsD8KVcJROwNRTPb yh7vObC08Lmd7K9RH+hBS5NIzFrZkF67++KokdgBwNMPIjrAhbYlekpjKMUHXPiD0KTS 1EzQ== X-Gm-Message-State: AC+VfDylXcKCyUO1DoPVAKysI1EUBSfcCKBVwTHCKn1V+X06mt7DJtG9 wahVB1zEpVNfnZ2DhBlxZZlp26gqBLxXIioScX2OPQ+GjkDQqg== X-Received: by 2002:a25:ab28:0:b0:b9e:5aad:ed72 with SMTP id u37-20020a25ab28000000b00b9e5aaded72mr4084855ybi.31.1685739762435; Fri, 02 Jun 2023 14:02:42 -0700 (PDT) MIME-Version: 1.0 References: <168547265011.24337.4306067683997517082-0@git.sr.ht> <87fs7abu0f.fsf@email.froward.int.ebiederm.org> <87ilc67i95.fsf@email.froward.int.ebiederm.org> In-Reply-To: From: Akihiro Suda Date: Sat, 3 Jun 2023 06:02:30 +0900 Message-ID: Subject: Re: [PATCH linux 0/3] [PATCH] userns: add sysctl "kernel.userns_group_range" To: Paul Moore Cc: "Eric W. Biederman" , linux-kernel@vger.kernel.org, containers@lists.linux.dev, serge@hallyn.com, brauner@kernel.org, akihiro.suda.cz@hco.ntt.co.jp Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thank you all for feedbacks, > (Paul) > Given the challenges around adding access controls to userns > operations, have you considered using the LSM support that was added > upstream last year? I'll consider this. > The relevant LSM hook can be found in commit > 7cd4c5c2101c ("security, lsm: Introduce security_create_user_ns()"), > and although only SELinux currently provides an access control > implementation, there is no reason you couldn't add support for your > favorite LSM, or even just a simple BPF LSM to enforce the group > controls as you've described them here. My intent is to provide an universal knob that works for both SELinux distros and AppArmor distros. So I guess I should try to use BPF LSM (and find out how its end-user UX in the userspace can be simplified just like sysctl). --- > (Christian) > Yes. Please, no more sysctls... I'll try to find another way, such as (BPF) LSM. --- > (Eric) > How does this functionally differ from what already exists > user.max_user_namespaces? My patch is not about the numbers of the UserNS, but about who is permitted to create UserNS, which can be a potential attack surface to pwn the root in the initial User= NS. > Given that setns exists I don't see limiting creation of user namespaces > by group being meaningful, if your goal is to reduce the attack surface > of the kernel to mitigate potential kernel vulnerabilities. Yes, that's my goal. The intent is to allow creating UserNS only for (semi-trusted) human users who need to run unprivileged (aka rootless) containers. Creating UserNS is expected to be prohibited for system daemon accounts and human users who do not need (or who are not trusted enough) to run containers. This configuration should be more secure than just allowing everybody to run unprivileged (aka rootless) containers, and also more secure than just disabling UserNS and running everything as the root. > How does this functionality interact with the use of setgroups in a user > namespace? > > What is the value of a group_range inside of a newly created user > namespace? How does that work to maintain the policy you are trying to > implement? In a child UserNS, the group_range file is expected to use the mapped IDs, not the initial UserNS IDs. (So, the range can't be just initialized with `.range =3D {0, ((gid_t)~0U) - 1}`. My patch v1 is wrong.) > Paul are you aware that the LSM hook can not be used to achieve the > objective of this patchset? What would be an obstacle to using an LSM hook for this? (with an addition of GID checks) 2023=E5=B9=B46=E6=9C=882=E6=97=A5(=E9=87=91) 23:50 Paul Moore : > > On Thu, Jun 1, 2023 at 9:41=E2=80=AFPM Eric W. Biederman wrote: > > Paul Moore writes: > > > On Thu, Jun 1, 2023 at 8:14=E2=80=AFPM Eric W. Biederman wrote: > > >> Paul Moore writes: > > >> > > > >> > Given the challenges around adding access controls to userns > > >> > operations, have you considered using the LSM support that was add= ed > > >> > upstream last year? The relevant LSM hook can be found in commit > > >> > 7cd4c5c2101c ("security, lsm: Introduce security_create_user_ns()"= ), > > >> > > >> Paul how have you handled the real world regression I reported again= st > > >> chromium? > > > > > > I don't track chromium development. > > > > You have chosen to be the maintainer and I reported it to you. > > I just dug through all of the mail I've received from you over the > past two (?) years, as well as checking the LSM archive on lore and I > don't see any bug reports from you directed at the upstream LSM or > SELinux code ... perhaps I missed something, do you have a pointer? > > Also, for the sake of clarification, I do not maintain any part of > Chromium or Chrome OS. I do maintain the upstream LSM, SELinux, > audit, and labeled networking subsystems in the Linux Kernel as well > as a couple of userspace packages. > > > >> Paul are you aware that the LSM hook can not be used to achieve the > > >> objective of this patchset? > > > > > > /me shrugs > > > > [snip parts about performing a group id check] > > My comments here were only discussing the possibility of performing a > group ID based access control check; I made no claims about the > desirability of such a check, and I have no interest in rehashing our > old debates. > > -- > paul-moore.com