Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1511580rwl; Sun, 26 Mar 2023 04:09:43 -0700 (PDT) X-Google-Smtp-Source: AKy350b249ZgqwEJjaBiMNTNxAg/MbwX47xBDGaa6jUcOAwbiAnxDX268ETc9jtU5E22GQorgniJ X-Received: by 2002:a17:906:641:b0:933:9f43:5c3b with SMTP id t1-20020a170906064100b009339f435c3bmr8960737ejb.59.1679828983593; Sun, 26 Mar 2023 04:09:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679828983; cv=none; d=google.com; s=arc-20160816; b=m3EX1Z7Fha6ypEwUkHlxNSviN9d9zbp8F1sPrEp0g0d3jR4lIeszYk8Rj4zTn3maPH Pqg1OPvlQx1T8s1lI9w+DTuxNTHf1CWMhPa5TQvZaUy+3DqGBlmdM09iA31CoXa8q6je hkEAiM5+3gP6GQSjKnAtj29gSplHnMng77fkg2Sx/Phg19kkENbDeEodZDKeGbLK19qv AFoRSMM1ijIlonUzsRuXiGHCm9zIPiBx0xeBo9x0rIJoYsKwgug9nN9qdjdpvrqgx4gs 4LtL4MnTxP5k8x8YOOAq0IK76tiPvm9lQr8Ntp9xkteHeZHjyxYbt01Q36Hr7vONzy9s 1SoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=FWItP3hOwpWW7aBA9y+qGWl+PcPoGjlIYxKdMRqtbTo=; b=czzb2OWypZfoWEpmekKmg6lxMUfExSmvsH93GNAyIZqwunGQyR97JKXw9zhsOknH0O OaJMlBtb6e9wUu9CEssDdXYLrFpowZRPRB52UY3kAxhOnjyc+BJkQ5ny3I+OntjzTJGy /n9qKxele0/cev8u+H7IGPHAULSYhlIo1xlsy54uAohCtU7eew0vSUhvt2cq101IlHyg m38JcHxY6TgUtPI6Eq4uoFMSA6iBlRPayrAk1wv0CaovZWh4JpwZ7AGjlIZq77lhWwy6 KJZMKJjZVzi/f7GOrhyTB5KveURPOt4BTgqT8KwyOofsJUlgcxFE1P6tKCyhk2AuryT1 WRQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tqHrPHv6; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n1-20020a1709062bc100b008b179adfaf5si23435856ejg.466.2023.03.26.04.09.19; Sun, 26 Mar 2023 04:09:43 -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=@kernel.org header.s=k20201202 header.b=tqHrPHv6; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231777AbjCZKuB (ORCPT + 99 others); Sun, 26 Mar 2023 06:50:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229640AbjCZKuA (ORCPT ); Sun, 26 Mar 2023 06:50:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 156518A74; Sun, 26 Mar 2023 03:49:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 968ED60BA0; Sun, 26 Mar 2023 10:49:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3D76C433D2; Sun, 26 Mar 2023 10:49:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679827796; bh=/zPzerCJyWN32gkIc4jdRhEwAiqgyzx8PWwuY7bpEV0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=tqHrPHv64m8uWPu1rKbDXQwubJsZxY+ecesEmgIfY761zhK7K1Q/gl/PsCN6ovSka vVJL6fJl6GkRFok8o76h7d+oj5PdPjkpko+QCix9PuwYZWdw90vIb4ji8lo99oudhB 9pmh9swYZay5fN+es3Hn2FKj4ArQktwgc5tG25wpgTU40591QhRirIqeo16F1DWudD j0JGm1HfiLrj4yLmE2LDEEMt1FEabGUN/8Hmf6uorSJqYJEJDbiZUvmf7jHh7MDJq+ AHsC/Lt1v/7jobOxRfqRBYoBLm9YXTAzIk39YIvzQKQTpbZ+gOA2SMxFBG8EGqNfGK j9R2B2QeAFyzQ== Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id CE337A22551; Sun, 26 Mar 2023 12:49:52 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Yafang Shao , ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: Re: [RFC PATCH bpf-next 00/13] bpf: Introduce BPF namespace In-Reply-To: <20230326092208.13613-1-laoar.shao@gmail.com> References: <20230326092208.13613-1-laoar.shao@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett Date: Sun, 26 Mar 2023 12:49:52 +0200 Message-ID: <87pm8v7pnz.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 Yafang Shao writes: > Currently only CAP_SYS_ADMIN can iterate BPF object IDs and convert IDs > to FDs, that's intended for BPF's security model[1]. Not only does it > prevent non-privilidged users from getting other users' bpf program, but > also it prevents the user from iterating his own bpf objects. > > In container environment, some users want to run bpf programs in their > containers. These users can run their bpf programs under CAP_BPF and > some other specific CAPs, but they can't inspect their bpf programs in a > generic way. For example, the bpftool can't be used as it requires > CAP_SYS_ADMIN. That is very inconvenient. > > Without CAP_SYS_ADMIN, the only way to get the information of a bpf object > which is not created by the process itself is with SCM_RIGHTS, that > requires each processes which created bpf object has to implement a unix > domain socket to share the fd of a bpf object between different > processes, that is really trivial and troublesome. > > Hence we need a better mechanism to get bpf object info without > CAP_SYS_ADMIN. > > BPF namespace is introduced in this patchset with an attempt to remove > the CAP_SYS_ADMIN requirement. The user can create bpf map, prog and > link in a specific bpf namespace, then these bpf objects will not be > visible to the users in a different bpf namespace. But these bpf > objects are visible to its parent bpf namespace, so the sys admin can > still iterate and inspect them. > > BPF namespace is similar to PID namespace, and the bpf objects are > similar to tasks, so BPF namespace is very easy to understand. These > patchset only implements BPF namespace for bpf map, prog and link. In the > future we may extend it to other bpf objects like btf, bpffs and etc. May? I think we should cover all of the existing BPF objects from the beginning here, or we may miss important interactions that will invalidate the whole idea. In particular, I'm a little worried about the interaction between namespaces and bpffs; what happens if you're in a bpf namespace and you try to read a BPF object from a bpffs that belongs to a different namespace? Does the operation fail? Is the object hidden entirely? Something else? -Toke