capability.h 1.7 KB

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