Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2087912lqb; Mon, 27 May 2024 07:31:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXWFu5eq5QtOoWEUS8BjwaaU0P1ORo/DaPWP6L82F5g8cRHln2u/F5pWhDVyoUsJjL4K2MEIwHpx96YcPUS47Ym6A7Miy6fhwYwgsheRQ== X-Google-Smtp-Source: AGHT+IHGVR6oSvsUFMlce93WGUU0B0p39RcppHDgUV1CtjFsprKQGAgalwi6VE0eMDPT4zmELIsL X-Received: by 2002:a05:6214:41a1:b0:6ad:78b1:60fd with SMTP id 6a1803df08f44-6ad78b1619amr40861336d6.6.1716820262649; Mon, 27 May 2024 07:31:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716820262; cv=pass; d=google.com; s=arc-20160816; b=C27lyXuqgHP0Q21CoEJ3iPzKm87hXnFRTLCp3/tE4UX6yBzzhHfNrswQthZXktruSC I9HSbi8Av9Vty/zNwi3GK5Wtp0e4IYZhOxwyMwrwaqBSVFDTlzchI55iHTrFBciGk8iL DGKbkV1ejx9n3NPvxiybyiLp5uxFv6n7EMzK3vO78Z06yK7T6pkwxTCgxEqQhB0bJZzs MeFaCXwOUvGhDm5yq7iiGsg4GH7ylOmbrQwvNFHVsjE15It9JAmwAwllAvrvkdw1XsEX lutnbQUoDSp0g4jJHsH4qTF3WRYTfjtLQJwekWqDbQX6c1RZAkYN1ge20uGAXMyzs183 jalg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=LIA2cawM1h+xvLKM25FD+nzi5b2wxjj1N78I63CvyDY=; fh=FrKIEkBABPHqdYVdipivYjc6UjohPmIO1G9qpOjQTRM=; b=Q3rnn0aqxv08vnmWdzwybSc6HiFtSS6IKDjQhD1UKMrwrZAle9p7J4i8tHB29qRq4S r/7qvc50vGKQ3VpD4j+noDh0mAa8fScSZobVTvnvJJjAo9pU54WLWRIAJUOwIh3qbpwE zcADkflwTO8DULY5s8ktTnlk8jha1ISyLa6uGjJyUP5UzltcKcDKPemfJqpB7mUbYhvX eVJc5NyGcvFIfRXsB+9BXPBg31OkDk4Mu2VnckbkgsY2x78lVI1cHUDBj3TyFgsXdKCP foPRTcWGH2yQI8eFCId8Wds3QndG5pPqaiyXQy9nVXVUrxXnnKnFr33BEyLpOjRIC62n 2pEg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ildT3ADE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190871-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190871-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ac162d5604si82898236d6.558.2024.05.27.07.31.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 07:31:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190871-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ildT3ADE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190871-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190871-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 617211C21B05 for ; Mon, 27 May 2024 14:31:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7517C181CFC; Mon, 27 May 2024 14:15:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ildT3ADE" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92B4D16C44A; Mon, 27 May 2024 14:15:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716819328; cv=none; b=E42d30kxHNDVvQ13fKcJO/Mi/GiMPun276nAvuGIQUHA7CRIDt1lruDuDn9B3RdT2HkSGwYmf7V6NQdAA6WdDWXVQUYuqso000FGXQZ9YQIkD2iZOTas6LEbiu6X5SuDy5tFfcHSzlCKtTQTpUTncg1q4XcCFjPV29CbbcR2stA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716819328; c=relaxed/simple; bh=Q7y5vxePkRCxLcmXOfapudItCeMOo9cgDV4Y+GQrrUU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zt5HZOaZTU4f2LtkhFz0A4LQWGOP67LfWO8FhD0hDx5w3j3hue8IWtR23iggwtbT5QE7fwK9V8X56EEoUyhcHz1ZvayQ1+e9BemQMKS2aTf3Qe6UhcpVANcj2Rm+hIS4qBQ6KOFcggsbMNjAeQ9DxoG1fnVhR7BeMZBzeWBfZwk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ildT3ADE; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5E92C2BBFC; Mon, 27 May 2024 14:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716819328; bh=Q7y5vxePkRCxLcmXOfapudItCeMOo9cgDV4Y+GQrrUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ildT3ADEVzYBNdNaPmVDOSFyftDD7sqPjgY0yk8I2UCpBVmUUU2O89wAM0uVZbZAr d178+6wHFY3PLBEtLMjquNOuQOLtDkCB5H5VVw76FItHhgZzNPyf1FBbEtiMkPe9dg 03BbYi0FB+f0vxlxmjTogWZ5blQARqUV3SLwaIQzWft967BqXouzdSoy9MeswHbBrd JvUhC7PMQHQcSWbj56rPRCRhpbYNb5QJmv+qtUbXbkRWCTzgZXMIgupto8leku7TvI Gun0h3NUXRAze9K4sDk2pNTOF4WeFl8b1NlJgSE+YhXoMy+WtHcjkNWJIZ0pAQ86BM 1nurZ0Cgh0KYA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Jose E. Marchesi" , david.faust@oracle.com, cupertino.miranda@oracle.com, Yonghong Song , Eduard Zingerman , Alexei Starovoitov , Sasha Levin , 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 Message-ID: <20240527141406.3852821-28-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527141406.3852821-1-sashal@kernel.org> References: <20240527141406.3852821-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.8.11 Content-Transfer-Encoding: 8bit From: "Jose E. Marchesi" [ 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 Cc: david.faust@oracle.com Cc: cupertino.miranda@oracle.com Cc: Yonghong Song Cc: Eduard Zingerman Acked-by: Yonghong Song Link: https://lore.kernel.org/r/20240507184756.1772-1-jose.marchesi@oracle.com Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- .../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