Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7929588rwp; Wed, 19 Jul 2023 02:31:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlHvHBmjqUOTzIIAaK9ckAVFTuvYUQGntE1IFAYOHuLouwfBXvQybsYPmSOjpbPUz6r0g5MX X-Received: by 2002:a17:903:48c:b0:1b8:7483:d47a with SMTP id jj12-20020a170903048c00b001b87483d47amr14144596plb.37.1689759112452; Wed, 19 Jul 2023 02:31:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689759112; cv=none; d=google.com; s=arc-20160816; b=df4RUvmyPnj7AIxCGGEVNmWKtaPh0kejS2w3vDJ2IcSsMzMrQDy36xGbKH4ZQaXzOd yHuQ1T0aYhy+PkV5redIYfumcNrW/rmaAgLcUspf1yZlsuKzl6CnFIocjm7SQW5B8+FL HuV74/R/uPTsZf6qgyGyALwmYap9eazuBSt2XAej1qhATKuese6ioc2Pmo60MFHStULE 1vuZZe8XsELJP5bGtSOcNu/GkHoSxs2e07wIbs+/g6CZ/pI+clVUtsFQpleOrVV4mdFP qU3gJsCGqIA26PWCneU78MDVZaCmcgRw4jqwl78mqdZ3V9cm4A3GEJYBO99W9mAse82m Y+QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=N+yJnAl3CCQWb/mfN2f4CLcTItvIXBeaPFFTQ42Alt4=; fh=2sg2q7H8sim4Fm1AbvHvV4k3HSKIwWA7VUbqHVkgvXY=; b=jyMQP+mHEJiC6dQmBLk0ZYjfWyoWBhoXjhW6tSaOJMaxkP9eeSJgUpE8/HI2mfdQnw STfi3gSoGRUA8/3s8YF/hwcpivhFicSQeIBXhS+E/vUSyla6Gxfusl5ITwl5t81Pd/WB nFNuvVtW4h3SiiGwsbsO4Rmqyu27GNsdfB4fqc5s7yWJIDT9Sf68YgY1BNZ6eFTjCnMU lisQ1xKcdXllc4VwZMLz/pnCuEbXkwY/Apk8xlfF3d3nO+tzuAy1e778uRHSuNLR+P3o ubiiLdIMPDe4gAdJksTCoYG+QmP62yP4lll8rUvg2M0GRJkx+HDEJbk/0DjiRcwVl16l 52Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@isovalent.com header.s=google header.b=Qe1Qo1A7; 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=isovalent.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b6-20020a170902650600b001b9d2982362si3149826plk.36.2023.07.19.02.31.40; Wed, 19 Jul 2023 02:31:52 -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=@isovalent.com header.s=google header.b=Qe1Qo1A7; 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=isovalent.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229681AbjGSJ2o (ORCPT + 99 others); Wed, 19 Jul 2023 05:28:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbjGSJ2n (ORCPT ); Wed, 19 Jul 2023 05:28:43 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C59F410D4 for ; Wed, 19 Jul 2023 02:28:41 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbfa811667so3441415e9.1 for ; Wed, 19 Jul 2023 02:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent.com; s=google; t=1689758920; x=1692350920; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=N+yJnAl3CCQWb/mfN2f4CLcTItvIXBeaPFFTQ42Alt4=; b=Qe1Qo1A7lFJd+xdiu0BpKr3r4b11oInJMbPdUPdeGVEAn/xYpXOe+H62t77qy6lQSZ vj1+XLOVcE8I3Mk9DsdeaTX+Y9F8VQTxAcSlz/SGwKCz+2Us5XNKpLB9YnbLBmLd0zdS 5O06IWhhEl2Bv7sa+dlOVNlqzHbYdPhhyzTwOtTmIykJik1tRgOmYMJJ6pAhTDJz9T3G 5uWdu8RBJ93xk7Rs6mQTd2V5KCbGDaxx0eJ59e1YVzoMuw70td6cf0n4AYqeLECPPotf E1UT/biMKw7XPC/PaVA7kFCioo3p46bfsRn5H6BWdFP1mN8tL3m1A8jUs720p2mCgCTo lDBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689758920; x=1692350920; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=N+yJnAl3CCQWb/mfN2f4CLcTItvIXBeaPFFTQ42Alt4=; b=NtQoKDhnIBpennhtB1SY21qLHrd4FmqDiV8RvkbGpUaIPcOdZhoNr3MX6eAqdV2sOb Gp84R4tChmNWAwEpiI9JJTmNVmmkkaNoJCyBn5zRzX9/06oEhYihTbQoQcCJeHDraRIN Dfo1t9wIK02lm1G3bErn++1J94oXIbjel887tTntoZBjTDGNA6lnoNkYgkeGTTCxg02c SqQlNlFTJHx9A96p+1ZjTqI2P0BVP4woqIJFwi3Cz/65DhpkZB2lUtBUVs2s+MloBhgF kKXfgTDGKZ+KMT1rNMRMrfmw+4N5gyjMb+cftIeTTdSttaZTWJnCxVRBXXkslSmcvBcb SqXw== X-Gm-Message-State: ABy/qLZ6HdeIkJiNd65DRWYySULeo7QsVMmjVNIPm1sXTZ+NnBRS8y86 iNZt7sqwRI5zh4sEog80a5L0Eg== X-Received: by 2002:adf:db52:0:b0:314:3f86:dd9f with SMTP id f18-20020adfdb52000000b003143f86dd9fmr1311078wrj.25.1689758920131; Wed, 19 Jul 2023 02:28:40 -0700 (PDT) Received: from zh-lab-node-5.home ([2a02:168:f656:0:1ac0:4dff:fe0f:3782]) by smtp.gmail.com with ESMTPSA id r18-20020adff112000000b0031435c2600esm4857213wro.79.2023.07.19.02.28.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 02:28:39 -0700 (PDT) From: Anton Protopopov To: Martin KaFai Lau , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , Hou Tao , Joe Stringer , Anton Protopopov , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 bpf-next 0/4] allow bpf_map_sum_elem_count for all program types Date: Wed, 19 Jul 2023 09:29:48 +0000 Message-Id: <20230719092952.41202-1-aspsk@isovalent.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 This series is a follow up to the recent change [1] which added per-cpu insert/delete statistics for maps. The bpf_map_sum_elem_count kfunc presented in the original series was only available to tracing programs, so let's make it available to all. The first patch makes types listed in the reg2btf_ids[] array to be considered trusted by kfuncs. The second patch allows to treat CONST_PTR_TO_MAP as trusted pointers from kfunc's point of view by adding it to the reg2btf_ids[] array. The third patch adds missing const to the map argument of the bpf_map_sum_elem_count kfunc. The fourth patch registers the bpf_map_sum_elem_count for all programs, and patches selftests correspondingly. [1] https://lore.kernel.org/bpf/20230705160139.19967-1-aspsk@isovalent.com/ v1 -> v2: * treat the whole reg2btf_ids array as trusted (Alexei) Anton Protopopov (4): bpf: consider types listed in reg2btf_ids as trusted bpf: consider CONST_PTR_TO_MAP as trusted pointer to struct bpf_map bpf: make an argument const in the bpf_map_sum_elem_count kfunc bpf: allow any program to use the bpf_map_sum_elem_count kfunc include/linux/btf_ids.h | 1 + kernel/bpf/map_iter.c | 7 +++--- kernel/bpf/verifier.c | 22 +++++++++++-------- .../selftests/bpf/progs/map_ptr_kern.c | 5 +++++ 4 files changed, 22 insertions(+), 13 deletions(-) -- 2.34.1