From mboxrd@z Thu Jan 1 00:00:00 1970 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=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 99EBBC433ED for ; Mon, 17 May 2021 09:30:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 39946611CC for ; Mon, 17 May 2021 09:30:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 39946611CC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B011F6B0036; Mon, 17 May 2021 05:30:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB1276B006E; Mon, 17 May 2021 05:30:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9788E6B0070; Mon, 17 May 2021 05:30:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0243.hostedemail.com [216.40.44.243]) by kanga.kvack.org (Postfix) with ESMTP id 636216B0036 for ; Mon, 17 May 2021 05:30:51 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 69EFA8249980 for ; Mon, 17 May 2021 09:30:49 +0000 (UTC) X-FDA: 78150203418.40.87993A8 Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) by imf03.hostedemail.com (Postfix) with ESMTP id EC4B5C0007F1 for ; Mon, 17 May 2021 09:30:47 +0000 (UTC) Received: by mail-io1-f52.google.com with SMTP id t11so5092608iol.9 for ; Mon, 17 May 2021 02:30:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZWqKSiLW2fby6hi7ZHFnbPrODBra/XbqWzo23kfZq3g=; b=Z1IyVdLx0SBWKqAwKsdrlEutAXKUnP7HcgeIi4qWse/1UfNkaCYAEPQygx5oEj0a23 3svXrXYExwKm4vBXUTWP/3ZQAyLhepGFDWVs6QfuUec6UtpMJ4MjokqAgH603B/iLhA1 So5XzBSF1tv6n3uPS5xOTHWnwomgLsmdm89zY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZWqKSiLW2fby6hi7ZHFnbPrODBra/XbqWzo23kfZq3g=; b=CSwr+yU2RZTsmvgIbvZLtZSBChurRpXNgkwd4hq1TtjqKLXJkOOvZPVFzHuMazhPuv C59CoYDjztMjIgkNuO1CGTAxfA+4LtJhD/ryGtySrqSvAI9vJ3TrHKF+srCxXZMx5R0h krDpJ9iCnZGEZ52dMFH+XFHLp7ZPqVkz251tKMRm/ivxiz3SkOTtxifEIujDTHHpxCRy fPTt17xUrrdVLNLK6FZGY2vdudSzWhmW5KYMquiKdmMjCp36Hu3r4Ed5I87PHp6YfY0X vmTPGOZHL6dhCN2fGbdqan1ixMJWbUMlluSZb3dmDHm/bCvEn/Vvm34C/1ki+dJbw409 VLDA== X-Gm-Message-State: AOAM533rzr/SsnmpXqytE3v5Y1s25EhyRPsHCQMi82hTCbJL8uKfH4KI FCO0IKRdUXfhqWBpS0zfkDa+6X24a2KjyID/qhTCWg== X-Google-Smtp-Source: ABdhPJwY5Fb0Jn4L9kqGWhPdRvW0a1PZDp9pupDfvazBs3fEmqeORS1Dh+bfhoufUq22wdWF7UCVzeDsqa/L1+tq/Gk= X-Received: by 2002:a6b:dc06:: with SMTP id s6mr44931086ioc.130.1621243848434; Mon, 17 May 2021 02:30:48 -0700 (PDT) MIME-Version: 1.0 References: <20210514063622.GU2687475@shao2-debian> In-Reply-To: From: Florent Revest Date: Mon, 17 May 2021 11:30:37 +0200 Message-ID: Subject: Re: [linux-next:master 2296/2770] kernel/bpf/helpers.c:713:43: warning: Uninitialized variable: bufs [uninitvar] To: Alexei Starovoitov Cc: kernel test robot , kbuild-all@lists.01.org, Linux Memory Management List , Alexei Starovoitov Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Z1IyVdLx; spf=pass (imf03.hostedemail.com: domain of revest@chromium.org designates 209.85.166.52 as permitted sender) smtp.mailfrom=revest@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: EC4B5C0007F1 X-Stat-Signature: ca64tjofrx4q9r6h6jspndbujp35eub9 X-HE-Tag: 1621243847-888380 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, May 14, 2021 at 4:18 PM Alexei Starovoitov wrote: > > On Fri, May 14, 2021 at 7:10 AM Florent Revest wrote: > > > > On Fri, May 14, 2021 at 8:37 AM kernel test robot wrote: > > > cppcheck possible warnings: (new ones prefixed by >>, may not real problems) > > > > > > >> kernel/bpf/helpers.c:713:43: warning: Uninitialized variable: bufs [uninitvar] > > > if (WARN_ON_ONCE(nest_level > ARRAY_SIZE(bufs->tmp_bufs))) { > > > ^ > > > > I don't think this is a real problem. bufs is not actually > > dereferenced, it is only used to give the type information to a > > sizeof. This is only evaluated at compilation time. > > > > If this matters, I guess we could silent this cppcheck warning with > > something like the following patch. Alexei, what do you think ? > > > > --- a/kernel/bpf/helpers.c > > +++ b/kernel/bpf/helpers.c > > @@ -697,8 +697,9 @@ static int bpf_trace_copy_string(char *buf, void > > *unsafe_ptr, char fmt_ptype, > > #define MAX_PRINTF_BUF_LEN 512 > > > > /* Support executing three nested bprintf helper calls on a given CPU */ > > +#define MAX_PRINTF_NEST_LEVEL 3 > > struct bpf_bprintf_buffers { > > - char tmp_bufs[3][MAX_PRINTF_BUF_LEN]; > > + char tmp_bufs[MAX_PRINTF_NEST_LEVEL][MAX_PRINTF_BUF_LEN]; > > }; > > static DEFINE_PER_CPU(struct bpf_bprintf_buffers, bpf_bprintf_bufs); > > static DEFINE_PER_CPU(int, bpf_bprintf_nest_level); > > @@ -710,7 +711,7 @@ static int try_get_fmt_tmp_buf(char **tmp_buf) > > > > preempt_disable(); > > nest_level = this_cpu_inc_return(bpf_bprintf_nest_level); > > - if (WARN_ON_ONCE(nest_level > ARRAY_SIZE(bufs->tmp_bufs))) { > > + if (WARN_ON_ONCE(nest_level > MAX_PRINTF_NEST_LEVEL)) { > > Yeah. Why not. I think it's cleaner overall. Cool :) thanks, I sent something to the bpf list