From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Jose E. Marchesi" <jose.marchesi@oracle.com>,
david.faust@oracle.com, cupertino.miranda@oracle.com,
Yonghong Song <yonghong.song@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Sasha Levin <sashal@kernel.org>,
andrii@kernel.org, daniel@iogearbox.net, shuah@kernel.org,
john.fastabend@gmail.com, bpf@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: [PATCH AUTOSEL 6.8 28/30] bpf: avoid uninitialized warnings in verifier_global_subprogs.c
Date: Mon, 27 May 2024 10:13:37 -0400 [thread overview]
Message-ID: <20240527141406.3852821-28-sashal@kernel.org> (raw)
In-Reply-To: <20240527141406.3852821-1-sashal@kernel.org>
From: "Jose E. Marchesi" <jose.marchesi@oracle.com>
[ Upstream commit cd3fc3b9782130a5bc1dc3dfccffbc1657637a93 ]
[Changes from V1:
- The warning to disable is -Wmaybe-uninitialized, not -Wuninitialized.
- This warning is only supported in GCC.]
The BPF selftest verifier_global_subprogs.c contains code that
purposedly performs out of bounds access to memory, to check whether
the kernel verifier is able to catch them. For example:
__noinline int global_unsupp(const int *mem)
{
if (!mem)
return 0;
return mem[100]; /* BOOM */
}
With -O1 and higher and no inlining, GCC notices this fact and emits a
"maybe uninitialized" warning. This is by design. Note that the
emission of these warnings is highly dependent on the precise
optimizations that are performed.
This patch adds a compiler pragma to verifier_global_subprogs.c to
ignore these warnings.
Tested in bpf-next master.
No regressions.
Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
Cc: david.faust@oracle.com
Cc: cupertino.miranda@oracle.com
Cc: Yonghong Song <yonghong.song@linux.dev>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20240507184756.1772-1-jose.marchesi@oracle.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
.../testing/selftests/bpf/progs/verifier_global_subprogs.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c b/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c
index 67dddd9418911..27f4b2da131b1 100644
--- a/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c
+++ b/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c
@@ -8,6 +8,13 @@
#include "xdp_metadata.h"
#include "bpf_kfuncs.h"
+/* The compiler may be able to detect the access to uninitialized
+ memory in the routines performing out of bound memory accesses and
+ emit warnings about it. This is the case of GCC. */
+#if !defined(__clang__)
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#endif
+
int arr[1];
int unkn_idx;
const volatile bool call_dead_subprog = false;
--
2.43.0
next prev parent reply other threads:[~2024-05-27 14:15 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-27 14:13 [PATCH AUTOSEL 6.8 01/30] ssb: Fix potential NULL pointer dereference in ssb_device_uevent() Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 02/30] selftests/bpf: Prevent client connect before server bind in test_tc_tunnel.sh Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 03/30] selftests/bpf: Fix flaky test btf_map_in_map/lookup_update Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 04/30] devlink: use kvzalloc() to allocate devlink instance resources Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 05/30] batman-adv: bypass empty buckets in batadv_purge_orig_ref() Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 06/30] wifi: rtw89: 8852c: add quirk to set PCI BER for certain platforms Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 07/30] wifi: ath9k: work around memset overflow warning Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 08/30] af_packet: avoid a false positive warning in packet_setsockopt() Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 09/30] ACPI: x86: Add PNP_UART1_SKIP quirk for Lenovo Blade2 tablets Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 10/30] net: sfp: add quirk for another multigig RollBall transceiver Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 11/30] drop_monitor: replace spin_lock by raw_spin_lock Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 12/30] ACPI: resource: Do IRQ override on GMxBGxx (XMG APEX 17 M23) Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 13/30] scsi: qedi: Fix crash while reading debugfs attribute Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 14/30] net: sfp: enhance quirk for Fibrestore 2.5G copper SFP module Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 15/30] net: sfp: add quirk for ATS SFP-GE-T 1000Base-TX module Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 16/30] net/sched: fix false lockdep warning on qdisc root lock Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 17/30] arm64/sysreg: Update PIE permission encodings Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 18/30] kselftest: arm64: Add a null pointer check Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 19/30] net: dsa: realtek: keep default LED state in rtl8366rb Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 20/30] ACPI: resource: Skip IRQ override on Asus Vivobook Pro N6506MV Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 21/30] netpoll: Fix race condition in netpoll_owner_active Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 22/30] wifi: ath12k: fix the problem that down grade phy mode operation Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 23/30] wifi: mt76: mt7921s: fix potential hung tasks during chip recovery Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 24/30] HID: Add quirk for Logitech Casa touchpad Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 25/30] HID: asus: fix more n-key report descriptors if n-key quirked Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 26/30] ACPI: video: Add backlight=native quirk for Lenovo Slim 7 16ARH7 Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 27/30] HID: bpf: add in-tree HID-BPF fix for the HP Elite Presenter Mouse Sasha Levin
2024-05-27 14:49 ` Benjamin Tissoires
2024-05-27 14:13 ` Sasha Levin [this message]
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 29/30] selftests: net: fix timestamp not arriving in cmsg_time.sh Sasha Levin
2024-05-27 14:13 ` [PATCH AUTOSEL 6.8 30/30] Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240527141406.3852821-28-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cupertino.miranda@oracle.com \
--cc=daniel@iogearbox.net \
--cc=david.faust@oracle.com \
--cc=eddyz87@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=jose.marchesi@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=stable@vger.kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox