Revert "tcp: Use skb__nullable in trace_tcp_send_reset"
PATCH 1/3 Revert "tcp: Use skb__nullable in trace_tcp_send_reset"
From: Feng Yang <[email protected]>
This commit 838a10bd2ebf
("bpf: Augment raw_tp arguments with PTR_MAYBE_NULL") has already resolved the issue, so we can roll back these patches. This reverts commit edd3f6f7588c713477e1299c38c84dcd91a7f148.
--- include/trace/events/tcp.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
include/trace/events/tcp.h +6 -6
@@ -91,10 +91,10 @@ DEFINE_RST_REASON(FN, FN) TRACE_EVENT(tcp_send_reset, TP_PROTO(const struct sock *sk, - const struct sk_buff *skb__nullable, + const struct sk_buff *skb, const enum sk_rst_reason reason), - TP_ARGS(sk, skb__nullable, reason), + TP_ARGS(sk, skb, reason), TP_STRUCT__entry( __field(const void *, skbaddr)
@@ -106,7 +106,7 @@ TRACE_EVENT(tcp_send_reset, ), TP_fast_assign( - __entry->skbaddr = skb__nullable; + __entry->skbaddr = skb; __entry->skaddr = sk;/* Zero means unknown state. */ __entry->state = sk ? sk->sk_state :0 ;
@@ -118,13 +118,13 @@ TRACE_EVENT(tcp_send_reset,const struct inet_sock *inet =inet_sk (sk);TP_STORE_ADDR_PORTS (__entry, inet, sk); - }else if (skb__nullable) { -const struct tcphdr *th = (const struct tcphdr *)skb__nullable->data; + }else if (skb) { +const struct tcphdr *th = (const struct tcphdr *)skb->data;/* * We should reverse the 4-tuple of skb, so later * it can print the right flow direction of rst. */ -TP_STORE_ADDR_PORTS_SKB (skb__nullable, th, entry->daddr, entry->saddr); +TP_STORE_ADDR_PORTS_SKB (skb, th, entry->daddr, entry->saddr); } __entry->reason = reason; ),
Signature · 1 line
2.43.0
PATCH 2/3 Revert "selftests/bpf: Add test for __nullable suffix in tp_btf"
From: Feng Yang <[email protected]>
This commit 838a10bd2ebf
("bpf: Augment raw_tp arguments with PTR_MAYBE_NULL") has already resolved the issue, so we can roll back these patches. This reverts commit 2060f07f861a237345922023e9347a204c0795af.
--- .../bpf/prog_tests/tp_btf_nullable.c | 14 ----------- .../bpf/progs/test_tp_btf_nullable.c | 24 ------------------- .../bpf/test_kmods/bpf_testmod-events.h | 6 ----- .../selftests/bpf/test_kmods/bpf_testmod.c | 2 -- 4 files changed, 46 deletions(-) delete mode 100644 tools/testing/selftests/bpf/prog_tests/tp_btf_nullable.c delete mode 100644 tools/testing/selftests/bpf/progs/test_tp_btf_nullable.c
tools/testing/selftests/bpf/prog_tests/tp_btf_nullable.c deleted +0 -14
@@ -1,14 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -#include <test_progs.h> -#include "test_tp_btf_nullable.skel.h" - -void test_tp_btf_nullable (void ) -{ -if (!env.has_testmod) { -test__skip (); -return ; - } - -RUN_TESTS (test_tp_btf_nullable); -}
tools/testing/selftests/bpf/progs/test_tp_btf_nullable.c deleted +0 -24
@@ -1,24 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -#include "vmlinux.h" -#include <bpf/bpf_helpers.h> -#include <bpf/bpf_tracing.h> -#include "../test_kmods/bpf_testmod.h" -#include "bpf_misc.h" - -SEC("tp_btf/bpf_testmod_test_nullable_bare") -__failure __msg("R1 invalid mem access 'trusted_ptr_or_null_'") -int BPF_PROG(handle_tp_btf_nullable_bare1, struct bpf_testmod_test_read_ctx *nullable_ctx) -{ -return nullable_ctx->len; -} - -SEC("tp_btf/bpf_testmod_test_nullable_bare") -int BPF_PROG (handle_tp_btf_nullable_bare2 ,struct bpf_testmod_test_read_ctx *nullable_ctx) -{ -if (nullable_ctx) -return nullable_ctx->len; -return 0 ; -} - -char _license[] SEC("license") = "GPL";
tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h +0 -6
@@ -34,12 +34,6 @@ DECLARE_TRACE(bpf_testmod_test_write_bare,TP_ARGS (task, ctx) ); -/* Used in bpf_testmod_test_read() to test __nullable suffix */ -DECLARE_TRACE (bpf_testmod_test_nullable_bare, - TP_PROTO(struct bpf_testmod_test_read_ctx *ctx__nullable), -TP_ARGS (ctx__nullable) -); -struct sk_buff ; DECLARE_TRACE(bpf_testmod_test_raw_tp_null,
tools/testing/selftests/bpf/test_kmods/bpf_testmod.c +0 -2
@@ -431,8 +431,6 @@ bpf_testmod_test_read(struct file *file, struct kobject *kobj,if (bpf_testmod_loop_test (101 ) >100 )trace_bpf_testmod_test_read (current, &ctx); -trace_bpf_testmod_test_nullable_bare (NULL ); -/* Magic number to enable writable tp */ if (len ==64 ) {struct bpf_testmod_test_writable_ctx writable = {
Signature · 1 line
2.43.0
PATCH 3/3 Revert "bpf: Support __nullable argument suffix for tp_btf"
In reply to Feng YangFrom: Feng Yang <[email protected]>
This commit 838a10bd2ebf
("bpf: Augment raw_tp arguments with PTR_MAYBE_NULL") has already resolved the issue, so we can roll back these patches. This reverts commit 8aeaed21befc90f27f4fca6dd190850d97d2e9e3.
--- kernel/bpf/btf.c | 3 --- kernel/bpf/verifier.c | 36 ++++-------------------------------- 2 files changed, 4 insertions(+), 35 deletions(-)
kernel/bpf/btf.c +0 -3
@@ -6683,9 +6683,6 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type,if (prog_args_trusted (prog)) info->reg_type |=PTR_TRUSTED ; -if (btf_param_match_suffix (btf, &args[arg],"__nullable" )) - info->reg_type |=PTR_MAYBE_NULL ; -if (prog->expected_attach_type ==BPF_TRACE_RAW_TP ) {struct btf *btf = prog->aux->attach_btf;const struct btf_type *t;
kernel/bpf/verifier.c +4 -32
@@ -28,8 +28,6 @@#include <linux/cpumask.h> #include <linux/bpf_mem_alloc.h> #include <net/xdp.h> -#include <linux/trace_events.h> -#include <linux/kallsyms.h> #include "disasm.h"
@@ -22509,13 +22507,11 @@ int bpf_check_attach_target(struct bpf_verifier_log *log, {bool prog_extension = prog->type ==BPF_PROG_TYPE_EXT ;bool prog_tracing = prog->type ==BPF_PROG_TYPE_TRACING ; -char trace_symbol[KSYM_SYMBOL_LEN ];const char prefix[] ="btf_trace_" ; -struct bpf_raw_event_map *btp;int ret =0 , subprog =-1 , i;const struct btf_type *t;bool conservative = true; -const char *tname, *fname; +const char *tname;struct btf *btf;long addr =0 ;struct module *mod =NULL ;
@@ -22655,34 +22651,10 @@ int bpf_check_attach_target(struct bpf_verifier_log *log,return -EINVAL ; } tname +=sizeof (prefix) -1 ; - -/* The func_proto of "btf_trace_##tname" is generated from typedef without argument -* names. Thus using bpf_raw_event_map to get argument names. -*/ - btp =bpf_get_raw_tracepoint (tname); -if (!btp) + t =btf_type_by_id (btf, t->type); +if (!btf_type_is_ptr (t)) +/* should never happen in valid vmlinux build */ return -EINVAL ; - fname =kallsyms_lookup ((unsigned long )btp->bpf_func,NULL ,NULL ,NULL , - trace_symbol); -bpf_put_raw_tracepoint (btp); - -if (fname) - ret =btf_find_by_name_kind (btf, fname,BTF_KIND_FUNC ); - -if (!fname || ret <0 ) { -bpf_log (log,"Cannot find btf of tracepoint template, fall back to %s%s.\n" , - prefix, tname); - t =btf_type_by_id (btf, t->type); -if (!btf_type_is_ptr (t)) -/* should never happen in valid vmlinux build */ -return -EINVAL ; - }else { - t =btf_type_by_id (btf, ret); -if (!btf_type_is_func (t)) -/* should never happen in valid vmlinux build */ -return -EINVAL ; - } - t =btf_type_by_id (btf, t->type);if (!btf_type_is_func_proto (t))/* should never happen in valid vmlinux build */
Signature · 1 line
2.43.0
Re: [PATCH 3/3] Revert "bpf: Support __nullable argument suffix for tp_btf"
Quoted 19 lines · Feng Yang
From: Feng Yang <[email protected]>
This commit
838a10bd2ebf
("bpf: Augmentraw_tparguments withPTR_MAYBE_NULL") has already resolved the issue, so we can roll back these patches. This reverts commit8aeaed21befc90f27f4fca6dd190850d97d2e9e3.Signed-off-by Feng Yang <[email protected]>--- kernel/bpf/btf.c | 3 --- kernel/bpf/verifier.c | 36 ++++-------------------------------- 2 files changed, 4 insertions(+), 35 deletions(-)kernel/bpf/btf.c +0
-0
kernel/bpf/btf.c bool btf_ctx_access(int off, int size, enum bpf_access_type type, · line 6688
Quoted 6 lines
kernel/bpf/btf.c +0
-3@@ -6683,9 +6683,6 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type,if (prog_args_trusted (prog)) info->reg_type |=PTR_TRUSTED ; -if (btf_param_match_suffix (btf, &args[arg],"__nullable" )) - info->reg_type |=PTR_MAYBE_NULL ; -
Nack.
This is still useful and necessary.