From patchwork Tue Oct 27 23:36:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 316172 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F0A5C388F9 for ; Wed, 28 Oct 2020 01:38:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1FCFA21D41 for ; Wed, 28 Oct 2020 01:38:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cPblheka" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725964AbgJ1BiX (ORCPT ); Tue, 27 Oct 2020 21:38:23 -0400 Received: from mail-qv1-f74.google.com ([209.85.219.74]:50442 "EHLO mail-qv1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1833022AbgJ0XhA (ORCPT ); Tue, 27 Oct 2020 19:37:00 -0400 Received: by mail-qv1-f74.google.com with SMTP id b16so135778qvw.17 for ; Tue, 27 Oct 2020 16:36:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=F2RvHgXC3oKHdz1O4cGcgeyiXW9DkqTo75Q0ru83S58=; b=cPblheka8Zz576kOfWYGh7klThOUEF4vx0mwSf7z8wZsk0vKsTbArthcnN8pU+OarF +fmv0FbkiWBXYExERS3fX2JTfXeaaSSJzVK93W9SPlCJ1FgPfQ4mEyZce6QVM4QF0UiF 16uzikCzugSzRrdTii0O7dkozRruYIPBSlc0l6Gal3cXt2shJPyrTOzLe2iuhwLu+VGe Y2ELYr/GIWz3d1P2MKCHhx+976agOMlGiI2CzZu0lgJuNiy6DIg9Ukx3gcNInlSWxvQj qvhO+h+0UflqdiKTgbkJs84ONO8AJVL3kjVRhQYs2kWbkx1JAopv05BfoO88vi5kbX2K KVUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=F2RvHgXC3oKHdz1O4cGcgeyiXW9DkqTo75Q0ru83S58=; b=iCo7ooxpKts5WDNAs/nxJk5T6BE3YEBiH6roPCmV1hQxj6apJxPZUqjkLFuS/0tvaP 2QmeIXDyKqU8B1PHXbC6a80FW3AqVd0fx4a4kZX2gI+xPZWClNmuo1d7KmpQtB2lmsru 6bWbNXBKpE+IXW9dqdL7w3lSkG0S10i/VhzXSL9k3plcEZ0woP8NagVaa+4lBdNwSVok EPcYtBGwxElPcpOvNHiAD3IiV5s1sHChSmAq4/SSVS1P8oyoci32Hn9aW4whrY1qxo60 MJQpD95TibMNITag790bG1FgdeOfDlSNRY2dRCURj502nH7b9AHkm5wSv99J/CQiwUuv IKUQ== X-Gm-Message-State: AOAM531ZzJE0plQ5zM8oCegW1gZEV6Jxeey3nqEoNII1KtAm1y6LIor3 50fPaqUJomHSRjysb7HqNl8gPF1VukNe X-Google-Smtp-Source: ABdhPJxKUkk7BxVmNkh/rmJozAq6U0AfdieIdylk+jWsWElruPHkYKsXgddbtZwvxSrqgQM6GvFDzb3pyy2G Sender: "irogers via sendgmr" X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:2:f693:9fff:fef4:4583]) (user=irogers job=sendgmr) by 2002:a05:6214:1351:: with SMTP id b17mr4973338qvw.11.1603841818509; Tue, 27 Oct 2020 16:36:58 -0700 (PDT) Date: Tue, 27 Oct 2020 16:36:45 -0700 Message-Id: <20201027233646.3434896-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.0.rc2.309.g374f81d7ae-goog Subject: [PATCH 1/2] tools, bpftool: Avoid array index warnings. From: Ian Rogers To: Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Nathan Chancellor , Nick Desaulniers , Quentin Monnet , Michal Rostecki , "=?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?=" , Tobias Klauser , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Cc: Ian Rogers Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The bpf_caps array is shorter without CAP_BPF, avoid out of bounds reads if this isn't defined. Working around this avoids -Wno-array-bounds with clang. Signed-off-by: Ian Rogers Acked-by: Andrii Nakryiko Reviewed-by: Tobias Klauser --- tools/bpf/bpftool/feature.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/bpf/bpftool/feature.c b/tools/bpf/bpftool/feature.c index a43a6f10b564..359960a8f1de 100644 --- a/tools/bpf/bpftool/feature.c +++ b/tools/bpf/bpftool/feature.c @@ -843,9 +843,14 @@ static int handle_perms(void) else p_err("missing %s%s%s%s%s%s%s%srequired for full feature probing; run as root or use 'unprivileged'", capability_msg(bpf_caps, 0), +#ifdef CAP_BPF capability_msg(bpf_caps, 1), capability_msg(bpf_caps, 2), - capability_msg(bpf_caps, 3)); + capability_msg(bpf_caps, 3) +#else + "", "", "", "", "", "" +#endif /* CAP_BPF */ + ); goto exit_free; } From patchwork Tue Oct 27 23:36:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 298514 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82E7AC55179 for ; Wed, 28 Oct 2020 01:38:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4494622384 for ; Wed, 28 Oct 2020 01:38:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ti0ysnDz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725997AbgJ1BiZ (ORCPT ); Tue, 27 Oct 2020 21:38:25 -0400 Received: from mail-pl1-f201.google.com ([209.85.214.201]:50373 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1833025AbgJ0XhD (ORCPT ); Tue, 27 Oct 2020 19:37:03 -0400 Received: by mail-pl1-f201.google.com with SMTP id w4so1756603plp.17 for ; Tue, 27 Oct 2020 16:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=4a9MYiiaTByHEbKl6To5Tz0gAmU1s4D2bue8aWKymII=; b=ti0ysnDzMX8K9s3iOF6d3+2ZR/oAqISGhCt//Y8qyqRAD+FFbTBuNGhv/HfDxO0iWO Tnksd0YoilK4CS7LK0en3GtVxELV5DhrS8cpR1XC4IEjbU9qoA7CbX9fg4xVGcSZe4aY CDDrO2ZjyZhFnSVvdFL/nbOFmlZKk2d0TGMPT+qdGsuBVZhjmeKfuMIYt4dfGcFQv2iT I8t3YhyERHXCwFzAPrm9TY1WmCkybWOg7uhosZ5ze9YDVNm+FUb1s31Qwi6gwIfXF66F kpYyUxxUkNsmtGwKEV4suUGGYe56pCNYU7pj6pHyITQfO8mZsJDLMKmFuZ0bVhQHYiIq ZZJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=4a9MYiiaTByHEbKl6To5Tz0gAmU1s4D2bue8aWKymII=; b=p30XUCicxLXTaVfe0CQedSAVJdp7j7TvHG4A0IPk5FwjH/I+p1INWL//f0APXVLJ10 czplS50b28T5FwKdc8f130bDkAsljf7WcMo/oY6BMoaJqkTw1Lub7gF2Dk4JcV0LoS4T SgACSPFfAoBMfP9HYHIB3iNhJtK0P51Id7zu1CkBFtoKLy8q7Zs9kDpTr++79xSwqyhB RD33Wh8isnu0uXDyuBAPzeC4PAZxdRm2/zWfeoLbj9aj4X3049WUius7JPRIrX5YPShe C/AJMf/pm20sqbFkdyIdVZpoYo9Zeu4ttiXMAYCB+R/H0TTEZJzp3tg/CzOYrbbYFTlv 7vdA== X-Gm-Message-State: AOAM532GGuqDSwHHySklcey/34MzYbqL1XXG8cXeyGqJsp0oVk1K6Z30 1vnviPybHrPQWPdJYAsaw1pAh304QlD1 X-Google-Smtp-Source: ABdhPJyFHO0f4PxvIORwWA5M0VfCJIehQ4AlnLeaLHsxZx+/28M/X1yaGhFBvfcBbffl9uTCEYmyzwBptmWK Sender: "irogers via sendgmr" X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:2:f693:9fff:fef4:4583]) (user=irogers job=sendgmr) by 2002:a17:90a:7e0a:: with SMTP id i10mr4190504pjl.89.1603841820716; Tue, 27 Oct 2020 16:37:00 -0700 (PDT) Date: Tue, 27 Oct 2020 16:36:46 -0700 In-Reply-To: <20201027233646.3434896-1-irogers@google.com> Message-Id: <20201027233646.3434896-2-irogers@google.com> Mime-Version: 1.0 References: <20201027233646.3434896-1-irogers@google.com> X-Mailer: git-send-email 2.29.0.rc2.309.g374f81d7ae-goog Subject: [PATCH 2/2] tools, bpftool: Remove two unused variables. From: Ian Rogers To: Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Nathan Chancellor , Nick Desaulniers , Quentin Monnet , Michal Rostecki , "=?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?=" , Tobias Klauser , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Cc: Ian Rogers Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Avoid an unused variable warning. Signed-off-by: Ian Rogers Acked-by: Andrii Nakryiko Reviewed-by: Tobias Klauser --- tools/bpf/bpftool/skeleton/profiler.bpf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/bpf/bpftool/skeleton/profiler.bpf.c b/tools/bpf/bpftool/skeleton/profiler.bpf.c index 4e3512f700c0..ce5b65e07ab1 100644 --- a/tools/bpf/bpftool/skeleton/profiler.bpf.c +++ b/tools/bpf/bpftool/skeleton/profiler.bpf.c @@ -70,7 +70,7 @@ int BPF_PROG(fentry_XXX) static inline void fexit_update_maps(u32 id, struct bpf_perf_event_value *after) { - struct bpf_perf_event_value *before, diff, *accum; + struct bpf_perf_event_value *before, diff; before = bpf_map_lookup_elem(&fentry_readings, &id); /* only account samples with a valid fentry_reading */ @@ -95,7 +95,7 @@ int BPF_PROG(fexit_XXX) { struct bpf_perf_event_value readings[MAX_NUM_MATRICS]; u32 cpu = bpf_get_smp_processor_id(); - u32 i, one = 1, zero = 0; + u32 i, zero = 0; int err; u64 *count;