tracing: Introduce helpers to safely handle dynamic-sized sockaddrs
[ Upstream commitd07c9ad622
] 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> Stable-dep-of:948f072ada
("SUNRPC: always free ctxt when freeing deferred request") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Родитель
7851771789
Коммит
8c26ecd887
|
@ -21,6 +21,9 @@
|
||||||
#undef __get_bitmask
|
#undef __get_bitmask
|
||||||
#define __get_bitmask(field) (char *)__get_dynamic_array(field)
|
#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
|
#undef __get_rel_dynamic_array
|
||||||
#define __get_rel_dynamic_array(field) \
|
#define __get_rel_dynamic_array(field) \
|
||||||
((void *)(&__entry->__rel_loc_##field) + \
|
((void *)(&__entry->__rel_loc_##field) + \
|
||||||
|
@ -37,6 +40,9 @@
|
||||||
#undef __get_rel_bitmask
|
#undef __get_rel_bitmask
|
||||||
#define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field)
|
#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
|
#undef __perf_count
|
||||||
#define __perf_count(c) (c)
|
#define __perf_count(c) (c)
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
#undef __get_bitmask
|
#undef __get_bitmask
|
||||||
#define __get_bitmask(field) (char *)__get_dynamic_array(field)
|
#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
|
#undef __get_rel_dynamic_array
|
||||||
#define __get_rel_dynamic_array(field) \
|
#define __get_rel_dynamic_array(field) \
|
||||||
((void *)__entry + \
|
((void *)__entry + \
|
||||||
|
@ -38,6 +41,9 @@
|
||||||
#undef __get_rel_bitmask
|
#undef __get_rel_bitmask
|
||||||
#define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field)
|
#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
|
#undef __perf_count
|
||||||
#define __perf_count(c) (__count = (c))
|
#define __perf_count(c) (__count = (c))
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,9 @@ TRACE_MAKE_SYSTEM_STR();
|
||||||
#undef __bitmask
|
#undef __bitmask
|
||||||
#define __bitmask(item, nr_bits) __dynamic_array(char, item, -1)
|
#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
|
#undef __rel_dynamic_array
|
||||||
#define __rel_dynamic_array(type, item, len) u32 __rel_loc_##item;
|
#define __rel_dynamic_array(type, item, len) u32 __rel_loc_##item;
|
||||||
|
|
||||||
|
@ -120,6 +123,9 @@ TRACE_MAKE_SYSTEM_STR();
|
||||||
#undef __rel_bitmask
|
#undef __rel_bitmask
|
||||||
#define __rel_bitmask(item, nr_bits) __rel_dynamic_array(char, item, -1)
|
#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
|
#undef TP_STRUCT__entry
|
||||||
#define TP_STRUCT__entry(args...) args
|
#define TP_STRUCT__entry(args...) args
|
||||||
|
|
||||||
|
@ -212,11 +218,14 @@ TRACE_MAKE_SYSTEM_STR();
|
||||||
#undef __string
|
#undef __string
|
||||||
#define __string(item, src) __dynamic_array(char, item, -1)
|
#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
|
#undef __bitmask
|
||||||
#define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
|
#define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
|
||||||
|
|
||||||
#undef __string_len
|
#undef __sockaddr
|
||||||
#define __string_len(item, src, len) __dynamic_array(char, item, -1)
|
#define __sockaddr(field, len) __dynamic_array(u8, field, len)
|
||||||
|
|
||||||
#undef __rel_dynamic_array
|
#undef __rel_dynamic_array
|
||||||
#define __rel_dynamic_array(type, item, len) u32 item;
|
#define __rel_dynamic_array(type, item, len) u32 item;
|
||||||
|
@ -230,6 +239,9 @@ TRACE_MAKE_SYSTEM_STR();
|
||||||
#undef __rel_bitmask
|
#undef __rel_bitmask
|
||||||
#define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1)
|
#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
|
#undef DECLARE_EVENT_CLASS
|
||||||
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
|
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
|
||||||
struct trace_event_data_offsets_##call { \
|
struct trace_event_data_offsets_##call { \
|
||||||
|
@ -349,6 +361,12 @@ TRACE_MAKE_SYSTEM_STR();
|
||||||
trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \
|
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
|
#undef __print_flags
|
||||||
#define __print_flags(flag, delim, flag_array...) \
|
#define __print_flags(flag, delim, flag_array...) \
|
||||||
({ \
|
({ \
|
||||||
|
@ -520,6 +538,9 @@ static struct trace_event_functions trace_event_type_funcs_##call = { \
|
||||||
#undef __bitmask
|
#undef __bitmask
|
||||||
#define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
|
#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
|
#undef __rel_dynamic_array
|
||||||
#define __rel_dynamic_array(_type, _item, _len) { \
|
#define __rel_dynamic_array(_type, _item, _len) { \
|
||||||
.type = "__rel_loc " #_type "[]", .name = #_item, \
|
.type = "__rel_loc " #_type "[]", .name = #_item, \
|
||||||
|
@ -535,6 +556,9 @@ static struct trace_event_functions trace_event_type_funcs_##call = { \
|
||||||
#undef __rel_bitmask
|
#undef __rel_bitmask
|
||||||
#define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1)
|
#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
|
#undef DECLARE_EVENT_CLASS
|
||||||
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \
|
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \
|
||||||
static struct trace_event_fields trace_event_fields_##call[] = { \
|
static struct trace_event_fields trace_event_fields_##call[] = { \
|
||||||
|
@ -626,6 +650,12 @@ static struct trace_event_fields trace_event_fields_##call[] = { \
|
||||||
#define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, \
|
#define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, \
|
||||||
__bitmask_size_in_longs(nr_bits))
|
__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
|
#undef DECLARE_EVENT_CLASS
|
||||||
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
|
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
|
||||||
static inline notrace int trace_event_get_offsets_##call( \
|
static inline notrace int trace_event_get_offsets_##call( \
|
||||||
|
@ -790,6 +820,15 @@ static inline notrace int trace_event_get_offsets_##call( \
|
||||||
#define __assign_bitmask(dst, src, nr_bits) \
|
#define __assign_bitmask(dst, src, nr_bits) \
|
||||||
memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(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
|
#undef __rel_dynamic_array
|
||||||
#define __rel_dynamic_array(type, item, len) \
|
#define __rel_dynamic_array(type, item, len) \
|
||||||
__entry->__rel_loc_##item = __data_offsets.item;
|
__entry->__rel_loc_##item = __data_offsets.item;
|
||||||
|
@ -821,6 +860,16 @@ static inline notrace int trace_event_get_offsets_##call( \
|
||||||
#define __assign_rel_bitmask(dst, src, nr_bits) \
|
#define __assign_rel_bitmask(dst, src, nr_bits) \
|
||||||
memcpy(__get_rel_bitmask(dst), (src), __bitmask_size_in_bytes(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
|
#undef TP_fast_assign
|
||||||
#define TP_fast_assign(args...) args
|
#define TP_fast_assign(args...) args
|
||||||
|
|
||||||
|
@ -885,10 +934,12 @@ static inline void ftrace_test_probe_##call(void) \
|
||||||
#undef __get_dynamic_array_len
|
#undef __get_dynamic_array_len
|
||||||
#undef __get_str
|
#undef __get_str
|
||||||
#undef __get_bitmask
|
#undef __get_bitmask
|
||||||
|
#undef __get_sockaddr
|
||||||
#undef __get_rel_dynamic_array
|
#undef __get_rel_dynamic_array
|
||||||
#undef __get_rel_dynamic_array_len
|
#undef __get_rel_dynamic_array_len
|
||||||
#undef __get_rel_str
|
#undef __get_rel_str
|
||||||
#undef __get_rel_bitmask
|
#undef __get_rel_bitmask
|
||||||
|
#undef __get_rel_sockaddr
|
||||||
#undef __print_array
|
#undef __print_array
|
||||||
#undef __print_hex_dump
|
#undef __print_hex_dump
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче