xref: /linux/include/trace/events/capability.h (revision 754916d4a2b970bc1b5104d552b5d16ab54954c0)
1*d48da4d5SJordan Rome /* SPDX-License-Identifier: GPL-2.0 */
2*d48da4d5SJordan Rome #undef TRACE_SYSTEM
3*d48da4d5SJordan Rome #define TRACE_SYSTEM capability
4*d48da4d5SJordan Rome 
5*d48da4d5SJordan Rome #if !defined(_TRACE_CAPABILITY_H) || defined(TRACE_HEADER_MULTI_READ)
6*d48da4d5SJordan Rome #define _TRACE_CAPABILITY_H
7*d48da4d5SJordan Rome 
8*d48da4d5SJordan Rome #include <linux/cred.h>
9*d48da4d5SJordan Rome #include <linux/tracepoint.h>
10*d48da4d5SJordan Rome #include <linux/user_namespace.h>
11*d48da4d5SJordan Rome 
12*d48da4d5SJordan Rome /**
13*d48da4d5SJordan Rome  * cap_capable - called after it's determined if a task has a particular
14*d48da4d5SJordan Rome  * effective capability
15*d48da4d5SJordan Rome  *
16*d48da4d5SJordan Rome  * @cred: The credentials used
17*d48da4d5SJordan Rome  * @target_ns: The user namespace of the resource being accessed
18*d48da4d5SJordan Rome  * @capable_ns: The user namespace in which the credential provides the
19*d48da4d5SJordan Rome  *              capability to access the targeted resource.
20*d48da4d5SJordan Rome  *              This will be NULL if ret is not 0.
21*d48da4d5SJordan Rome  * @cap: The capability to check for
22*d48da4d5SJordan Rome  * @ret: The return value of the check: 0 if it does, -ve if it does not
23*d48da4d5SJordan Rome  *
24*d48da4d5SJordan Rome  * Allows to trace calls to cap_capable in commoncap.c
25*d48da4d5SJordan Rome  */
26*d48da4d5SJordan Rome TRACE_EVENT(cap_capable,
27*d48da4d5SJordan Rome 
28*d48da4d5SJordan Rome 	TP_PROTO(const struct cred *cred, struct user_namespace *target_ns,
29*d48da4d5SJordan Rome 		const struct user_namespace *capable_ns, int cap, int ret),
30*d48da4d5SJordan Rome 
31*d48da4d5SJordan Rome 	TP_ARGS(cred, target_ns, capable_ns, cap, ret),
32*d48da4d5SJordan Rome 
33*d48da4d5SJordan Rome 	TP_STRUCT__entry(
34*d48da4d5SJordan Rome 		__field(const struct cred *, cred)
35*d48da4d5SJordan Rome 		__field(struct user_namespace *, target_ns)
36*d48da4d5SJordan Rome 		__field(const struct user_namespace *, capable_ns)
37*d48da4d5SJordan Rome 		__field(int, cap)
38*d48da4d5SJordan Rome 		__field(int, ret)
39*d48da4d5SJordan Rome 	),
40*d48da4d5SJordan Rome 
41*d48da4d5SJordan Rome 	TP_fast_assign(
42*d48da4d5SJordan Rome 		__entry->cred       = cred;
43*d48da4d5SJordan Rome 		__entry->target_ns    = target_ns;
44*d48da4d5SJordan Rome 		__entry->capable_ns = ret == 0 ? capable_ns : NULL;
45*d48da4d5SJordan Rome 		__entry->cap        = cap;
46*d48da4d5SJordan Rome 		__entry->ret        = ret;
47*d48da4d5SJordan Rome 	),
48*d48da4d5SJordan Rome 
49*d48da4d5SJordan Rome 	TP_printk("cred %p, target_ns %p, capable_ns %p, cap %d, ret %d",
50*d48da4d5SJordan Rome 		__entry->cred, __entry->target_ns, __entry->capable_ns, __entry->cap,
51*d48da4d5SJordan Rome 		__entry->ret)
52*d48da4d5SJordan Rome );
53*d48da4d5SJordan Rome 
54*d48da4d5SJordan Rome #endif /* _TRACE_CAPABILITY_H */
55*d48da4d5SJordan Rome 
56*d48da4d5SJordan Rome /* This part must be outside protection */
57*d48da4d5SJordan Rome #include <trace/define_trace.h>
58