Skip to contentSkip to conversation

security: add trace event for cap_capable

PATCH Superseded Jordan Rome 3 participants 3 messages Nov 28, 2024 – Nov 30, 2024

Subsystems (3)

v8 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v8 1/1 security: add trace event for cap_capable

In cases where we want a stable way to observe/trace cap_capable (e.g. protection from inlining and API updates) add a tracepoint that passes:
- The credentials used
- The user namespace of the resource being accessed
- The user namespace in which the credential provides the capability to access the targeted resource
- The capability to check for
- The return value of the check

---
 MAINTAINERS                       |  1 +
 include/trace/events/capability.h | 57 +++++++++++++++++++++++++++++++
 security/commoncap.c              | 57 +++++++++++++++++++++----------
 3 files changed, 97 insertions(+), 18 deletions(-)
 create mode 100644 include/trace/events/capability.h
MAINTAINERS +1 -0
index f870842fad9c..b90df58f6030 100644
@@ -5103,6 +5103,7 @@ M:	Serge Hallyn <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	include/linux/capability.h
+F:	include/trace/events/capability.h
 F:	include/uapi/linux/capability.h
 F:	kernel/capability.c
 F:	security/commoncap.c
include/trace/events/capability.h new file +57 -0

57 lines not on this page · raw message

security/commoncap.c +39 -18

96 lines not on this page · raw message

--
2.43.5

maintainer Reviewed-by on v8 1/1
#1 lore raw
Quoted 11 lines · Jordan Rome

In cases where we want a stable way to observe/trace cap_capable (e.g. protection from inlining and API updates) add a tracepoint that passes:
- The credentials used
- The user namespace of the resource being accessed
- The user namespace in which the credential provides the capability to access the targeted resource
- The capability to check for
- The return value of the check

Quoted 7 lines
---
 MAINTAINERS                       |  1 +
 include/trace/events/capability.h | 57 +++++++++++++++++++++++++++++++
 security/commoncap.c              | 57 +++++++++++++++++++++----------
 3 files changed, 97 insertions(+), 18 deletions(-)
 create mode 100644 include/trace/events/capability.h

I'm personally not a fan of the helper based approach here, it adds unnecessary complexity in my opinion, but I understand that was an edict handed to you. Otherwise, and within the other constraints, I think this looks okay.

Signature · 1 line
paul-moore.com
maintainer Reviewed-by
#2 lore raw
Quoted 20 lines · Paul Moore
Quoted 11 lines · Jordan Rome

In cases where we want a stable way to observe/trace cap_capable (e.g. protection from inlining and API updates) add a tracepoint that passes:
- The credentials used
- The user namespace of the resource being accessed
- The user namespace in which the credential provides the capability to access the targeted resource
- The capability to check for
- The return value of the check

Quoted 7 lines
---
 MAINTAINERS                       |  1 +
 include/trace/events/capability.h | 57 +++++++++++++++++++++++++++++++
 security/commoncap.c              | 57 +++++++++++++++++++++----------
 3 files changed, 97 insertions(+), 18 deletions(-)
 create mode 100644 include/trace/events/capability.h
Quoted 6 lines

I'm personally not a fan of the helper based approach here, it adds unnecessary complexity in my opinion, but I understand that was an edict handed to you. Otherwise, and within the other constraints, I think this looks okay.

Thanks, I'll add it to the caps-next tree so it can get some testing until the next merge window.

Quoted 3 lines
Signature · 2 lines
-- 
paul-moore.com