From nobody Tue Apr 7 13:50:15 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37A72394791 for ; Mon, 6 Apr 2026 18:22:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775499768; cv=none; b=uEE7tCNqjuLKw11Jw9aOmPT2HDQsT6Bu1BYQFoLESkhCbkTeq901T8RsY2B+sS1JWbzBS/wPRpdRI8dHTmRqYwzfAgs3GCIXM4DoVK9ljTCeDbiuo2XUJdw42WRKESQbGcSEL0t1p9pY6JV/q15/YkXbWn8j7ygzeYX4IRfzpK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775499768; c=relaxed/simple; bh=oi9iikLLALiEnY24VFCpWcYTkvvNa+ktRrLGnTBV65k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qv8O2GvV786yXIuHdMq/7yy0v/1Srwv28qCtqRY/Jfl7FMqa7CQq2vBFFwBVcO3CAq2YBll/dwA83yLat5ElI4un2hqGsqwfgfeEt5lNMTu+/HJzUssqd+54stc/MAl5mmxDrfRZZpo0jRRLefcim3i14KRuvL4hjIQ4EskswMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=M5NiXqbo; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="M5NiXqbo" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-488aa77a06eso24282445e9.0 for ; Mon, 06 Apr 2026 11:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1775499766; x=1776104566; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=hnBUcaHO1k2gTBLDn9MaOizJd/ELdZ7iIsdz0Nzo7xE=; b=M5NiXqboFE0/IJYSuw7fGtXFrnAEsIgjIZ4IfQyW0BzcYL19ToEFz20TyqA9JwHBNS CRq9cGclN2kXAEMETbV/M9DaBTuA1PYCx7TMpABbkv3dq3nMSYLvHEZEpJj7M7RTJ/98 cfCCO++TPzCzMnJoto+9Gt3El8DA74tGF07EW9b86rOBpCazmeW4dVJWMD/gcFknMv/w 44zKIcaqAFJHJrw2+v+vAVNs4REN0Fi7LlvZmUaLaYQ5nEbhDKYkqgj5DHbGOYHgk4XP 1duypryJw0b4baVJnICc+uEtSWgYToWoGscXkaY4M7qawyPQYncP4DLPYBIMVzm86C/3 UOuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775499766; x=1776104566; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=hnBUcaHO1k2gTBLDn9MaOizJd/ELdZ7iIsdz0Nzo7xE=; b=aWJs0v/C8e/5wA4IuYjRGagSoG5pUY29+MGezgwyc35750ln5lw8AG5ywOt829UiqQ RBTuqdJLgKEb57SpSt/cKVtG5ztjVukaE6a/ahjVaiYYPs0qlWBZKEip5aemTDuycUu+ 2KhImqyYIlJpweyOTFT9TtGPqt4Nt0WTLe1yrfGKrShLN9I41lRxKQZt48QlvwZU15/n LRpFtjkwiJIArHeDecXUP1SYfU4G6KtNbRte72a+nZxOwgucd28HXemV6t0z//83oOKj WyCNji/L2+AmGWrqccYzghTjRpP1NBRorGhIZ0lBcA07bTCQGxyLtu/iI2IraG0+/WUs mh/g== X-Forwarded-Encrypted: i=1; AJvYcCWEA80Tyyf9ixi4+CXTveDTg7zRs8dErwF/lLt3ejS+v0pUfgItpL+SAyLUc0StYTTzCudXXGoaA8Ne5og=@vger.kernel.org X-Gm-Message-State: AOJu0YypYHo347hmV/Mjhvj8R26qslcYUyf/CWRti9eqjHagdxkAkKkm 3FvsVQRxoyrSrW+82+tkfkS35BthTijwh3WCXoOgG4DoBxJVG43an78D5adEzCFld8o= X-Gm-Gg: AeBDieuyJZLCbGKerOT4CeJoCEJ3ODTIjFRQqcsNiiJaOlYnfV5bTCthvmwBloVWkZy mL8axUte0qIuMXIRmlf0AxnSNAIqr+fxF4hjwjEaqpEF/e3EU6Bbkh2dsHSD2CG3ZEbmZT9UpAU PdLywsGFMAK8adJLtDsEB56q6CZW8xBFLOVGZVeqA8EiRf44EkEZltADdtGOcOGL3Y+1ovMUoIu NazfBSP9VnyszvxfR5SoDnM7jejkUcw/j5JxUhXeiwSBxaigWKh9pdjwFbadPhzuc6eo/GLR4ST kJ3TnehnK6JKakAHJFgUI6KXOv7dkuoA61ZtzxK8EmEQZwdV3zx8e6VAfScy0C1ZxB4FgwnxqSU R3mubEjrZZOk/zSYL9VuxKYI2TdZNyRsg8yXIkm8xtX5fi47WYWsAwB5We9Cu0wzTowhRy3NTS+ Bujw2sqBWu8dYd X-Received: by 2002:a05:600c:4ec7:b0:485:3a03:ceca with SMTP id 5b1f17b1804b1-488997ee016mr179420795e9.23.1775499765553; Mon, 06 Apr 2026 11:22:45 -0700 (PDT) Received: from localhost ([2804:7f0:b767:120d:a4df:3777:2c55:2b95]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-56d9bd0a8a3sm18067021e0c.17.2026.04.06.11.22.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2026 11:22:44 -0700 (PDT) From: =?utf-8?q?Ricardo_B=2E_Marli=C3=A8re?= Date: Mon, 06 Apr 2026 15:22:20 -0300 Subject: [PATCH v4 08/10] selftests/bpf: Provide weak definitions for cross-test functions 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: <20260406-selftests-bpf_misconfig-v4-8-9914f50efdf7@suse.com> References: <20260406-selftests-bpf_misconfig-v4-0-9914f50efdf7@suse.com> In-Reply-To: <20260406-selftests-bpf_misconfig-v4-0-9914f50efdf7@suse.com> To: Andrii Nakryiko , Eduard Zingerman , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Kumar Kartikeya Dwivedi , Song Liu , Yonghong Song , Jiri Olsa , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, =?utf-8?q?Ricardo_B=2E_Marli=C3=A8re?= X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=openssh-sha256; t=1775499736; l=3476; i=rbm@suse.com; h=from:subject:message-id; bh=oi9iikLLALiEnY24VFCpWcYTkvvNa+ktRrLGnTBV65k=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgguRCc5X8/UX9M40lkMnr//aFGOhce x5ezt8MFNUFlqYAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QDcyKsZj5BbhkMTaLt7zN8tfoxhdaU278E5+BE1RWJOQzirY89Ld9uBt7Bx6eSfNMZOelIVxE3s CgmuRL8nbfwc= X-Developer-Key: i=rbm@suse.com; a=openssh; fpr=SHA256:pzhe0fJpYLz+3cZ33FFPhIfaUElk9CXPFFXmalIH+1g Some test files reference functions defined in other test translation units. When those units are not compiled (e.g. because a BPF skeleton could not be generated), the link step fails with undefined references. Replace forward declarations with weak stub definitions for: - uprobe_multi_func_{1,2,3}() in bpf_cookie.c (defined in uprobe_multi_test.c) - stack_mprotect() in bpf_cookie.c and iters.c (defined in test_lsm.c) The linker will prefer the strong definitions from the original objects when they are present, and fall back to the stubs otherwise. The uprobe stubs are marked noinline because uprobe_multi_test_run() takes their addresses directly to configure the BPF program's uprobe attachment points. An inlined function has no stable address in the binary, which would cause the attachment to probe the wrong location. Signed-off-by: Ricardo B. Marli=C3=A8re --- .../testing/selftests/bpf/prog_tests/bpf_cookie.c | 24 +++++++++++++++++-= ---- tools/testing/selftests/bpf/prog_tests/iters.c | 10 ++++++++- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c b/tools/te= sting/selftests/bpf/prog_tests/bpf_cookie.c index 35adc3f6d443..5fc6b2cd0bb9 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c @@ -252,10 +252,17 @@ static void kprobe_multi_attach_api_subtest(void) kprobe_multi__destroy(skel); } =20 -/* defined in prog_tests/uprobe_multi_test.c */ -void uprobe_multi_func_1(void); -void uprobe_multi_func_2(void); -void uprobe_multi_func_3(void); +/* + * Weak uprobe target stubs. noinline is required because + * uprobe_multi_test_run() takes their addresses to configure the BPF + * program's attachment points; an inlined function has no stable + * address in the binary to probe. The strong definitions in + * uprobe_multi_test.c take precedence when that translation unit is + * linked. + */ +noinline __weak void uprobe_multi_func_1(void) {} +noinline __weak void uprobe_multi_func_2(void) {} +noinline __weak void uprobe_multi_func_3(void) {} =20 static void uprobe_multi_test_run(struct uprobe_multi *skel) { @@ -574,7 +581,14 @@ static void tracing_subtest(struct test_bpf_cookie *sk= el) close(fmod_ret_fd); } =20 -int stack_mprotect(void); +/* + * Weak stub for stack_mprotect(); the real definition lives in + * test_lsm.c and takes precedence when that object is linked in. + */ +__weak int stack_mprotect(void) +{ + return 0; +} =20 static void lsm_subtest(struct test_bpf_cookie *skel) { diff --git a/tools/testing/selftests/bpf/prog_tests/iters.c b/tools/testing= /selftests/bpf/prog_tests/iters.c index a539980a2fbe..6888bc9173fd 100644 --- a/tools/testing/selftests/bpf/prog_tests/iters.c +++ b/tools/testing/selftests/bpf/prog_tests/iters.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "cgroup_helpers.h" =20 @@ -202,7 +203,14 @@ static void subtest_task_iters(void) iters_task__destroy(skel); } =20 -extern int stack_mprotect(void); +/* + * Weak stub for stack_mprotect(); the real definition lives in + * test_lsm.c and takes precedence when that object is linked in. + */ +__weak int stack_mprotect(void) +{ + return 0; +} =20 static void subtest_css_task_iters(void) { --=20 2.53.0