From nobody Mon Mar 23 19:53:34 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F6F63B4E8E; Mon, 23 Mar 2026 15:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774280432; cv=none; b=uEv9DUiwf1VXmR0pAHwrbFqPG9n8GC16q1wP9UBhihUQUeAmK2VmSBvoN7svRjaWHQK4yP/9RPwzsNcQ/y0Er6KDqralBftG55UWdEfYfSgFL5kIXHFHdcyur/ii3AbWc/50v4kgTmDuchgU/y6oeHD0MB0xueaCebOm6QbCsm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774280432; c=relaxed/simple; bh=/OoRSyce1xBSzRHNQcVKDJadSwKzqz+190gXk0b+TAg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aGJLxFZ/YGcukLSVG9B24ZP0mXlXqZeqI16Ib9HGrntdk73Nz/NfH6g0d6K9d2XJT9C0j3r432TjPKNtsgbTlGp68YAiyqRMA7BRQotchLmNoqBSs8xlauCyekWXDzqVCOmwurLQn0gIH0OQ2XNroSUARPUF1smKN02wMlZQ0Do= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C17A1169C; Mon, 23 Mar 2026 08:40:23 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 050643F694; Mon, 23 Mar 2026 08:40:25 -0700 (PDT) From: Leo Yan Date: Mon, 23 Mar 2026 15:40:02 +0000 Subject: [PATCH 1/6] bpftool: Avoid adding EXTRA_CFLAGS to HOST_CFLAGS Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260323-tools_build_fix_zero_init_bpf_only-v1-1-d1cfad2f4cd1@arm.com> References: <20260323-tools_build_fix_zero_init_bpf_only-v1-0-d1cfad2f4cd1@arm.com> In-Reply-To: <20260323-tools_build_fix_zero_init_bpf_only-v1-0-d1cfad2f4cd1@arm.com> To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Lorenz Bauer , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Kees Cook , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774280421; l=1436; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=/OoRSyce1xBSzRHNQcVKDJadSwKzqz+190gXk0b+TAg=; b=AZJ3LqrB+yZvRm5iiP4Mcnx6Ey+IpRRf7xjtO3J1rH9y7IIBdGIFlcKS5eIqqn9e88MNRCCWi ztGXXMbYBd5AGi9Wv5EgTdVneHWaQhvgwNcQRMUpAfGZQk6Bp3z6M+n X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= Prepare for future changes where EXTRA_CFLAGS may include flags not applicable to the host compiler. Move the HOST_CFLAGS assignment before appending EXTRA_CFLAGS to CFLAGS so that HOST_CFLAGS does not inherit flags from EXTRA_CFLAGS. Acked-by: Quentin Monnet Signed-off-by: Leo Yan --- tools/bpf/bpftool/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 0febf60e1b64656035dfe93cd15cba090015587a..5a14185407a2895ba0167802e55= 5c1113e1991f5 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -81,6 +81,12 @@ CFLAGS +=3D -DPACKAGE=3D'"bpftool"' -D__EXPORTED_HEADERS= __ \ ifneq ($(BPFTOOL_VERSION),) CFLAGS +=3D -DBPFTOOL_VERSION=3D'"$(BPFTOOL_VERSION)"' endif + +# This must be done before appending EXTRA_CFLAGS to CFLAGS to avoid +# including flags that are not applicable to the host compiler. +HOST_CFLAGS :=3D $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE)= ,\ + $(subst $(CLANG_CROSS_FLAGS),,$(CFLAGS))) + ifneq ($(EXTRA_CFLAGS),) CFLAGS +=3D $(EXTRA_CFLAGS) endif @@ -88,8 +94,6 @@ ifneq ($(EXTRA_LDFLAGS),) LDFLAGS +=3D $(EXTRA_LDFLAGS) endif =20 -HOST_CFLAGS :=3D $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE)= ,\ - $(subst $(CLANG_CROSS_FLAGS),,$(CFLAGS))) HOST_LDFLAGS :=3D $(LDFLAGS) =20 INSTALL ?=3D install --=20 2.34.1 From nobody Mon Mar 23 19:53:34 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 607C63B4E8E; Mon, 23 Mar 2026 15:40:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774280435; cv=none; b=qeQWsWBV0wPyp29/kkHrf4VgzKT9/4bL3IBD00kni/QljiSyIuonofMIaTPZQNWV/trjX1H5SU/2K/LkbQwC150V7C1DddOTTlKwK+x/ydlgewnlHrTvAT6XeYBq+60pWYwo/yk3SXk05Wy12nu2+ZWA4x0JYzcFbwCJfq7sXb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774280435; c=relaxed/simple; bh=RbzWvHVPMM6ZwIg9QOtNftjDOGjDOKJxSvUCxQ4+gxQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Oo70kzFhxZhj65w3TXaEeGLYJ1tmIYN2wA6X8o9OfJH/7ROEvymwja2PlPB0YAOzQeFVpuvLAiuKhmjqoERuA8JiWboUjSKy/rECqdwo1UmTcGbIMY79avH0ki30YvigNkFdeDVf3OW4FJpEJmHLtRbeFHfSQewBQThco1YTUrA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CE48C16A3; Mon, 23 Mar 2026 08:40:27 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 10FE73F694; Mon, 23 Mar 2026 08:40:29 -0700 (PDT) From: Leo Yan Date: Mon, 23 Mar 2026 15:40:03 +0000 Subject: [PATCH 2/6] bpftool: Append extra host flags Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260323-tools_build_fix_zero_init_bpf_only-v1-2-d1cfad2f4cd1@arm.com> References: <20260323-tools_build_fix_zero_init_bpf_only-v1-0-d1cfad2f4cd1@arm.com> In-Reply-To: <20260323-tools_build_fix_zero_init_bpf_only-v1-0-d1cfad2f4cd1@arm.com> To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Lorenz Bauer , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Kees Cook , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774280421; l=824; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=RbzWvHVPMM6ZwIg9QOtNftjDOGjDOKJxSvUCxQ4+gxQ=; b=sdT2ls0ptgMiCSYPqtZDxFu3HyRPrJnVyuA366Nciznm01sxzXVqEGNECEp51pVCc0f13Fstc KgdRbMBR8W5CaUO3vwJZ1/VkBIswsbOPkknqKxuxEdNHPaFgA5dW1m0 X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= Append HOST_EXTRACFLAGS to HOST_CFLAGS so that additional flags can be applied to the host compiler. Acked-by: Quentin Monnet Signed-off-by: Leo Yan --- tools/bpf/bpftool/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 5a14185407a2895ba0167802e555c1113e1991f5..adec4fdf43dab525609d7d37884= 3f5d3ec072213 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -86,6 +86,7 @@ endif # including flags that are not applicable to the host compiler. HOST_CFLAGS :=3D $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE)= ,\ $(subst $(CLANG_CROSS_FLAGS),,$(CFLAGS))) +HOST_CFLAGS +=3D $(HOST_EXTRACFLAGS) =20 ifneq ($(EXTRA_CFLAGS),) CFLAGS +=3D $(EXTRA_CFLAGS) --=20 2.34.1 From nobody Mon Mar 23 19:53:34 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F30C3B893A; Mon, 23 Mar 2026 15:40:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774280440; cv=none; b=ds2gt7TuxeUpWTB0pBjSW3R4cEChj0OQ6jBdvhXYk5KK7uNj3pU34ZEViiXrP8hVa2Vxq62Gk7MZbWzMK7yAUPGvprJ/df3RJT9/XTfCbdkmrK+1F0kl75/+dySyN2gvORhklPj4cJTT/9RfGhjxECf2Zj233Q6IGPlIjKoyMiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774280440; c=relaxed/simple; bh=fr7nMYwoXnzgHlC72bxfp98CkE2gEdCXj4tIMnBW3FM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QF2A70HLMTY+tc7Hc5iJ08OKAzNicggPtizNWl+dWwRJqqAqtHDxcxYsGl8M9pEQgFZ58AjjNdD5spE7Y/1Tc+A538SW81AjGeAXbGrnGJ5xh+GgbJPkJamHeIvBgR784OaGEmmu6urIKBGOqnWQvg3kOT+lAZuX0+M/NUzeYq8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D997114BF; Mon, 23 Mar 2026 08:40:31 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1D1113F694; Mon, 23 Mar 2026 08:40:33 -0700 (PDT) From: Leo Yan Date: Mon, 23 Mar 2026 15:40:04 +0000 Subject: [PATCH 3/6] libbpf: Initialize CFLAGS before including Makefile.include Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260323-tools_build_fix_zero_init_bpf_only-v1-3-d1cfad2f4cd1@arm.com> References: <20260323-tools_build_fix_zero_init_bpf_only-v1-0-d1cfad2f4cd1@arm.com> In-Reply-To: <20260323-tools_build_fix_zero_init_bpf_only-v1-0-d1cfad2f4cd1@arm.com> To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Lorenz Bauer , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Kees Cook , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774280421; l=2221; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=fr7nMYwoXnzgHlC72bxfp98CkE2gEdCXj4tIMnBW3FM=; b=XH6AMFkyqkkQGRjFx4y0fH/5tWD/XAuHUYm6opoUDU+OopxMv5nocPF1OQ4YeW0/K5XkJbacw 2LE1Vh6zgI0CLpvc5lRTdIuL1952+zYp+33z1B0VLtaRZwT1kwYLwX8 X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= tools/scripts/Makefile.include may expand EXTRA_CFLAGS in a future change. This could alter the initialization of CFLAGS, as the default options "-g -O2" would never be set once EXTRA_CFLAGS is expanded. Prepare for this by moving the CFLAGS initialization before including tools/scripts/Makefile.include, so it is not affected by the extended EXTRA_CFLAGS. Append EXTRA_CFLAGS to CFLAGS only after including Makefile.include and place it last so that the extra flags propagate properly and can override the default options. tools/scripts/Makefile.include already appends $(CLANG_CROSS_FLAGS) to CFLAGS, the Makefile appends $(CLANG_CROSS_FLAGS) again, remove the redundant append. Signed-off-by: Leo Yan --- tools/lib/bpf/Makefile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index 168140f8e6461bd06db40e23d21a3fb8847ccbf4..eca584fb061e16013e76827e420= 3f6be0477a73e 100644 --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile @@ -49,6 +49,14 @@ man_dir_SQ =3D '$(subst ','\'',$(man_dir))' export man_dir man_dir_SQ INSTALL export DESTDIR DESTDIR_SQ =20 +# Defer assigning EXTRA_CFLAGS to CFLAGS until after including +# tools/scripts/Makefile.include, as it may add flags to EXTRA_CFLAGS. +ifdef EXTRA_CFLAGS + CFLAGS :=3D +else + CFLAGS :=3D -g -O2 +endif + include $(srctree)/tools/scripts/Makefile.include =20 # copy a bit from Linux kbuild @@ -70,13 +78,6 @@ LIB_TARGET =3D libbpf.a libbpf.so.$(LIBBPF_VERSION) LIB_FILE =3D libbpf.a libbpf.so* PC_FILE =3D libbpf.pc =20 -# Set compile option CFLAGS -ifdef EXTRA_CFLAGS - CFLAGS :=3D $(EXTRA_CFLAGS) -else - CFLAGS :=3D -g -O2 -endif - # Append required CFLAGS override CFLAGS +=3D -std=3Dgnu89 override CFLAGS +=3D $(EXTRA_WARNINGS) -Wno-switch-enum @@ -84,7 +85,7 @@ override CFLAGS +=3D -Werror -Wall override CFLAGS +=3D $(INCLUDES) override CFLAGS +=3D -fvisibility=3Dhidden override CFLAGS +=3D -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=3D64 -override CFLAGS +=3D $(CLANG_CROSS_FLAGS) +override CFLAGS +=3D $(EXTRA_CFLAGS) =20 # flags specific for shared library SHLIB_FLAGS :=3D -DSHARED -fPIC --=20 2.34.1 From nobody Mon Mar 23 19:53:34 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7F8C23B9611; Mon, 23 Mar 2026 15:40:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774280443; cv=none; b=gaZdSH8IU3iwXMtIVQK24FaAOJejDmSba3sGqQM9BBO8u+cWiMeJfttGxaGFFq+C+a6LoZTdV2zW6xbDR6K1tsEghw6HXomYc93auZFOBd8CIdNvkoSDgVODkElaKZZvxiHWiJi9aIi993nnhm+Kj9FjB+8Fhe9zDSpWgoPyQgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774280443; c=relaxed/simple; bh=QVECXhBfSn3HTksxV9ctf7sdfgmuzFaQvCXjb24QcOs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l7VvTW1wuOPuKK+W+pNY09eFY8lFnbb1OheJPUYbLDLwSCVcaJBgYMXbIbNPCkU1Xo7UBqNw/7rQxrNkA2H07AAzGO/GesdxYKNzR3GLUmZLWnetWPWQGhIquXy4oNblBiUxIeuHNQAczGcQyZWvmDNCBHzXCIJqIroKGfRLfAA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E6DBE169C; Mon, 23 Mar 2026 08:40:35 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 28EE13F694; Mon, 23 Mar 2026 08:40:38 -0700 (PDT) From: Leo Yan Date: Mon, 23 Mar 2026 15:40:05 +0000 Subject: [PATCH 4/6] tools/bpf: build: Append extra cflags Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260323-tools_build_fix_zero_init_bpf_only-v1-4-d1cfad2f4cd1@arm.com> References: <20260323-tools_build_fix_zero_init_bpf_only-v1-0-d1cfad2f4cd1@arm.com> In-Reply-To: <20260323-tools_build_fix_zero_init_bpf_only-v1-0-d1cfad2f4cd1@arm.com> To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Lorenz Bauer , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Kees Cook , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774280421; l=742; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=QVECXhBfSn3HTksxV9ctf7sdfgmuzFaQvCXjb24QcOs=; b=C6HUHnhMGAXDO1yXBVhb43ljE1t47EE5AIYQaQnnS428132Tlulf9RMdg5JUPwn5DWNkGlSj0 iAcemiZMjApDx3zCEcJGzG/Q/l17Z+Ptxywa3DsUQH3xgFGm2d2KJA8 X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= Append EXTRA_CFLAGS to CFLAGS so that additional flags can be applied to the compiler. Signed-off-by: Leo Yan --- tools/bpf/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/bpf/Makefile b/tools/bpf/Makefile index fd2585af1252669c59228af3a77320e449e1a1ab..9c19e81f3c274767c3b9b94c907= cbbe3ce9fe78c 100644 --- a/tools/bpf/Makefile +++ b/tools/bpf/Makefile @@ -11,6 +11,7 @@ INSTALL ?=3D install CFLAGS +=3D -Wall -O2 CFLAGS +=3D -D__EXPORTED_HEADERS__ -I$(srctree)/tools/include/uapi \ -I$(srctree)/tools/include +CFLAGS +=3D $(EXTRA_CFLAGS) =20 # This will work when bpf is built in tools env. where srctree # isn't set and when invoked from selftests build, where srctree --=20 2.34.1 From nobody Mon Mar 23 19:53:34 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82EBF3B584A; Mon, 23 Mar 2026 15:40:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774280447; cv=none; b=mFPUSZocDXulAydtUMMzJw1U/0B/vP9dtntxW3w/+aENPzhp23v6VC9QkEHaShH6gnnyRyZOhDZB8DUkGY2M6ciyccJ78Bc0ulqjLyFieiLbj71SUZfG0U2KN9dVLQ9U5zrTqguWGmQ1QKAkmcoO8nuXGjG4JywiMbgNy1TE+NE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774280447; c=relaxed/simple; bh=rYNo8XPHR13NOfEGctHALckOR9FuoNu5duTDbJBWXzY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kdCBRr38+78mmjGTt4A9JYjl+nTriA0v7XTbQeTnC6b6jLMw7HVmPpeXxV4Y1MT7SdvBcz/io1AiGmbJW+K54UTop/tuAkuAY8SlGASSrRCjkJNuI6X+kroqC0ZV7xnilEHcpMXHJAOi9DIjJRWx8kgxOfI2dAb/C7hfkC4S7Y4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F13DB16F8; Mon, 23 Mar 2026 08:40:39 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 351473F694; Mon, 23 Mar 2026 08:40:42 -0700 (PDT) From: Leo Yan Date: Mon, 23 Mar 2026 15:40:06 +0000 Subject: [PATCH 5/6] selftests/bpf: Initialize operation name before use Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260323-tools_build_fix_zero_init_bpf_only-v1-5-d1cfad2f4cd1@arm.com> References: <20260323-tools_build_fix_zero_init_bpf_only-v1-0-d1cfad2f4cd1@arm.com> In-Reply-To: <20260323-tools_build_fix_zero_init_bpf_only-v1-0-d1cfad2f4cd1@arm.com> To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Lorenz Bauer , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Kees Cook , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774280421; l=1078; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=rYNo8XPHR13NOfEGctHALckOR9FuoNu5duTDbJBWXzY=; b=yD0flLirzs1eHaIrDMPcyYaiJjUVV25J9vWKzOg/3Ot0P4YbsVRXrDEoGpUiQiNtyENh/BQD8 o5FmdwFXyQlCk24+/h2G5xasRczDEk9jppae7kn11853DvY2kQ41vND X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= ASAN reports stack-buffer-overflow due to the uninitialized op_name. Initialize it to fix the issue. Fixes: 054b6c7866c7 ("selftests/bpf: Add verifier log tests for BPF_BTF_LOA= D command") Signed-off-by: Leo Yan --- tools/testing/selftests/bpf/prog_tests/verifier_log.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/bpf/prog_tests/verifier_log.c b/tools/= testing/selftests/bpf/prog_tests/verifier_log.c index aaa2854974c0a91cbbb9fc13ae0f966de1bcc818..dcbe2ef995c5b211c2b86b9555c= 02144e11ee7d6 100644 --- a/tools/testing/selftests/bpf/prog_tests/verifier_log.c +++ b/tools/testing/selftests/bpf/prog_tests/verifier_log.c @@ -317,6 +317,7 @@ static void verif_btf_log_subtest(bool bad_btf) res =3D load_btf(&opts, true); ASSERT_EQ(res, -ENOSPC, "half_log_fd"); ASSERT_EQ(strlen(logs.buf), 24, "log_fixed_25"); + snprintf(op_name, sizeof(op_name), "log_fixed"); ASSERT_STRNEQ(logs.buf, logs.reference, 24, op_name); =20 /* validate rolling verifier log logic: try all variations of log buf --=20 2.34.1 From nobody Mon Mar 23 19:53:34 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 745B53BADB5; Mon, 23 Mar 2026 15:40:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774280453; cv=none; b=FYTJ1ti4CkYlhRVyswlGJUY9dAAj+0I/QtWYx9wEb/SvUipADDfRJjb+Uz9lkYLRDQpcy0vwGDTnLMZt/Jd4nGsdLckmsvr2gTARSJZaJKfssqecLQ8VdLocVSg0c++iFEkV6tRMeT5GHw58itP/eljcHrIGdQijUQ6icQVMxeI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774280453; c=relaxed/simple; bh=K3wdiOIPmKzJb3V7P58ebfdxfQJMWLNeh3ipytoXWwU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PPKIa0tsLNxxwjvFSkoPp8lwmx/4Z4JFnx7ZaRg4rstz66uHIRsIQpfDp5FIGe0ccy4gMOADHeyZMLgWso8zLk/lhNqt6sFG4lIlkSg2/7RasC1lwAGxkwuyZqMsvH5ZfYJF2ElbpeE7RgvxCOE6FSvP/wUfnIP2H82i2k7Kq/s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0931714BF; Mon, 23 Mar 2026 08:40:44 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 40ADC3F694; Mon, 23 Mar 2026 08:40:46 -0700 (PDT) From: Leo Yan Date: Mon, 23 Mar 2026 15:40:07 +0000 Subject: [PATCH 6/6] selftests/bpf: Append extra cflags Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260323-tools_build_fix_zero_init_bpf_only-v1-6-d1cfad2f4cd1@arm.com> References: <20260323-tools_build_fix_zero_init_bpf_only-v1-0-d1cfad2f4cd1@arm.com> In-Reply-To: <20260323-tools_build_fix_zero_init_bpf_only-v1-0-d1cfad2f4cd1@arm.com> To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Lorenz Bauer , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Kees Cook , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774280421; l=2317; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=K3wdiOIPmKzJb3V7P58ebfdxfQJMWLNeh3ipytoXWwU=; b=6rkoiMv1f9bl/ohzee85t44Ww5uAMM1mVQPtXsR9tqgP/7amWpwxTqBrHN/Sm9C5YY0DfdRcn PAbEu+V1cv9CyO6twxqNxlpkHJyGSV2el40z9N3Tuk0qMa4QKtChMcg X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= Append EXTRA_CFLAGS to CFLAGS so that additional flags can be applied to the compiler. urandom_read is built with clang. Introduce URANDOM_READ_CFLAGS to copy the compiler flags without appending EXTRA_CFLAGS, which may contain incompatible options with clang. Since lib.mk appends options to CFLAGS, ensure that CFLAGS is inherited after including lib.mk. Signed-off-by: Leo Yan --- tools/testing/selftests/bpf/Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests= /bpf/Makefile index f75c4f52c02842541f385bc8cbaeab32d8195ed3..50bcf4c386ba52e6cceef4c15f9= 99d9eec6efd6e 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -158,6 +158,12 @@ endef =20 include ../lib.mk =20 +# urandom_read is built with clang. Copy $(CFLAGS) before EXTRA_CFLAGS are +# appended so that it does not inherit potentially incompatible options. +URANDOM_READ_CFLAGS :=3D $(CFLAGS) + +CFLAGS +=3D $(EXTRA_CFLAGS) + NON_CHECK_FEAT_TARGETS :=3D clean docs-clean CHECK_FEAT :=3D $(filter-out $(NON_CHECK_FEAT_TARGETS),$(or $(MAKECMDGOALS= ), "none")) ifneq ($(CHECK_FEAT),) @@ -255,7 +261,7 @@ endif $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c libu= random_read.map $(call msg,LIB,,$@) $(Q)$(CLANG) $(CLANG_TARGET_ARCH) \ - $(filter-out -static,$(CFLAGS) $(LDFLAGS)) \ + $(filter-out -static,$(URANDOM_READ_CFLAGS) $(LDFLAGS)) \ $(filter %.c,$^) $(filter-out -static,$(LDLIBS)) \ -Wno-unused-command-line-argument \ -fuse-ld=3D$(LLD) -Wl,-znoseparate-code -Wl,--build-id=3Dsha1 \ @@ -265,7 +271,7 @@ $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urand= om_read_lib2.c liburandom $(OUTPUT)/urandom_read: urandom_read.c urandom_read_aux.c $(OUTPUT)/libura= ndom_read.so $(call msg,BINARY,,$@) $(Q)$(CLANG) $(CLANG_TARGET_ARCH) \ - $(filter-out -static,$(CFLAGS) $(LDFLAGS)) $(filter %.c,$^) \ + $(filter-out -static,$(URANDOM_READ_CFLAGS) $(LDFLAGS)) $(filter %.= c,$^) \ -Wno-unused-command-line-argument \ -lurandom_read $(filter-out -static,$(LDLIBS)) -L$(OUTPUT) \ -fuse-ld=3D$(LLD) -Wl,-znoseparate-code -Wl,--build-id=3Dsha1 \ --=20 2.34.1