From 333c956f8daa736ea9269cb5f2078e55b7a8d76e Mon Sep 17 00:00:00 2001 From: jiangxinpei Date: Thu, 1 Aug 2024 10:55:12 +0800 Subject: [PATCH] ANDROID: GKI: Add a hook for sock management. This hook allows certain applications to clone a socket, after which the vendor module performs additional operations on the new socket. When the ANDROID_OEM_DATA of the new socket is a pointer rather than a specific value, the ANDROID_OEM_DATA of the new socket will point to the same address as the ANDROID_OEM_DATA of the old socket, which may lead to a crash when the pointer is subsequently released. Bug: 356733575 Change-Id: If4d98dd7c82e252eace49567e0385af3797beb29 Signed-off-by: jiangxinpei (cherry picked from commit 4bf30ef6b71a8f498cedcf70a1df750537eee496) --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/net.h | 2 ++ net/core/sock.c | 1 + 3 files changed, 4 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 6d510e36c9e5..5268bb118d4c 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -246,6 +246,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sk_alloc); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sk_free); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_enable_thermal_genl_check); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_entry); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sk_clone_lock); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_unref_folios_to_pcp_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_alloc_fail); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_vmalloc_node_bypass); diff --git a/include/trace/hooks/net.h b/include/trace/hooks/net.h index ba6940d64a48..3913b9b3db88 100644 --- a/include/trace/hooks/net.h +++ b/include/trace/hooks/net.h @@ -29,6 +29,8 @@ DECLARE_HOOK(android_vh_tcp_write_timeout_estab_retrans, TP_PROTO(struct sock *sk), TP_ARGS(sk)); DECLARE_HOOK(android_vh_tcp_connect, TP_PROTO(struct sk_buff *skb), TP_ARGS(skb)); +DECLARE_HOOK(android_vh_sk_clone_lock, + TP_PROTO(struct sock *nsk), TP_ARGS(nsk)); struct request_sock; DECLARE_HOOK(android_vh_inet_csk_clone_lock, TP_PROTO(struct sock *newsk, const struct request_sock *req), TP_ARGS(newsk, req)); diff --git a/net/core/sock.c b/net/core/sock.c index afde78b20956..3ea553156000 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -2388,6 +2388,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority) goto out; sock_copy(newsk, sk); + trace_android_vh_sk_clone_lock(newsk); newsk->sk_prot_creator = prot;