STRUCT LSM_CTX(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct lsm_ctx(9) β€” bestie edition

okay so this is from the Kernel API Manual, section 9, and it's literally the whole tea on struct lsm_ctx β€” which, iykyk, is the LSM context information struct πŸŽ€


✨ NAME ✨

struct lsm_ctx β€” LSM context information

Like, genuinely just the container for LSM context info. That's the vibe. 🌸


πŸ¦‹ SYNOPSIS πŸ¦‹

struct lsm_ctx {
    __u64 id;
    __u64 flags;
    __u64 len;
    __u64 ctx_len;
    __u8 ctx[];
};

Look at her. Structurally iconic. The flexible array member at the end? main character energy fr fr πŸ”₯


πŸ‘‘ Members πŸ‘‘

  • id β€” the LSM id number, see LSM_ID_XXX
  • flags β€” LSM specific flags
  • len β€” length of the lsm_ctx struct, ctx and any other data or padding
  • ctx_len β€” the size of ctx
  • ctx β€” the LSM context value

πŸ’– Description πŸ’–

okay so the rules, and bestie these are MUST rules, not suggestions:

The len field MUST be equal to the size of the lsm_ctx struct plus any additional padding and/or data placed after ctx. no cap, it has to match exactly.

In all cases ctx_len MUST be equal to the length of ctx. And listen β€” if ctx is a string value, it should be nul terminated, with ctx_len equal to `strlen(ctx) + 1`. Binary values are supported too, so it's not just strings-only over here 🫢

and now the part where you gotta respect boundaries: the flags and ctx fields SHOULD only be interpreted by the LSM specified by id. They MUST be set to zero/0 when not used. Like, don't be nosy about another LSM's fields, it's not cute πŸ™ˆ

🌈 SEE ALSO 🌈

Kernel file ./include/uapi/linux/lsm.h


πŸ’œ okay that's the whole page, go forth and initialize your structs correctly bestie, and remember: len and ctx_len are not optional vibes, they're requirements ✨

sign-off szn πŸŽ€ this one's from ./include/uapi/linux, dated October 2026, logged forever in the KERNEL API MANUAL, and it ate. periodt. πŸ‘‘

πŸ“¦ where this page comes from