From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (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 2B000396D14 for ; Tue, 24 Feb 2026 15:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771947775; cv=none; b=kk5WXRRYSaWZ3isrrgASTVGFaXk7oWvSsfqszYt99jRFbRwHqYAqqzu/dlunFtayXQFspRZPSSSiVJYAai2hexJN8TGKaStpoYrImad/Em7rTd3Ch5e2mf94Ay5A5gk9e5D7Z9FFtOKAELJnxdg6dV7cB5zYxcfJCOPH/p26MF4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771947775; c=relaxed/simple; bh=NHdxzPJAtBr7xEqxXkZkD/fNi+zTIHjksONscrsRtW8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sWagyekuN8rj2IYKSfXJWwFzhssWrFIf2HtuqRb4BqGFlDco28w4bpPZTLXWMNlOBYdlY0lY21G7p0thNrsa9sfP1RZQNv0566pM1Dw5119QFDO2b+8bwQYx+02ZWMHKpJEUEpO9MPBUPw4RMvhrWgVr8JpS/QvjGh20VyOETd8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=vTMgeP0c; arc=none smtp.client-ip=91.218.175.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vTMgeP0c" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1771947772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2BOzvXBrvd4MIf2KjLhTZ2sIZQ/Qdk4vFnBFVzdfMQ4=; b=vTMgeP0c81KkszjqgGD3qGWLo9OUqlvVh5hqfG5GnjurGp7dmWbzvJ/c8gpg91aDTRL4Fy jeJwIeQhFjqSgDGz6bI7sLXaDO0E3AQyQ7kR/2Ba14ip54n/OSjfcBJAh0bcF2xQoEIB7H nehxhSl5Kih1JtL4lCXATJnSz+7upuY= From: Leon Hwang To: bpf@vger.kernel.org Cc: 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 , Feng Yang , Leon Hwang , Menglong Dong , Puranjay Mohan , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Pu Lehui , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, kernel-patches-bot@fb.com Subject: [PATCH bpf-next 7/8] selftests/bpf: Add a test to verify call_get_func_ip compatibility enforcement Date: Tue, 24 Feb 2026 23:40:23 +0800 Message-ID: <20260224154024.12504-8-leon.hwang@linux.dev> In-Reply-To: <20260224154024.12504-1-leon.hwang@linux.dev> References: <20260224154024.12504-1-leon.hwang@linux.dev> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Add prog_array coverage for tracing programs that differ in bpf_get_func_ip() dependency. The test verifies one-way enforcement: !call_get_func_ip programs cannot tail-call call_get_func_ip programs. Assisted-by: Codex:gpt-5.3-codex Signed-off-by: Leon Hwang --- .../bpf/prog_tests/get_func_ip_test.c | 46 +++++++++++++++++++ .../selftests/bpf/progs/get_func_ip_test.c | 6 +++ 2 files changed, 52 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c b/tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c index 7772a0f288d3..670457d4e159 100644 --- a/tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c +++ b/tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c @@ -139,3 +139,49 @@ void test_get_func_ip_test(void) test_function_entry(); test_function_body(); } + +static void test_prog_array_call_get_func_ip_compat(void) +{ + __u32 key = 0, with_get_func_ip_fd, without_get_func_ip_fd; + struct get_func_ip_test *skel = NULL; + int map_fd = -1, err; + + skel = get_func_ip_test__open(); + if (!ASSERT_OK_PTR(skel, "get_func_ip_test__open")) + return; + + err = get_func_ip_test__load(skel); + if (!ASSERT_OK(err, "get_func_ip_test__load")) + goto cleanup; + + with_get_func_ip_fd = bpf_program__fd(skel->progs.test1); + without_get_func_ip_fd = bpf_program__fd(skel->progs.test1_dummy); + if (!ASSERT_GE(with_get_func_ip_fd, 0, "with_get_func_ip_fd")) + goto cleanup; + if (!ASSERT_GE(without_get_func_ip_fd, 0, "without_get_func_ip_fd")) + goto cleanup; + + map_fd = bpf_map_create(BPF_MAP_TYPE_PROG_ARRAY, NULL, sizeof(key), + sizeof(__u32), 1, NULL); + if (!ASSERT_GE(map_fd, 0, "bpf_map_create")) + goto cleanup; + + err = bpf_map_update_elem(map_fd, &key, &without_get_func_ip_fd, BPF_ANY); + if (!ASSERT_OK(err, "bpf_map_update_elem success")) + goto cleanup; + + err = bpf_map_update_elem(map_fd, &key, &with_get_func_ip_fd, BPF_ANY); + if (!ASSERT_ERR(err, "bpf_map_update_elem failure")) + goto cleanup; + ASSERT_EQ(errno, EINVAL, "bpf_map_update_elem errno"); + +cleanup: + if (map_fd >= 0) + close(map_fd); + get_func_ip_test__destroy(skel); +} + +void test_get_func_ip_test_prog_map_compatible(void) +{ + test_prog_array_call_get_func_ip_compat(); +} diff --git a/tools/testing/selftests/bpf/progs/get_func_ip_test.c b/tools/testing/selftests/bpf/progs/get_func_ip_test.c index 45eaa54d1ac7..6a7d306af96e 100644 --- a/tools/testing/selftests/bpf/progs/get_func_ip_test.c +++ b/tools/testing/selftests/bpf/progs/get_func_ip_test.c @@ -32,6 +32,12 @@ int BPF_PROG(test1, int a) return 0; } +SEC("fentry/bpf_fentry_test1") +int BPF_PROG(test1_dummy, int a) +{ + return 0; +} + __u64 test2_result = 0; SEC("fexit/bpf_fentry_test2") int BPF_PROG(test2, int a) -- 2.52.0