Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp617732pxx; Mon, 26 Oct 2020 17:04:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSy9Zloz5TZIAN+HLEPd4jIVYFOvh4mx0TnUG/6PUgajBrcG/SJCO9UlNy7+URn0ypYZg1 X-Received: by 2002:aa7:c6c5:: with SMTP id b5mr2848148eds.259.1603757043949; Mon, 26 Oct 2020 17:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603757043; cv=none; d=google.com; s=arc-20160816; b=BHJqCI0XGhFTmJK4Kf/HbvecM0qI+lbXcbevST2hh83kQy71cWLYWDChk9IJgmvIKl MyNJ5aP+/9zGy9H2xNdlbQEhlxZa9pMxtU0cLJd/5BpA70UYSZubsKajunoNjPQS9FJQ MjRGSTQ5GZ1DqPdME2ghdpr0lsOJ1KI3gnWEapghqgSX/lnNqWnfDNDoMnKEmT2LNRuP 8ngWytagZhhY2lTXs7Q4xTLP6SAy2Amx4oOhCYgjbc0jUcvK8KhvoZIVmm3j4PYzWy2q /1pYJ9hZ5QWydASWjnQucys4kjtBFkXH5QelMslGbiggl3gwOmdH/UaivpnLENNFejWp GU6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=0AJQQf0Ni3ANqjvMwme+AXNTNhiThWfCmD86h7IQPN4=; b=UgIp0yCp5Gw41wl0QW5Mpyl3ZKZlrrsazUuObv6i3EktTJf5AKrdZaOGsFY4BztkhL uD++ty+vKf+njbx1toak62SqY9F5fHQ5tSjmEtZuaOV9kiQIO+ShINZnJud0VDIeFeWQ gI1oa8oJNwrnpPDOKmiEGPCWLZ+QVMq5CJBOU7pvrbqXKSkhNz3RSsnp1rfCsV72gnvm J4QX9uUOxMjO2amAc7wCFrvA+zwZcpDTqHlF6Nimv5oUZiqNNdPmwpb0Lf/eHUP0sPH2 arviMs0gdE7IiUV52hcI0LQCq9spb9j/XwLr5vzfFcNda91seuwgPI0tuIDgpk4mw93n ZWAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=il+Ezvkv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r20si8016822ejb.578.2020.10.26.17.03.41; Mon, 26 Oct 2020 17:04:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=il+Ezvkv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729569AbgJZVEE (ORCPT + 99 others); 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 -- 2.27.0