mirror of
https://github.com/torvalds/linux.git
synced 2026-09-26 18:12:03 +02:00
landlock: Widen ruleset versions to 64 bits
Tracepoint consumers use a ruleset ID and version to identify the
successful landlock_add_rule(2) call prefix used to create a domain.
LANDLOCK_MAX_NUM_RULES bounds distinct stored rules, not successful
calls: re-adding already-present rights for an object or port succeeds
without increasing num_rules. Because every successful call increments
the version, these calls can wrap the 32-bit counter and give different
prefixes the same trace identity.
Widen the counter and its trace fields to 64 bits so the counter cannot
wrap in practice, while preserving the successful-call semantics.
Saturating would alias all subsequent histories, while rejecting a call
at the limit would change otherwise valid syscall behavior solely for
trace metadata.
Cc: Günther Noack <gnoack@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Fixes: 63747c9477 ("landlock: Add landlock_add_rule_fs and landlock_add_rule_net tracepoints")
Reviewed-by: Günther Noack <gnoack@google.com>
Link: https://patch.msgid.link/20260922132615.1025945-1-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net>
This commit is contained in:
parent
bd3a19800d
commit
e7e0a54300
|
|
@ -344,7 +344,7 @@ TRACE_EVENT(landlock_create_ruleset,
|
|||
|
||||
TP_STRUCT__entry(
|
||||
__field( u64, ruleset_id )
|
||||
__field( u32, ruleset_version )
|
||||
__field( u64, ruleset_version )
|
||||
__field( access_mask_t, handled_fs )
|
||||
__field( access_mask_t, handled_net )
|
||||
__field( access_mask_t, scoped )
|
||||
|
|
@ -358,7 +358,7 @@ TRACE_EVENT(landlock_create_ruleset,
|
|||
__entry->scoped = ruleset->handled_masks.scope;
|
||||
),
|
||||
|
||||
TP_printk("ruleset=%llx.%u handled_fs=%s handled_net=%s scoped=%s",
|
||||
TP_printk("ruleset=%llx.%llu handled_fs=%s handled_net=%s scoped=%s",
|
||||
__entry->ruleset_id, __entry->ruleset_version,
|
||||
__print_flags(__entry->handled_fs, "|", _LANDLOCK_ACCESS_FS_NAMES),
|
||||
__print_flags(__entry->handled_net, "|", _LANDLOCK_ACCESS_NET_NAMES),
|
||||
|
|
@ -384,7 +384,7 @@ TRACE_EVENT(landlock_free_ruleset,
|
|||
|
||||
TP_STRUCT__entry(
|
||||
__field( u64, ruleset_id )
|
||||
__field( u32, ruleset_version )
|
||||
__field( u64, ruleset_version )
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
|
|
@ -392,7 +392,7 @@ TRACE_EVENT(landlock_free_ruleset,
|
|||
__entry->ruleset_version = ruleset->version;
|
||||
),
|
||||
|
||||
TP_printk("ruleset=%llx.%u",
|
||||
TP_printk("ruleset=%llx.%llu",
|
||||
__entry->ruleset_id, __entry->ruleset_version)
|
||||
);
|
||||
|
||||
|
|
@ -423,7 +423,7 @@ TRACE_EVENT(landlock_add_rule_path_beneath,
|
|||
|
||||
TP_STRUCT__entry(
|
||||
__field( u64, ruleset_id )
|
||||
__field( u32, ruleset_version )
|
||||
__field( u64, ruleset_version )
|
||||
__field( access_mask_t, access_rights )
|
||||
__field( dev_t, dev )
|
||||
__field( ino_t, ino )
|
||||
|
|
@ -444,7 +444,7 @@ TRACE_EVENT(landlock_add_rule_path_beneath,
|
|||
__assign_str(pathname);
|
||||
),
|
||||
|
||||
TP_printk("ruleset=%llx.%u access_rights=%s dev=%u:%u ino=%lu path=%s",
|
||||
TP_printk("ruleset=%llx.%llu access_rights=%s dev=%u:%u ino=%lu path=%s",
|
||||
__entry->ruleset_id, __entry->ruleset_version,
|
||||
__print_flags(__entry->access_rights, "|", _LANDLOCK_ACCESS_FS_NAMES),
|
||||
MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino,
|
||||
|
|
@ -477,7 +477,7 @@ TRACE_EVENT(landlock_add_rule_net_port,
|
|||
|
||||
TP_STRUCT__entry(
|
||||
__field( u64, ruleset_id )
|
||||
__field( u32, ruleset_version )
|
||||
__field( u64, ruleset_version )
|
||||
__field( access_mask_t, access_rights )
|
||||
__field( u64, port )
|
||||
),
|
||||
|
|
@ -490,7 +490,7 @@ TRACE_EVENT(landlock_add_rule_net_port,
|
|||
__entry->port = port;
|
||||
),
|
||||
|
||||
TP_printk("ruleset=%llx.%u access_rights=%s port=%llu",
|
||||
TP_printk("ruleset=%llx.%llu access_rights=%s port=%llu",
|
||||
__entry->ruleset_id, __entry->ruleset_version,
|
||||
__print_flags(__entry->access_rights, "|", _LANDLOCK_ACCESS_NET_NAMES),
|
||||
__entry->port)
|
||||
|
|
@ -526,7 +526,7 @@ TRACE_EVENT(landlock_create_domain,
|
|||
__field( u64, domain_id )
|
||||
__field( u64, parent_id )
|
||||
__field( u64, ruleset_id )
|
||||
__field( u32, ruleset_version )
|
||||
__field( u64, ruleset_version )
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
|
|
@ -538,7 +538,7 @@ TRACE_EVENT(landlock_create_domain,
|
|||
__entry->ruleset_version = ruleset->version;
|
||||
),
|
||||
|
||||
TP_printk("domain=%llx parent=%llx ruleset=%llx.%u",
|
||||
TP_printk("domain=%llx parent=%llx ruleset=%llx.%llu",
|
||||
__entry->domain_id, __entry->parent_id,
|
||||
__entry->ruleset_id, __entry->ruleset_version)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -171,9 +171,10 @@ struct landlock_ruleset {
|
|||
* @version: Counter incremented on each successful
|
||||
* landlock_add_rule(2), including when it only extends an existing
|
||||
* rule's access rights. Used by tracepoints to correlate a domain with
|
||||
* the exact ruleset state it was created from. Protected by @lock.
|
||||
* the exact successful rule history it was created from. Protected by
|
||||
* @lock.
|
||||
*/
|
||||
u32 version;
|
||||
u64 version;
|
||||
/**
|
||||
* @id: Unique identifier for this ruleset, used for tracing.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user