Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2164363rwb; Thu, 19 Jan 2023 22:16:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXvWovWOPjwWD/ZMKg9UWV4aTC9dWKfuqF7k99u05p6dvziOMv1XZnjIGMr3Lwa3eM6IvhqD X-Received: by 2002:a17:907:20db:b0:7c1:7226:c936 with SMTP id qq27-20020a17090720db00b007c17226c936mr13476452ejb.64.1674195391811; Thu, 19 Jan 2023 22:16:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674195391; cv=none; d=google.com; s=arc-20160816; b=QnYlcO9xVR5GoKjBTcpAWZQQEYZ3vEhKzdSkSgu6ZWcRH+oKE/S/BWhL3TTkOR3+Mf 6v0adKkOG2rbqUgBr844OGDnqPLlVKZxiGdZQajUvTjASlL6oONxXM4X9apmeuHX9fE1 H/6wfUJ7qRVuP8ZYJAsSoOjE3Ui9tAhQMuJqaU8qToZabKT0eDVa3DSW+pF4zOA8y1Ax na9U7yhNRGT2ZOMv2KLaI2Qsr82LX9vcciNqAzBuCq7hRgG52oVHQU4mdq/nraw7fVJK fNbQZwDmvW1BM83eT+AFuUco/5lw03YkHGW7EsZhQbC/Y1KDAbSTYy739H3V3rhTJGHF /pGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=NG5+tmHyXpekUMb9UX3El+JSGlQkPkl7YXC+PKgRDIY=; b=ujq6D6rSlHe0qJYh5V8CorqG6HkTPXhpYSLvd4PHlFJ60n1queNSFvvS3RnNJ4H2ek TvuOuDz9KKZKJdH6yNCt2L5dtVvrfxjR1Y1iEtN6F2AsB9S2R/35o8WP8iH4KgBc+Qt2 YZr2LAHcLCiojhIrSaUDD968AhjL6U0HEu2yklQQ+Mg5YFYBcRQQpfPdnuRrOL67QEP7 1zQQGivzpyXgG4APJAoUv5M1r5bJkb/61S6OB24Zy7zobj/pWyqjv2HFwwecUbfBm1s+ tVcy0OBqk1F3iZuBMfw+gAQC8KqRXRnZYCgAR5yCVBUEJ7Az8v7PrYlMTch111EC/iTP zjyg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs11-20020a170906dc8b00b00877876d372fsi3022159ejc.411.2023.01.19.22.16.19; Thu, 19 Jan 2023 22:16:31 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231577AbjATFvI (ORCPT + 47 others); Fri, 20 Jan 2023 00:51:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231447AbjATFuv (ORCPT ); Fri, 20 Jan 2023 00:50:51 -0500 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 833542B63D; Thu, 19 Jan 2023 21:50:45 -0800 (PST) Received: by mail-qt1-f177.google.com with SMTP id x7so3401952qtv.13; Thu, 19 Jan 2023 21:50:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NG5+tmHyXpekUMb9UX3El+JSGlQkPkl7YXC+PKgRDIY=; b=yBueUWs1jYG+VAYxy3oP7mnl2L+tYaXa0Bd3D4cKxswCoxiCNfVcL5OlKxq+QMOTo0 KNiRvcHZn6J8AQaWlx6c9tGvYyQ+ucro3z4Lj8z/+0/oZRtEmyf1ef6Pk8vcAcVx+A05 QSpSUVqoRKf2rHb+1yrasCOxo02XH6pEAl8ceE5V2Z3kA9LAQRvayyxDySlfXcu+Gn4O abtyHhP4EyGR1967gNzErlnbi0OmzzwQOx6h5NSZ9EmGk8X6wfTMw2m3r2uX7WnyV4SQ ZbbzAQVjwyk6N9B4Lt9F3e77HQn3WK4SakVxb1L+9urYa35XlZHvS4f5iTAOny35PlAM cwBA== X-Gm-Message-State: AFqh2kqrhf291WoW63Z0jmexSgDpKJ635MJ5LH7XSU4mdgrUobddgndx ZclKPTJ/LeCvUtTty6dR172HEk9GkCu3sNWs X-Received: by 2002:ac8:760b:0:b0:3b6:8bc3:a09c with SMTP id t11-20020ac8760b000000b003b68bc3a09cmr8984984qtq.25.1674193844510; Thu, 19 Jan 2023 21:50:44 -0800 (PST) Received: from maniforge.lan ([2620:10d:c091:480::1:2fc9]) by smtp.gmail.com with ESMTPSA id do26-20020a05620a2b1a00b0070648cf78bdsm11319963qkb.54.2023.01.19.21.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 21:50:44 -0800 (PST) Date: Thu, 19 Jan 2023 23:50:47 -0600 From: David Vernet To: Alexei Starovoitov Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@meta.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, tj@kernel.org Subject: Re: [PATCH bpf-next 4/8] bpf: Enable cpumasks to be queried and used as kptrs Message-ID: References: <20230119235833.2948341-1-void@manifault.com> <20230119235833.2948341-5-void@manifault.com> <20230120054823.bldnkx5tl3jxejm3@MacBook-Pro-6.local.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230120054823.bldnkx5tl3jxejm3@MacBook-Pro-6.local.dhcp.thefacebook.com> User-Agent: Mutt/2.2.9 (2022-11-12) X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no 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 Thu, Jan 19, 2023 at 09:48:23PM -0800, Alexei Starovoitov wrote: > On Thu, Jan 19, 2023 at 05:58:29PM -0600, David Vernet wrote: > > silently check for and ignore these cases at runtime. When we have e.g. > > per-argument kfunc flags, it might be helpful to add another KF_CPU-type > > flag that specifies that the verifier should validate that it's a valid > > CPU. > > ... > > > +void bpf_cpumask_set_cpu(u32 cpu, struct bpf_cpumask *cpumask) > > +{ > > + if (!cpu_valid(cpu)) > > + return; > > + > > + cpumask_set_cpu(cpu, (struct cpumask *)cpumask); > > +} > > ... > > > +void bpf_cpumask_clear_cpu(u32 cpu, struct bpf_cpumask *cpumask) > > +{ > > + if (!cpu_valid(cpu)) > > + return; > > I don't think we'll be able to get rid of this with KF_CPU or special suffix. > The argument might be a variable and not a constant at the verification time. > We would have to allow passing unknown vars otherwise the UX will be too restrictive, > so this run-time check would have to stay. Makes sense. We'll just leave it as is then and document that passing in cpu >= nr_cpus is silently ignored for any kfunc taking a cpu argument.