STRUCT LANDLOCK_OBJECT(9)
π struct landlock_object(9) β Kernel API Manual, bestie edition β¨
okay so picture this: it's a struct landlock_object, and its whole personality is being the security blob tied to a kernel object. that's the NAME section, we ate. π
πΈ SYNOPSIS πΈ
like, here's the actual shape of it, no cap, copy it exactly:
struct landlock_object {
refcount_t usage;
spinlock_t lock;
void *underobj;
union {
struct rcu_head rcu_free;
const struct landlock_object_underops *underops;
};
};
π§ Members (the cast, the main characters) π
usageβ this counter is literally the social glue: it ties an object to the rules matching it, or keeps it alive while you're adding a new rule. the moment this counter hits zero, this struct must NOT be modified β like, do not touch, hands off, it's giving "do not perceive me". the one exception: you can still read this counter from within an RCU read-side critical section. and if you're adding a new rule to an object whose usage counter is zero? you gotta wait until the pointer to this object is set toNULL(or recycled). patience, bestie. π«Άlockβ protects against concurrent modifications. this lock must be held from the timeusagedrops to zero until any weak references fromunderobjto this object have been cleaned up. it's the "nobody move" lock of the group chat.
Lock ordering: inode->i_lock nests inside this. iykyk π
underobjβ used when cleaning up an object, and to mark an object as tied to its underlying kernel structure. this pointer is protected bylock. Cf.landlock_release_inodesandrelease_inode. π{unnamed_union}β anonymous. she has no name, she has no label, she simply is. πrcu_freeβ enables lockless use ofusage,lockandunderobjfrom within an RCU read-side critical section.rcu_freeandunderopsare only used bylandlock_put_object. exclusive little duo, obsessed with them. β¨underopsβ enableslandlock_put_objectto release the underlying object (e.g. inode). cleanup queen behavior. π§Ή
π¦ Description π¦
the goal of this structure is to enable tying a set of ephemeral access rights (pertaining to different domains, ok multitasker) to a kernel object (e.g an inode) in a safe way. and yes, "safe way" implies handling concurrent use and modification β no shortcuts, no vibes-based locking, we're doing this properly. π₯
and the lifetime of a struct landlock_object? it depends entirely on the rules referring to it. not you, not me, not the scheduler β the rules. main character energy fr fr. π
lowkey important: this is concurrency-sensitive kernel code β treat every caveat above as load-bearing, not decoration. π
π SEE ALSO π
- Kernel file
./security/landlock/object.hstruct landlock_object_underops(9)
and that's the whole vibe check, bestie π β this lil number lives at ./security/landlock, dated October 2026, and it's struct landlock_object(9). slay, stay safe, hold your locks. ππ
π¦ 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