lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201026210355.3885283-1-arnd@kernel.org>
Date:   Mon, 26 Oct 2020 22:03:48 +0100
From:   Arnd Bergmann <arnd@...nel.org>
To:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Jakub Sitnicki <jakub@...udflare.com>,
        Arnd Bergmann <arnd@...db.de>, Martin KaFai Lau <kafai@...com>
Cc:     Marek Majkowski <marek@...udflare.com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        Andrii Nakryiko <andrii@...nel.org>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...omium.org>, Jiri Olsa <jolsa@...nel.org>,
        Alan Maguire <alan.maguire@...cle.com>,
        Hao Luo <haoluo@...gle.com>, netdev@...r.kernel.org,
        bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] bpf: fix incorrect initialization of bpf_ctx_convert_map

From: Arnd Bergmann <arnd@...db.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@...db.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ