forked from Minki/linux
tracing: Introduce helpers to safely handle dynamic-sized sockaddrs
Enable a struct sockaddr to be stored in a trace record as a dynamically-sized field. The common cases are AF_INET and AF_INET6 which are different sizes, and are vastly smaller than a struct sockaddr_storage. These are safer because, when used properly, the size of the sockaddr destination field in each trace record is now guaranteed to be the same as the source address that is being copied into it. Link: https://lore.kernel.org/all/164182978641.8391.8277203495236105391.stgit@bazille.1015granger.net/ Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
parent
add1511c38
commit
d07c9ad622
@ -21,6 +21,9 @@
|
||||
#undef __get_bitmask
|
||||
#define __get_bitmask(field) (char *)__get_dynamic_array(field)
|
||||
|
||||
#undef __get_sockaddr
|
||||
#define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field))
|
||||
|
||||
#undef __get_rel_dynamic_array
|
||||
#define __get_rel_dynamic_array(field) \
|
||||
((void *)(&__entry->__rel_loc_##field) + \
|
||||
@ -37,6 +40,9 @@
|
||||
#undef __get_rel_bitmask
|
||||
#define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field)
|
||||
|
||||
#undef __get_rel_sockaddr
|
||||
#define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field))
|
||||
|
||||
#undef __perf_count
|
||||
#define __perf_count(c) (c)
|
||||
|
||||
|
@ -21,6 +21,9 @@
|
||||
#undef __get_bitmask
|
||||
#define __get_bitmask(field) (char *)__get_dynamic_array(field)
|
||||
|
||||
#undef __get_sockaddr
|
||||
#define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field))
|
||||
|
||||
#undef __get_rel_dynamic_array
|
||||
#define __get_rel_dynamic_array(field) \
|
||||
((void *)__entry + \
|
||||
@ -38,6 +41,9 @@
|
||||
#undef __get_rel_bitmask
|
||||
#define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field)
|
||||
|
||||
#undef __get_rel_sockaddr
|
||||
#define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field))
|
||||
|
||||
#undef __perf_count
|
||||
#define __perf_count(c) (__count = (c))
|
||||
|
||||
|
@ -108,6 +108,9 @@ TRACE_MAKE_SYSTEM_STR();
|
||||
#undef __bitmask
|
||||
#define __bitmask(item, nr_bits) __dynamic_array(char, item, -1)
|
||||
|
||||
#undef __sockaddr
|
||||
#define __sockaddr(field, len) __dynamic_array(u8, field, len)
|
||||
|
||||
#undef __rel_dynamic_array
|
||||
#define __rel_dynamic_array(type, item, len) u32 __rel_loc_##item;
|
||||
|
||||
@ -120,6 +123,9 @@ TRACE_MAKE_SYSTEM_STR();
|
||||
#undef __rel_bitmask
|
||||
#define __rel_bitmask(item, nr_bits) __rel_dynamic_array(char, item, -1)
|
||||
|
||||
#undef __rel_sockaddr
|
||||
#define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
|
||||
|
||||
#undef TP_STRUCT__entry
|
||||
#define TP_STRUCT__entry(args...) args
|
||||
|
||||
@ -212,11 +218,14 @@ TRACE_MAKE_SYSTEM_STR();
|
||||
#undef __string
|
||||
#define __string(item, src) __dynamic_array(char, item, -1)
|
||||
|
||||
#undef __string_len
|
||||
#define __string_len(item, src, len) __dynamic_array(char, item, -1)
|
||||
|
||||
#undef __bitmask
|
||||
#define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
|
||||
|
||||
#undef __string_len
|
||||
#define __string_len(item, src, len) __dynamic_array(char, item, -1)
|
||||
#undef __sockaddr
|
||||
#define __sockaddr(field, len) __dynamic_array(u8, field, len)
|
||||
|
||||
#undef __rel_dynamic_array
|
||||
#define __rel_dynamic_array(type, item, len) u32 item;
|
||||
@ -230,6 +239,9 @@ TRACE_MAKE_SYSTEM_STR();
|
||||
#undef __rel_bitmask
|
||||
#define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1)
|
||||
|
||||
#undef __rel_sockaddr
|
||||
#define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
|
||||
|
||||
#undef DECLARE_EVENT_CLASS
|
||||
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
|
||||
struct trace_event_data_offsets_##call { \
|
||||
@ -349,6 +361,12 @@ TRACE_MAKE_SYSTEM_STR();
|
||||
trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \
|
||||
})
|
||||
|
||||
#undef __get_sockaddr
|
||||
#define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field))
|
||||
|
||||
#undef __get_rel_sockaddr
|
||||
#define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field))
|
||||
|
||||
#undef __print_flags
|
||||
#define __print_flags(flag, delim, flag_array...) \
|
||||
({ \
|
||||
@ -518,6 +536,9 @@ static struct trace_event_functions trace_event_type_funcs_##call = { \
|
||||
#undef __bitmask
|
||||
#define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
|
||||
|
||||
#undef __sockaddr
|
||||
#define __sockaddr(field, len) __dynamic_array(u8, field, len)
|
||||
|
||||
#undef __rel_dynamic_array
|
||||
#define __rel_dynamic_array(_type, _item, _len) { \
|
||||
.type = "__rel_loc " #_type "[]", .name = #_item, \
|
||||
@ -533,6 +554,9 @@ static struct trace_event_functions trace_event_type_funcs_##call = { \
|
||||
#undef __rel_bitmask
|
||||
#define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1)
|
||||
|
||||
#undef __rel_sockaddr
|
||||
#define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
|
||||
|
||||
#undef DECLARE_EVENT_CLASS
|
||||
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \
|
||||
static struct trace_event_fields trace_event_fields_##call[] = { \
|
||||
@ -624,6 +648,12 @@ static struct trace_event_fields trace_event_fields_##call[] = { \
|
||||
#define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, \
|
||||
__bitmask_size_in_longs(nr_bits))
|
||||
|
||||
#undef __sockaddr
|
||||
#define __sockaddr(field, len) __dynamic_array(u8, field, len)
|
||||
|
||||
#undef __rel_sockaddr
|
||||
#define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
|
||||
|
||||
#undef DECLARE_EVENT_CLASS
|
||||
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
|
||||
static inline notrace int trace_event_get_offsets_##call( \
|
||||
@ -788,6 +818,15 @@ static inline notrace int trace_event_get_offsets_##call( \
|
||||
#define __assign_bitmask(dst, src, nr_bits) \
|
||||
memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits))
|
||||
|
||||
#undef __sockaddr
|
||||
#define __sockaddr(field, len) __dynamic_array(u8, field, len)
|
||||
|
||||
#undef __get_sockaddr
|
||||
#define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field))
|
||||
|
||||
#define __assign_sockaddr(dest, src, len) \
|
||||
memcpy(__get_dynamic_array(dest), src, len)
|
||||
|
||||
#undef __rel_dynamic_array
|
||||
#define __rel_dynamic_array(type, item, len) \
|
||||
__entry->__rel_loc_##item = __data_offsets.item;
|
||||
@ -819,6 +858,16 @@ static inline notrace int trace_event_get_offsets_##call( \
|
||||
#define __assign_rel_bitmask(dst, src, nr_bits) \
|
||||
memcpy(__get_rel_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits))
|
||||
|
||||
#undef __rel_sockaddr
|
||||
#define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
|
||||
|
||||
#undef __get_rel_sockaddr
|
||||
#define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field))
|
||||
|
||||
#define __assign_rel_sockaddr(dest, src, len) \
|
||||
memcpy(__get_rel_dynamic_array(dest), src, len)
|
||||
|
||||
|
||||
#undef TP_fast_assign
|
||||
#define TP_fast_assign(args...) args
|
||||
|
||||
@ -883,10 +932,12 @@ static inline void ftrace_test_probe_##call(void) \
|
||||
#undef __get_dynamic_array_len
|
||||
#undef __get_str
|
||||
#undef __get_bitmask
|
||||
#undef __get_sockaddr
|
||||
#undef __get_rel_dynamic_array
|
||||
#undef __get_rel_dynamic_array_len
|
||||
#undef __get_rel_str
|
||||
#undef __get_rel_bitmask
|
||||
#undef __get_rel_sockaddr
|
||||
#undef __print_array
|
||||
#undef __print_hex_dump
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user