STRUCT LANDLOCK_OBJECT(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 to NULL (or recycled). patience, bestie. 🫢
  • lock β€” protects against concurrent modifications. this lock must be held from the time usage drops to zero until any weak references from underobj to 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 by lock. Cf. landlock_release_inodes and release_inode. 🌈
  • {unnamed_union} β€” anonymous. she has no name, she has no label, she simply is. πŸ’€
  • rcu_free β€” enables lockless use of usage, lock and underobj from within an RCU read-side critical section. rcu_free and underops are only used by landlock_put_object. exclusive little duo, obsessed with them. ✨
  • underops β€” enables landlock_put_object to 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.h struct
  • 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