From patchwork Mon Oct 26 21:03:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 288094 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C48EC388F9 for ; Mon, 26 Oct 2020 21:04:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 179CF221F7 for ; Mon, 26 Oct 2020 21:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603746246; bh=pJK1OJkuepgQNI/swpB2eC2t54KgsoqFayP1FDpJXfQ=; h=From:To:Cc:Subject:Date:List-ID:From; b=KZFi+7XGAXALfUXr/JC7noYtc4CxazPKHWuHEOO3bsVH0/aSoYh9pxyuvwOG3vZuc C2LroZCfvp6Ab/V1EL4JZc5pYBqR2xzmlh64425OmZmenun/Ywr/fiOF/fURh/uVLR 5yhu+JFsGuuDw34H1KTnQXPui/ucPCyOfhaiAX0g= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729626AbgJZVEE (ORCPT ); Mon, 26 Oct 2020 17:04:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:57988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729586AbgJZVEE (ORCPT ); Mon, 26 Oct 2020 17:04:04 -0400 Received: from localhost.localdomain (unknown [192.30.34.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4555D20773; Mon, 26 Oct 2020 21:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603746243; bh=pJK1OJkuepgQNI/swpB2eC2t54KgsoqFayP1FDpJXfQ=; h=From:To:Cc:Subject:Date:From; b=il+Ezvkv44gRlBOPG/TAjzsUspGL735bVU/p1dkTXRRr2677e7fkKH6WBUkYfghhK Asd0ogLsUT8EZNaFDP+XWlMRSUiJQOudCF9pj+P/wWo+hYIqInx2uajeFs2o8rZQkN VfuQHXsNQUb/ja8DpWG6qxO/QRhqewWqOJzQsbDM= From: Arnd Bergmann To: Alexei Starovoitov , Daniel Borkmann , Jakub Sitnicki , Arnd Bergmann , Martin KaFai Lau Cc: Marek Majkowski , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Jiri Olsa , Alan Maguire , Hao Luo , 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 Message-Id: <20201026210355.3885283-1-arnd@kernel.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arnd Bergmann 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 --- 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 #undef BPF_PROG_TYPE - 0, /* avoid empty array */ }; #undef BPF_MAP_TYPE #undef BPF_LINK_TYPE