Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp218377pxp; Wed, 9 Mar 2022 01:14:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQjz2mHpBlRjJPHEpT8JQlfk6FJWEuH0nR6xKIIdufO3k8n7M5v10ICvUZVgFYWZeQ1xAA X-Received: by 2002:a50:cc89:0:b0:400:8f82:99e8 with SMTP id q9-20020a50cc89000000b004008f8299e8mr20177489edi.7.1646817284115; Wed, 09 Mar 2022 01:14:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646817284; cv=none; d=google.com; s=arc-20160816; b=R8NbW1nUhOThX5LNJ0zR1SB5ZY1GSvcCJV3D9buuYh5s4wKMOAxzzXAKpkDgcLL6Gz Wr+cB2Xa14oTECKzOMQW85p2CabQIhOQQJnC8g4jOMicsKpCpdxd1IfDJaMTfVQOJ/es XQC7AlIdsY4SCJaIWbJe79GbN0pBD9wVbGLeARbJ0wxvq7RzzUXn77ZevfyQoN2dkpxe 6DCcfUVrF5OxTBTqJC0fnDEfD8tmQ2WrbaL2o6vwsB+x0SwKEu91znFK4oX1ajWNl3go iwjmdHDOjizfh3gnQKGqTNE48726LJ6WWCtU+JjpTzJ7AnpTmr383E73ZX6mRiE2XG6n yREA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Y3rOL0gHar7RkL0oKqeyAciZ0ToGickmr5j7LDhhZio=; b=EyG8QJABmtIvC3eUqXhxSMzMPSEsZrTot24ZktmOoGvvoN1kUQhXfQkKrmzZL3kKGP ychzFHBh3iPuGJpRz8ljF4iWt38aV1WUZcDGkA6BwkiRcNwJ7bV/JkaHtFRJjooVzBzJ RalqgkpmLXf/Hhc7Llte88FHOEgVDOmcgufKADfWCg11uRo6g+S/Sl6fKQjFe1STvmuH AuycFrPSK69CgxsuDgzjd8DM34w/PM2AY1teu+vSiHVeX/0T4jFtXaTPWnhQ8gYXucNI qhBMBtGEOpxnY7m3m2ZyN1DzmxpXRaxznyg1XjclD3A8629iMzPKT5sz1h52dQt+8K5J R6gg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mess.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn42-20020a1709070d2a00b006db3accad43si891394ejc.519.2022.03.09.01.14.21; Wed, 09 Mar 2022 01:14:44 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231331AbiCII2P (ORCPT + 99 others); Wed, 9 Mar 2022 03:28:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229818AbiCII2O (ORCPT ); Wed, 9 Mar 2022 03:28:14 -0500 Received: from gofer.mess.org (gofer.mess.org [IPv6:2a02:8011:d000:212::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE146C12DD; Wed, 9 Mar 2022 00:27:15 -0800 (PST) Received: by gofer.mess.org (Postfix, from userid 1000) id 75846101C67; Wed, 9 Mar 2022 08:27:11 +0000 (UTC) Date: Wed, 9 Mar 2022 08:27:11 +0000 From: Sean Young To: Benjamin Tissoires Cc: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Shuah Khan , Dave Marchevsky , Joe Stringer , Tero Kristo , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH bpf-next v2 01/28] bpf: add new is_sys_admin_prog_type() helper Message-ID: References: <20220304172852.274126-1-benjamin.tissoires@redhat.com> <20220304172852.274126-2-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220304172852.274126-2-benjamin.tissoires@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Fri, Mar 04, 2022 at 06:28:25PM +0100, Benjamin Tissoires wrote: > LIRC_MODE2 does not really need net_admin capability, but only sys_admin. > > Extract a new helper for it, it will be also used for the HID bpf > implementation. > > Cc: Sean Young > Signed-off-by: Benjamin Tissoires For BPF_PROG_TYPE_LIRC_MODE2, I don't think this change will break userspace. This is called from ir-keytable(1) which is called from udev. It should have all the necessary permissions. In addition, the vast majority IR decoders are non-bpf. bpf ir decoders have very few users at the moment. Acked-by: Sean Young Sean > > --- > > new in v2 > --- > kernel/bpf/syscall.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c > index db402ebc5570..cc570891322b 100644 > --- a/kernel/bpf/syscall.c > +++ b/kernel/bpf/syscall.c > @@ -2165,7 +2165,6 @@ static bool is_net_admin_prog_type(enum bpf_prog_type prog_type) > case BPF_PROG_TYPE_LWT_SEG6LOCAL: > case BPF_PROG_TYPE_SK_SKB: > case BPF_PROG_TYPE_SK_MSG: > - case BPF_PROG_TYPE_LIRC_MODE2: > case BPF_PROG_TYPE_FLOW_DISSECTOR: > case BPF_PROG_TYPE_CGROUP_DEVICE: > case BPF_PROG_TYPE_CGROUP_SOCK: > @@ -2202,6 +2201,17 @@ static bool is_perfmon_prog_type(enum bpf_prog_type prog_type) > } > } > > +static bool is_sys_admin_prog_type(enum bpf_prog_type prog_type) > +{ > + switch (prog_type) { > + case BPF_PROG_TYPE_LIRC_MODE2: > + case BPF_PROG_TYPE_EXT: /* extends any prog */ > + return true; > + default: > + return false; > + } > +} > + > /* last field in 'union bpf_attr' used by this command */ > #define BPF_PROG_LOAD_LAST_FIELD core_relo_rec_size > > @@ -2252,6 +2262,8 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr) > return -EPERM; > if (is_perfmon_prog_type(type) && !perfmon_capable()) > return -EPERM; > + if (is_sys_admin_prog_type(type) && !capable(CAP_SYS_ADMIN)) > + return -EPERM; > > /* attach_prog_fd/attach_btf_obj_fd can specify fd of either bpf_prog > * or btf, we need to check which one it is > -- > 2.35.1