STRUCT LANDLOCK_DOMAIN(9)
π 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 theptraceand 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 bylandlock_put_domain_deferredwhenusagereaches zero. and when that happens, the fieldsusage,num_layersandhandled_masksare then unused π like they just sit there, unemployed, not invited to the party π{unnamed_struct}β anonymous π«₯ again, mysterious queenusageβ the number of credentials referencing this domain π like a little fan counternum_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 tripsFORTIFY: 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 π
- Kernel file
./security/landlock/domain.h struct landlock_details(9)struct landlock_hierarchy(9)landlock_union_access_masks(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms