STRUCT LANDLOCK_DOMAIN(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– struct landlock_domain(9) πŸ’–

okay bestie so we're in the Kernel API Manual today and the main character is literally struct landlock_domain β€” it's the Immutable Landlock domain ✨ no cap, that's the whole vibe of the NAME section and I'm obsessed 🫢


🌸 SYNOPSIS 🌸

like, here's the whole glow-up, exactly as it is, don't touch it:

struct landlock_domain {
    struct landlock_rules rules;
    struct landlock_hierarchy *hierarchy;
    union {
      struct work_struct work_free;
      struct {
        refcount_t usage;
        u32 num_layers;
        struct access_masks handled_masks[];
      };
    };
 };

πŸŽ€ Members πŸŽ€

okay so let's meet the cast, one by one, they all ate πŸ’…

  • rules β€” the red-black tree storage for rules. that's it, that's the whole thing, a whole red-black tree just chilling in there holding your rules 🌳
  • hierarchy β€” enables hierarchy identification even when a parent domain vanishes πŸ‘» this is literally needed for the ptrace and scope restrictions, so like, it's not just decorative, it's doing actual work 🫢
  • {unnamed_union} β€” anonymous πŸ«₯ (yes that's the entire description, we love a mysterious icon)
  • work_free β€” enables freeing a domain within a lockless section πŸ”“ this is only used by landlock_put_domain_deferred when usage reaches zero. and when that happens, the fields usage, num_layers and handled_masks are then unused πŸ’€ like they just sit there, unemployed, not invited to the party πŸ™ˆ
  • {unnamed_struct} β€” anonymous πŸ«₯ again, mysterious queen
  • usage β€” the number of credentials referencing this domain πŸ‘‘ like a little fan counter
  • num_layers β€” the number of layers that are used in this domain. this is what lets you check that all the layers allow an access request βœ… (all of them, bestie, no skipping)
  • handled_masks β€” contains the subset of filesystem and network actions that are restricted by a domain πŸ’… a domain saves all layers of merged rulesets in a stack (FAM), starting from the first layer to the last one. these layers are used when merging rulesets, for user space backward compatibility (i.e. future-proof), and to properly handle merged rulesets without overlapping access rights. these layers are set once and never changed for the lifetime of the domain 🧚 periodt, they're immutable
okay important side note, bestie, don't skip this one: it's not annotated with __counted_by(num_layers) because clang miscomputes the counter address for a FAM nested in an anonymous struct within a union, which trips FORTIFY: https://github.com/llvm/llvm-project/pull/228309 β€” so yeah, that's a real thing, don't "helpfully" add it back 😭

πŸ¦‹ Description πŸ¦‹

a domain is created from a ruleset by landlock_merge_ruleset and enforced on a task 🎯 once it's created, its rules and access masks are immutable β€” like, no edits, no take-backs, it's giving set in stone ✨

and unlike struct landlock_ruleset, a domain has no lock field πŸš«πŸ”’ which lowkey makes sense given the whole immutable thing, main character energy fr fr


🌈 SEE ALSO 🌈

go read those next, iykyk πŸ“


and that's the whole page bestie!! πŸ’œ this icon lives over in ./security/landlock and the version stamp is from October 2026, and the title card says struct landlock_domain(9) β€” okay bye, hydrate and go read your kernel headers πŸ§šβ€β™€οΈπŸ’–β­

πŸ“¦ where this page comes from