ANDROID: GKI: net: add vendor hooks for 'struct sock' lifecycle
Some vendors want to add a field when a 'sruct sock' is added so give a hook to handle this. Any memory allocated when trace_android_rvh_sk_alloc() is called needs to be freed when trace_android_rvh_sk_free() is called. Note, if trace_android_rvh_sk_alloc() fails, be sure to be able to handle this in trace_android_rvh_sk_free(), but that should not be an issue as that needs to be addressed in vendor code that runs for 'struct sock' objects that have been created before the vendor code is loaded no matter what. Bug: 171013716 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I9ed93e8bffef3cd8fbde4d62fc14596764a85304
This commit is contained in:
@@ -47,6 +47,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_write_wait_finish);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_show_task);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ptype_head);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kfree_skb);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sk_alloc);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sk_free);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_arch_set_freq_scale);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_transaction_init);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_set_priority);
|
||||
|
||||
@@ -13,14 +13,21 @@
|
||||
struct packet_type;
|
||||
struct list_head;
|
||||
struct sk_buff;
|
||||
struct sock;
|
||||
DECLARE_HOOK(android_vh_ptype_head,
|
||||
TP_PROTO(const struct packet_type *pt, struct list_head *vendor_pt),
|
||||
TP_ARGS(pt, vendor_pt));
|
||||
DECLARE_HOOK(android_vh_kfree_skb,
|
||||
TP_PROTO(struct sk_buff *skb), TP_ARGS(skb));
|
||||
DECLARE_RESTRICTED_HOOK(android_rvh_sk_alloc,
|
||||
TP_PROTO(struct sock *sock), TP_ARGS(sock), 1);
|
||||
DECLARE_RESTRICTED_HOOK(android_rvh_sk_free,
|
||||
TP_PROTO(struct sock *sock), TP_ARGS(sock), 1);
|
||||
#else
|
||||
#define trace_android_vh_ptype_head(pt, vendor_pt)
|
||||
#define trace_android_vh_kfree_skb(skb)
|
||||
#define trace_android_rvh_sk_alloc(sock)
|
||||
#define trace_android_rvh_sk_free(sock)
|
||||
#endif
|
||||
#endif /* _TRACE_HOOK_NET_VH_H */
|
||||
/* This part must be outside protection */
|
||||
|
||||
@@ -134,6 +134,7 @@
|
||||
#include <net/bpf_sk_storage.h>
|
||||
|
||||
#include <trace/events/sock.h>
|
||||
#include <trace/hooks/net.h>
|
||||
|
||||
#include <net/tcp.h>
|
||||
#include <net/busy_poll.h>
|
||||
@@ -1608,6 +1609,8 @@ static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,
|
||||
if (security_sk_alloc(sk, family, priority))
|
||||
goto out_free;
|
||||
|
||||
trace_android_rvh_sk_alloc(sk);
|
||||
|
||||
if (!try_module_get(prot->owner))
|
||||
goto out_free_sec;
|
||||
sk_tx_queue_clear(sk);
|
||||
@@ -1617,6 +1620,7 @@ static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,
|
||||
|
||||
out_free_sec:
|
||||
security_sk_free(sk);
|
||||
trace_android_rvh_sk_free(sk);
|
||||
out_free:
|
||||
if (slab != NULL)
|
||||
kmem_cache_free(slab, sk);
|
||||
@@ -1636,6 +1640,7 @@ static void sk_prot_free(struct proto *prot, struct sock *sk)
|
||||
cgroup_sk_free(&sk->sk_cgrp_data);
|
||||
mem_cgroup_sk_free(sk);
|
||||
security_sk_free(sk);
|
||||
trace_android_rvh_sk_free(sk);
|
||||
if (slab != NULL)
|
||||
kmem_cache_free(slab, sk);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user