Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2254629imw; Sun, 10 Jul 2022 01:42:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tu1l3HzyhFElGYOrByc1E/2J7yDTAMkwoC+yMwG/CpRq09T3Hb2u4OE3zhrXLu48YnVZDd X-Received: by 2002:a63:b21:0:b0:3fd:f319:dd6c with SMTP id 33-20020a630b21000000b003fdf319dd6cmr10675510pgl.168.1657442536466; Sun, 10 Jul 2022 01:42:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657442536; cv=none; d=google.com; s=arc-20160816; b=KpjZR0C+6LFuBuzEnRhn/vh7y5AyNQVGngmByjeBuMbxDj27pkeHGi6IGC8Q6aCYw5 +ClRLc71R466Xm2+oDj/1nc+229Ig0zwBKPQWnQLqVySwzzFGDegde9k6Oa3xIBnwdIw yDrZvyCLx1fx79P+KacI396Q0tDfKyOX7Eyi0F7D7ZhkyFZDX5tIc4h1VxXqR3Oy/st2 Bckczq+pjxx+9JJoWsNR+fGwEeqkfnuXOMtktomrAmh6R56O4UgDtlXC6DqfDMgVSUTC qQTP6iIHIPx0Zx+yR5ygV7ihdhq8dvJIJP9QxBsshLczwFdv6pcuQJt5qI5wXUecfoIc 1FEw== 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:cc:to:from:dkim-signature; bh=orIIFdtRbt6cm/l/3AlelKzIyuzEuMYVC6VdEiG/HhE=; b=A4ClA8hza10vhOuzDe7wZMoAZIk9I6PBWqGKxgDpBwjA46UhWQV0nMtcCLU+WQAg0f edYqDNg/cguusyIJDahHd/BDGPL0l4D/hmhJa019d7OzUD4o1QGSZKXyabjlDvAkxcF9 D3P4nR/WJQ77z2/zuDMXs1fIQqY+CWYrPx4G632vpW72Y6lh3D5lCtD9Wqzm11fyG5oo /km+Ikjaxevm3/1ZFSrtTGyodoBFefLToaKcnO2wVZj06lrNy8gXiUP7sA+gkta/YwST gBx9rHyfXiy6Ysd+QDVKjUA6e2jcQpBeEuL/0/darOK5eB/rK3smpPuzqyszBg/lOJfe xKpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=xw92GhKX; 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 mu11-20020a17090b388b00b001ef8382fcfesi6266982pjb.94.2022.07.10.01.42.04; Sun, 10 Jul 2022 01:42:16 -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=@tessares.net header.s=google header.b=xw92GhKX; 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 S229555AbiGJIfe (ORCPT + 99 others); Sun, 10 Jul 2022 04:35:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiGJIfc (ORCPT ); Sun, 10 Jul 2022 04:35:32 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DB7C13F1F for ; Sun, 10 Jul 2022 01:35:30 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id v67-20020a1cac46000000b003a1888b9d36so3401761wme.0 for ; Sun, 10 Jul 2022 01:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=orIIFdtRbt6cm/l/3AlelKzIyuzEuMYVC6VdEiG/HhE=; b=xw92GhKX4WJO8whQD7utDC8+8bFUEokf6yXN1jTy1b8fK7xUW6SB6d3+HjS0DvXLln bu2CcR2YFRaQZFjV19f90BQSnxs/vaoHsaybo7j3aeVfpytGIIkW/Xvu6uexB8PrE/Ge XpYOfxY7hQT9u0RvKILf+GBEYrXwvGdduWd9tyDOcEztbS14h6uOF50qQmRSixwuhmaQ jGpgJfWQZidxD74rkU11R6urlWEKy51jhcyDMa0ZO0DyHjFSy7mzxI64jEn52drPB0kz 7Ydd2tQlZibBTDjy+AbGQ3K1FhRIf5cOSzCjwF5S/q3gOwoMi+NmYGtAUf7DVfmfKZL3 PDWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=orIIFdtRbt6cm/l/3AlelKzIyuzEuMYVC6VdEiG/HhE=; b=KbgNPlBG3pLPQae++wMBbBtUPmwTxyADsEqPq0UzDXmEqfz4gVmPABtxTJQx+d+QCc H30jnwhjibvewFYaCcWpQs7ZLBDfz4LADSdTicCV9clmgODjyj4OoXjRRSBG85tIihCO xfOBjEhtZp1Qd9TCY0FipwnOFmeY9krGWHzkunuR5LUcSzs3/Fhi95khQS0noHjvULdX R7WHbBhB2uU+7ARu4YSs210j7EFeUVf5qLc8wgsWEPKcCekry9HvVDfJU5FYbimxjCVm XBKuUA/TfBhEMSQ+gxOmb4xRMgwLIWm4R344r8XqVBOaqg1V2SGPN69YrhP7kjUVKlu4 6rKw== X-Gm-Message-State: AJIora8A9jTTRH5B9AuiZAMOmDVNwg3B+gATPp3tUKE8tnl8hm+G+f2P TCWquJmVWSbIM/YEbH6j/GJNeN1GRHbkkcpQ X-Received: by 2002:a05:600c:4e54:b0:3a0:4e07:ce with SMTP id e20-20020a05600c4e5400b003a04e0700cemr9652537wmq.37.1657442128721; Sun, 10 Jul 2022 01:35:28 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id b17-20020adff911000000b0021d819c8f6dsm3120944wrr.39.2022.07.10.01.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 01:35:28 -0700 (PDT) From: Matthieu Baerts To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Eduard Zingerman Cc: mptcp@lists.linux.dev, Matthieu Baerts , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next] bpf: fix 'dubious one-bit signed bitfield' warnings Date: Sun, 10 Jul 2022 10:35:23 +0200 Message-Id: <20220710083523.1620722-1-matthieu.baerts@tessares.net> X-Mailer: git-send-email 2.36.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 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 Our CI[1] reported these warnings when using Sparse: $ touch net/mptcp/bpf.c $ make C=1 net/mptcp/bpf.o net/mptcp/bpf.c: note: in included file: include/linux/bpf_verifier.h:348:26: error: dubious one-bit signed bitfield include/linux/bpf_verifier.h:349:29: error: dubious one-bit signed bitfield These two fields from the new 'bpf_loop_inline_state' structure are used as booleans. Instead of declaring two 'unsigned int', we can declare them as 'bool'. While at it, also set 'state->initialized' to 'true' instead of '1' to make it clearer it is linked to a 'bool' type. [1] https://github.com/multipath-tcp/mptcp_net-next/actions/runs/2643588487 Fixes: 1ade23711971 ("bpf: Inline calls to bpf_loop when callback is known") Signed-off-by: Matthieu Baerts --- include/linux/bpf_verifier.h | 8 ++++---- kernel/bpf/verifier.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h index 81b19669efba..2ac424641cc3 100644 --- a/include/linux/bpf_verifier.h +++ b/include/linux/bpf_verifier.h @@ -345,10 +345,10 @@ struct bpf_verifier_state_list { }; struct bpf_loop_inline_state { - int initialized:1; /* set to true upon first entry */ - int fit_for_inline:1; /* true if callback function is the same - * at each call and flags are always zero - */ + bool initialized; /* set to true upon first entry */ + bool fit_for_inline; /* true if callback function is the same + * at each call and flags are always zero + */ u32 callback_subprogno; /* valid when fit_for_inline is true */ }; diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 328cfab3af60..4fa49d852a59 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -7144,7 +7144,7 @@ static void update_loop_inline_state(struct bpf_verifier_env *env, u32 subprogno struct bpf_loop_inline_state *state = &cur_aux(env)->loop_inline_state; if (!state->initialized) { - state->initialized = 1; + state->initialized = true; state->fit_for_inline = loop_flag_is_zero(env); state->callback_subprogno = subprogno; return; -- 2.36.1