* [PATCH bpf-next 1/2] bpf: Resolve modifiers when walking structs
@ 2023-06-26 21:25 Stanislav Fomichev
2023-06-26 21:25 ` [PATCH bpf-next 2/2] selftests/bpf: Add test to exercise typedef walking Stanislav Fomichev
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Stanislav Fomichev @ 2023-06-26 21:25 UTC (permalink / raw)
To: bpf
Cc: ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
kpsingh, sdf, haoluo, jolsa
It is impossible to use skb_frag_t in the tracing program.
Resolve typedefs when walking structs.
Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
kernel/bpf/btf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 29fe21099298..3dd47451f097 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -6135,6 +6135,8 @@ static int btf_struct_walk(struct bpf_verifier_log *log, const struct btf *btf,
*flag = 0;
again:
+ if (btf_type_is_modifier(t))
+ t = btf_type_skip_modifiers(btf, t->type, NULL);
tname = __btf_name_by_offset(btf, t->name_off);
if (!btf_type_is_struct(t)) {
bpf_log(log, "Type '%s' is not a struct\n", tname);
--
2.41.0.162.gfafddb0af9-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH bpf-next 2/2] selftests/bpf: Add test to exercise typedef walking
2023-06-26 21:25 [PATCH bpf-next 1/2] bpf: Resolve modifiers when walking structs Stanislav Fomichev
@ 2023-06-26 21:25 ` Stanislav Fomichev
2023-06-27 5:06 ` Yonghong Song
2023-06-27 5:02 ` [PATCH bpf-next 1/2] bpf: Resolve modifiers when walking structs Yonghong Song
2023-06-30 8:40 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Stanislav Fomichev @ 2023-06-26 21:25 UTC (permalink / raw)
To: bpf
Cc: ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
kpsingh, sdf, haoluo, jolsa
Add new bpf_fentry_test_sinfo with skb_shared_info argument
and try to access frags.
Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
net/bpf/test_run.c | 4 ++++
.../selftests/bpf/prog_tests/verifier.c | 2 ++
.../selftests/bpf/progs/verifier_typedef.c | 23 +++++++++++++++++++
3 files changed, 29 insertions(+)
create mode 100644 tools/testing/selftests/bpf/progs/verifier_typedef.c
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index 2321bd2f9964..63b11f7a5392 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -555,6 +555,10 @@ __bpf_kfunc u32 bpf_fentry_test9(u32 *a)
return *a;
}
+void noinline bpf_fentry_test_sinfo(struct skb_shared_info *sinfo)
+{
+}
+
__bpf_kfunc int bpf_modify_return_test(int a, int *b)
{
*b += 1;
diff --git a/tools/testing/selftests/bpf/prog_tests/verifier.c b/tools/testing/selftests/bpf/prog_tests/verifier.c
index 070a13833c3f..c375e59ff28d 100644
--- a/tools/testing/selftests/bpf/prog_tests/verifier.c
+++ b/tools/testing/selftests/bpf/prog_tests/verifier.c
@@ -58,6 +58,7 @@
#include "verifier_stack_ptr.skel.h"
#include "verifier_subprog_precision.skel.h"
#include "verifier_subreg.skel.h"
+#include "verifier_typedef.skel.h"
#include "verifier_uninit.skel.h"
#include "verifier_unpriv.skel.h"
#include "verifier_unpriv_perf.skel.h"
@@ -159,6 +160,7 @@ void test_verifier_spin_lock(void) { RUN(verifier_spin_lock); }
void test_verifier_stack_ptr(void) { RUN(verifier_stack_ptr); }
void test_verifier_subprog_precision(void) { RUN(verifier_subprog_precision); }
void test_verifier_subreg(void) { RUN(verifier_subreg); }
+void test_verifier_typedef(void) { RUN(verifier_typedef); }
void test_verifier_uninit(void) { RUN(verifier_uninit); }
void test_verifier_unpriv(void) { RUN(verifier_unpriv); }
void test_verifier_unpriv_perf(void) { RUN(verifier_unpriv_perf); }
diff --git a/tools/testing/selftests/bpf/progs/verifier_typedef.c b/tools/testing/selftests/bpf/progs/verifier_typedef.c
new file mode 100644
index 000000000000..08481cfaac4b
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/verifier_typedef.c
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <vmlinux.h>
+#include <bpf/bpf_helpers.h>
+#include "bpf_misc.h"
+
+SEC("fentry/bpf_fentry_test_sinfo")
+__description("typedef: resolve")
+__success __retval(0)
+__naked void resolve_typedef(void)
+{
+ asm volatile (" \
+ r1 = *(u64 *)(r1 +0); \
+ r2 = *(u64 *)(r1 +%[frags_offs]); \
+ r0 = 0; \
+ exit; \
+" :
+ : __imm_const(frags_offs,
+ offsetof(struct skb_shared_info, frags))
+ : __clobber_all);
+}
+
+char _license[] SEC("license") = "GPL";
--
2.41.0.162.gfafddb0af9-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH bpf-next 2/2] selftests/bpf: Add test to exercise typedef walking
2023-06-26 21:25 ` [PATCH bpf-next 2/2] selftests/bpf: Add test to exercise typedef walking Stanislav Fomichev
@ 2023-06-27 5:06 ` Yonghong Song
0 siblings, 0 replies; 5+ messages in thread
From: Yonghong Song @ 2023-06-27 5:06 UTC (permalink / raw)
To: Stanislav Fomichev, bpf
Cc: ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
kpsingh, haoluo, jolsa
On 6/26/23 2:25 PM, Stanislav Fomichev wrote:
> Add new bpf_fentry_test_sinfo with skb_shared_info argument
> and try to access frags.
>
> Signed-off-by: Stanislav Fomichev <sdf@google.com>
Acked-by: Yonghong Song <yhs@fb.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH bpf-next 1/2] bpf: Resolve modifiers when walking structs
2023-06-26 21:25 [PATCH bpf-next 1/2] bpf: Resolve modifiers when walking structs Stanislav Fomichev
2023-06-26 21:25 ` [PATCH bpf-next 2/2] selftests/bpf: Add test to exercise typedef walking Stanislav Fomichev
@ 2023-06-27 5:02 ` Yonghong Song
2023-06-30 8:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Yonghong Song @ 2023-06-27 5:02 UTC (permalink / raw)
To: Stanislav Fomichev, bpf
Cc: ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
kpsingh, haoluo, jolsa
On 6/26/23 2:25 PM, Stanislav Fomichev wrote:
> It is impossible to use skb_frag_t in the tracing program.
> Resolve typedefs when walking structs.
>
> Signed-off-by: Stanislav Fomichev <sdf@google.com>
Acked-by: Yonghong Song <yhs@fb.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH bpf-next 1/2] bpf: Resolve modifiers when walking structs
2023-06-26 21:25 [PATCH bpf-next 1/2] bpf: Resolve modifiers when walking structs Stanislav Fomichev
2023-06-26 21:25 ` [PATCH bpf-next 2/2] selftests/bpf: Add test to exercise typedef walking Stanislav Fomichev
2023-06-27 5:02 ` [PATCH bpf-next 1/2] bpf: Resolve modifiers when walking structs Yonghong Song
@ 2023-06-30 8:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-06-30 8:40 UTC (permalink / raw)
To: Stanislav Fomichev
Cc: bpf, ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
kpsingh, haoluo, jolsa
Hello:
This series was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:
On Mon, 26 Jun 2023 14:25:21 -0700 you wrote:
> It is impossible to use skb_frag_t in the tracing program.
> Resolve typedefs when walking structs.
>
> Signed-off-by: Stanislav Fomichev <sdf@google.com>
> ---
> kernel/bpf/btf.c | 2 ++
> 1 file changed, 2 insertions(+)
Here is the summary with links:
- [bpf-next,1/2] bpf: Resolve modifiers when walking structs
https://git.kernel.org/bpf/bpf-next/c/819d43428a86
- [bpf-next,2/2] selftests/bpf: Add test to exercise typedef walking
https://git.kernel.org/bpf/bpf-next/c/2597a25cb865
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-06-30 8:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-26 21:25 [PATCH bpf-next 1/2] bpf: Resolve modifiers when walking structs Stanislav Fomichev
2023-06-26 21:25 ` [PATCH bpf-next 2/2] selftests/bpf: Add test to exercise typedef walking Stanislav Fomichev
2023-06-27 5:06 ` Yonghong Song
2023-06-27 5:02 ` [PATCH bpf-next 1/2] bpf: Resolve modifiers when walking structs Yonghong Song
2023-06-30 8:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox