From nobody Sat Apr 27 04:30:50 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:590e:0:0:0:0:0 with SMTP id n14csp1416476uad; Sun, 10 Jul 2022 01:35:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1srURK7SvCkl48LVCnFJjoGp8f5JEKcnlUEt+ygjP50YqvPV6XRHPA26NubvSdXnOrsAv8f X-Received: by 2002:a17:90b:1488:b0:1ef:82bb:5f08 with SMTP id js8-20020a17090b148800b001ef82bb5f08mr10714068pjb.214.1657442134704; Sun, 10 Jul 2022 01:35:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657442134; cv=none; d=google.com; s=arc-20160816; b=VoLfGXcDB0o641vJdTLSP1P9F3tDh4Ad5oDNCanm8nfJI7KVstBNHea7WK/NS6ooRw 3U5d4dHoCO0FgSmwrmUNTE55bSTKm6PQUFNEGnJLUUQJ4zP4YmgJajKuDzzbWR5HaKhL YKQfIj8aQH0GR+kIJw6zkTyJww53KVDTpEk5SwPGGFBNE+iu5VfW7gKP+9ZK50kO9TqB URxVMI2BBCrKiDfgooR1WLojmOy+nDCG596glEvAhOTUJ52pBMx1VqxoGWo2SA7aldwV Ce/ALdcrBKyI8cIxN3O0wSpQOa+s+WdemYci0aurlghRB/O9oRJdzZOihYzlqvD+kFaW 9GBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=orIIFdtRbt6cm/l/3AlelKzIyuzEuMYVC6VdEiG/HhE=; b=zutH8uwjnQrX4oC6zr/YD31myVldc9FBjy0/I46VBmei4r0+nbGxhPCGX5q94I53Ck yZdfcDcNTWQy9pj+fprE55tWYoyB439LW2gcCKVyewkEjisB/3ZT0bcXDMHWLSEDE7o+ 6mFGJcrSdA3fjfIB7VZT8M766lkfI0EfRU05l/NQJhilGGbxibtwX9UQqpW0y5z7z8mr h80xwaNmscPnOVpi26gCwW2DJABbntjVD0+TxytcP5SaslOir9mOUW/bq60zZmJKXvWq ifbHb7kyrEEHaPf+Wvt8MldRGM+rA5NJZiCwbpqJMF3OlOkNdnlqxL13bMnmOVHbAGIM zY+A== 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 mptcp+bounces-5996-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-5996-wpasupplicant.patchew=gmail.com@lists.linux.dev" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j123-20020a62c581000000b0050dcc1acf09si6629756pfg.111.2022.07.10.01.35.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Jul 2022 01:35:34 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-5996-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=xw92GhKX; spf=pass (google.com: domain of mptcp+bounces-5996-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-5996-wpasupplicant.patchew=gmail.com@lists.linux.dev" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A215F280C17 for ; Sun, 10 Jul 2022 08:35:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6596B1104; Sun, 10 Jul 2022 08:35:32 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFD1BEBC for ; Sun, 10 Jul 2022 08:35:30 +0000 (UTC) Received: by mail-wm1-f41.google.com with SMTP id be14-20020a05600c1e8e00b003a04a458c54so1430880wmb.3 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=l2dDJqrXAzLkEaFWhWuq9NbtREOyPcuuZ/+ZRsw4YgOmAQ1+KmTlvY3Vy3q65ZIJu3 IOAKNf1VkxyUUNHiqQWwfMSYss10YgsDMi/BzuSsPhfr7nvc6BhNgTjWMaC5SObIWJDq VLbI8+qWNYUNE8PGV6ZdIIU0Pw2cJsdwpUfV/jbMwaUnowYvZejMCGxkENBqRYECsVp/ GjNDJ103XTIjLH8qcidWXyabE5VWoJTXuQUAxfwW49TIIBmxGXawuU5suGUZtIbqMik9 QRi8vXgYKF5mWSAFdGOFq3/ArzMN+Epw5+SP9jxLjoNEukl+Z7q6mD6yRzytA5+UrVyq JHrA== X-Gm-Message-State: AJIora+kmIH0wzLSlXKMdBmg7lyKxZJdBPprkd7pEtPp3S6YYJlcwri3 VYNv7l8VUyJx8930kORlSnpo8w== 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 Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Our CI[1] reported these warnings when using Sparse: $ touch net/mptcp/bpf.c $ make C=3D1 net/mptcp/bpf.o net/mptcp/bpf.c: note: in included file: include/linux/bpf_verifier.h:348:26: error: dubious one-bit signed bitfie= ld include/linux/bpf_verifier.h:349:29: error: dubious one-bit signed bitfie= ld 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 { }; =20 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 */ }; =20 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_verif= ier_env *env, u32 subprogno struct bpf_loop_inline_state *state =3D &cur_aux(env)->loop_inline_state; =20 if (!state->initialized) { - state->initialized =3D 1; + state->initialized =3D true; state->fit_for_inline =3D loop_flag_is_zero(env); state->callback_subprogno =3D subprogno; return; --=20 2.36.1