bpf_cgroup_read_xattr(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ bpf_cgroup_read_xattr β€” read xattr of a cgroup's node in cgroupfs

okay bestie so this is a page from the Linux Kernel API Manual, section 9 β€” like, the kernel-API girlies section, not the "type man ls" section. it's bpf_cgroup_read_xattr, and it does exactly what it says on the tin. let's get into it πŸ’–


✨ NAME ✨

bpf_cgroup_read_xattr β€” read xattr of a cgroup's node in cgroupfs

literally that. you want a cgroup's extended attribute? this is the kfunc for you, no cap 🌸


πŸŽ€ SYNOPSIS πŸŽ€

__bpf_kfunc int bpf_cgroup_read_xattr (struct cgroup *cgroup , const
       char *name__str , struct bpf_dynptr *value_p );

that's the whole signature, character for character, don't @ me 🫢


πŸ’… ARGUMENTS πŸ’…

  • cgroup β€” the cgroup you wanna get the xattr from. your main character cgroup, basically πŸ‘‘
  • name__str β€” the name of the xattr. (and yes, it really is spelled with that double underscore, that's the BTF magic, iykyk ✨)
  • value_p β€” the output buffer where the xattr value goes. it's a struct bpf_dynptr *, so it's giving "dynptr energy" fr fr

πŸ”₯ DESCRIPTION πŸ”₯

Get the xattr name__str of cgroup and store the output in value_ptr. that's the whole job, and it ate πŸ’…

⚠️ ok so listen β€” for security reasons, only name__str with prefix "user." is allowed. like, the kernel is doing a vibe check on your attribute name and if it doesn't start with user. it is NOT coming to the party. periodt. so name it right or stay home πŸ™ˆ

⭐ RETURN ⭐

  • length of the xattr value β€” on success, slay πŸ’–
  • a negative value β€” on error, and yes bestie a negative return is the kernel's way of saying "we're not okay" 😭

🌈 SEE ALSO 🌈

the kernel file lives at ./fs/bpf_fs_kfuncs.c β€” go read it, it's iconic. and here's the whole friend group, all of them, in order:

like a whole xattr cinematic universe, we love to see it 🧚✨


and that's the page!! sourced from ./fs, dated October 2026 β€” yes, the future, because this kernel API is ahead of its time πŸ’œ mwah, go read your xattrs responsibly bestie πŸŽ€

πŸ“¦ where this page comes from