diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 28a90672f028..14e5dd6dc17b 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -296,6 +296,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_udpv6_recvmsg); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_tcp_select_window); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_inet_sock_create); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_inet_sock_release); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_bpf_skb_load_bytes); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tcp_rtt_estimator); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_udp_enqueue_schedule_skb); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_build_skb_around); diff --git a/include/trace/hooks/net.h b/include/trace/hooks/net.h index 979bb9a9b627..54e1dcacf53e 100644 --- a/include/trace/hooks/net.h +++ b/include/trace/hooks/net.h @@ -119,6 +119,10 @@ DECLARE_RESTRICTED_HOOK(android_rvh_inet_sock_create, TP_PROTO(struct sock *sk), TP_ARGS(sk), 1); DECLARE_RESTRICTED_HOOK(android_rvh_inet_sock_release, TP_PROTO(struct sock *sk), TP_ARGS(sk), 1); +DECLARE_RESTRICTED_HOOK(android_rvh_bpf_skb_load_bytes, + TP_PROTO(const struct sk_buff *skb, u32 offset, void *to, u32 len, + int *handled, int *err), + TP_ARGS(skb, offset, to, len, handled, err), 1); DECLARE_HOOK(android_vh_tcp_rtt_estimator, TP_PROTO(struct sock *sk, long mrtt_us), TP_ARGS(sk, mrtt_us)); DECLARE_HOOK(android_vh_udp_enqueue_schedule_skb, diff --git a/net/core/filter.c b/net/core/filter.c index 790345c2546b..d91ddd443373 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -91,6 +91,8 @@ /* Keep the struct bpf_fib_lookup small so that it fits into a cacheline */ static_assert(sizeof(struct bpf_fib_lookup) == 64, "struct bpf_fib_lookup size check"); +#include + static const struct bpf_func_proto * bpf_sk_base_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog); @@ -1758,6 +1760,12 @@ BPF_CALL_4(bpf_skb_load_bytes, const struct sk_buff *, skb, u32, offset, void *, to, u32, len) { void *ptr; + int handled = 0; + int err = 0; + + trace_android_rvh_bpf_skb_load_bytes(skb, offset, to, len, &handled, &err); + if (handled) + return err; if (unlikely(offset > INT_MAX)) goto err_clear;