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.5 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 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 16C07C433ED for ; Fri, 14 May 2021 14:10:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B3C74613E9 for ; Fri, 14 May 2021 14:10:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3C74613E9 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 438B56B0036; Fri, 14 May 2021 10:10:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E7236B006E; Fri, 14 May 2021 10:10:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 265276B0070; Fri, 14 May 2021 10:10:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0008.hostedemail.com [216.40.44.8]) by kanga.kvack.org (Postfix) with ESMTP id EB55F6B0036 for ; Fri, 14 May 2021 10:10:44 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8E935180013C0 for ; Fri, 14 May 2021 14:10:44 +0000 (UTC) X-FDA: 78140022408.38.21E9A7A Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) by imf13.hostedemail.com (Postfix) with ESMTP id B2CAFE0001B4 for ; Fri, 14 May 2021 14:10:42 +0000 (UTC) Received: by mail-il1-f175.google.com with SMTP id h11so1160828ili.9 for ; Fri, 14 May 2021 07:10:44 -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=hshb9cDtr9870Ic8Izi43VIls53nnQxrkIs2rM8SoK8=; b=GB6gUzFAvSh6s66keAvPhMy+cvQkOAaIujxtOv1YCyViNVnDfknMpDmnXL5njj6EbX Cj9TVHEc19NMBv5MxxjhiaUA9/umsKz+h2Z1oXWSGpW1ritWLcz3y5lI2iWnwz0xG2Vk Ekm8lYyPtDAg3e7gNkduHikvjpJef0sTj9Pxc= 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=hshb9cDtr9870Ic8Izi43VIls53nnQxrkIs2rM8SoK8=; b=mIM6G8KGFaz6FDCpkdlowwxMlUzZx1jz+uCA3zH3+bAFEGBUH8vVc55XsT7iqasqjM dNgw5a83I0qr5vGKnLT1ZZtECEleiylBJWzSnoUjeCxpIDM24J2EY4aFvpSPCSPlHMCd 0vhn8nl/r2gPADDU59rmpW2XSyps6dAQwABZJ0X8dPo+kP1mLj8lEHKjbewoqfjodHG1 kZOyeTqzkgZ9N42GZBacJNC2/M67XGJcH4+H/FR0VLAeQcoYMcRSVcRIOG4YlkeICPqb KcPMmUsWTdHy4nucb0A6/0AzrB4G5SPD5LnHNthFjZz4ZbFkB4F5QUxxwqXoZ8a6QbKF ycZg== X-Gm-Message-State: AOAM533DFnCrvh0RPvbzPCcry8v3XrrQJurcqmSMac8JA2ssaVnIelo6 5sV7UjoVv14zQYOjvQJk3wk2ggRwPx+SPcRieoOZ+w== X-Google-Smtp-Source: ABdhPJzE90FrO3Vv478cLkdHzj5OSxBps9jY7JuqNgNHtzWfmDZ73aJEzRakk+lpmPYlqWweDeYdiUPYZnJ3mS9q3xA= X-Received: by 2002:a05:6e02:eac:: with SMTP id u12mr41492221ilj.177.1621001443481; Fri, 14 May 2021 07:10:43 -0700 (PDT) MIME-Version: 1.0 References: <20210514063622.GU2687475@shao2-debian> In-Reply-To: <20210514063622.GU2687475@shao2-debian> From: Florent Revest Date: Fri, 14 May 2021 16:10:32 +0200 Message-ID: Subject: Re: [linux-next:master 2296/2770] kernel/bpf/helpers.c:713:43: warning: Uninitialized variable: bufs [uninitvar] To: kernel test robot Cc: kbuild-all@lists.01.org, Linux Memory Management List , Alexei Starovoitov Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=GB6gUzFA; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf13.hostedemail.com: domain of revest@chromium.org designates 209.85.166.175 as permitted sender) smtp.mailfrom=revest@chromium.org X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: B2CAFE0001B4 X-Stat-Signature: rmbcgbwxc6uu677qnopcx954edhp3emn X-HE-Tag: 1621001442-113332 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 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)) { this_cpu_dec(bpf_bprintf_nest_level); preempt_enable(); return -EBUSY;