From: Arnd Bergmann <arnd@kernel.org>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jakub Sitnicki <jakub@cloudflare.com>,
Arnd Bergmann <arnd@arndb.de>, Martin KaFai Lau <kafai@fb.com>
Cc: Marek Majkowski <marek@cloudflare.com>,
Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
Andrii Nakryiko <andrii@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>, Jiri Olsa <jolsa@kernel.org>,
Alan Maguire <alan.maguire@oracle.com>,
Hao Luo <haoluo@google.com>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] bpf: fix incorrect initialization of bpf_ctx_convert_map
Date: Mon, 26 Oct 2020 22:03:48 +0100 [thread overview]
Message-ID: <20201026210355.3885283-1-arnd@kernel.org> (raw)
From: Arnd Bergmann <arnd@arndb.de>
gcc -Wextra points out that a field may get overridden in some
configurations such as x86 allmodconfig, when the next index after the one
that has been assigned last already had a value, in this case for index
BPF_PROG_TYPE_SK_LOOKUP, which comes after BPF_PROG_TYPE_LSM in the list:
kernel/bpf/btf.c:4225:2: warning: initialized field overwritten [-Woverride-init]
4225 | 0, /* avoid empty array */
| ^
kernel/bpf/btf.c:4225:2: note: (near initialization for 'bpf_ctx_convert_map[30]')
Move the zero-initializer first instead. This avoids the warning since
nothing else uses index 0, and the last element does not have to be zero.
Fixes: e9ddbb7707ff ("bpf: Introduce SK_LOOKUP program type with a dedicated attach point")
Fixes: 4c80c7bc583a ("bpf: Fix build in minimal configurations, again")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
kernel/bpf/btf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index ed7d02e8bc93..2a4a4aeeaac1 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -4218,11 +4218,11 @@ enum {
__ctx_convert_unused, /* to avoid empty enum in extreme .config */
};
static u8 bpf_ctx_convert_map[] = {
+ [0] = 0, /* avoid empty array */
#define BPF_PROG_TYPE(_id, _name, prog_ctx_type, kern_ctx_type) \
[_id] = __ctx_convert##_id,
#include <linux/bpf_types.h>
#undef BPF_PROG_TYPE
- 0, /* avoid empty array */
};
#undef BPF_MAP_TYPE
#undef BPF_LINK_TYPE
--
2.27.0
next reply other threads:[~2020-10-26 21:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-26 21:03 Arnd Bergmann [this message]
2020-10-26 22:32 ` [PATCH] bpf: fix incorrect initialization of bpf_ctx_convert_map Andrii Nakryiko
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=20201026210355.3885283-1-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=arnd@arndb.de \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=jakub@cloudflare.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marek@cloudflare.com \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/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;
as well as URLs for NNTP newsgroup(s).