STRUCT LANDLOCK_RULESET(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct landlock_ruleset(9) β€” the Kernel API Manual, bestie edition ✨

okay so this is a page from the Kernel API Manual, and the star of the show is struct landlock_ruleset β€” literally the blueprint for a Landlock ruleset. she's iconic, she's structured, and she's about to make so much sense. πŸŽ€


✨ NAME ✨

struct landlock_ruleset β€” Landlock ruleset. that's it, that's the name, slay. πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole vibe, character for character, no cap:

struct landlock_ruleset {
    struct landlock_rules rules;
    struct mutex lock;
    refcount_t usage;
  #ifdef CONFIG_TRACEPOINTS;
    u64 version;
    u64 id;
  #endif ;
    struct access_masks quiet_masks;
    struct access_masks handled_masks;
 };

🌸 Members 🌸

bestie these are the fields, and every single one matters:

  • rules β€” the red-black tree storage for rules. that's where the rules live, periodt. 🌳
  • lock β€” protects against concurrent modifications of rules, if usage is greater than zero. she's the bodyguard fr fr. πŸ’ͺ
  • usage β€” the number of file descriptors referencing this ruleset. like a little headcount for who's holding a ref. 🫢
  • version β€” a counter that gets incremented on each successful landlock_add_rule(2), including when it only extends an existing rule's access rights. tracepoints use it to correlate a domain with the exact successful rule history it was created from. protected by lock. the way she just keeps receipts 😭⭐
  • id β€” a unique identifier for this ruleset, used for tracing. main character energy, obviously unique. πŸ¦‹
  • quiet_masks β€” stores the quiet flags for an unmerged ruleset. for a merged domain, this is stored in each layer's struct landlock_hierarchy instead. not me relocating the data, iykyk πŸ™ˆ
  • handled_masks β€” contains the subset of filesystem and network actions that are handled by this ruleset. the whole "what are we even managing here" energy. πŸ’…

🧚 Description 🧚

so here's the tea: this data structure must contain unique entries, be updatable, and quick to match an object. that's the whole assignment, and she ate. ✨πŸ”₯


🌈 SEE ALSO 🌈

the whole bestie squad, go check them out:

  • Kernel file ./security/landlock/ruleset.h
  • struct landlock_layer(9)
  • union landlock_key(9)
  • enum landlock_key_type(9)
  • struct landlock_id(9)
  • struct landlock_rule(9)
  • struct landlock_rules(9)
  • landlock_get_rule_root(9)

ngl, this page lives in ./security/landlock and it's dated October 2026 β€” so like, future vibes only. see u in the source tree, bestie πŸ’œπŸŽ€

kisses, and happy rule-matching πŸ“πŸ’–

πŸ“¦ where this page comes from