selinux_netlbl_sock_getattr(9)
π selinux_netlbl_sock_getattr(9) β like, the Kernel API Manual page, bestie
okay so this is selinux_netlbl_sock_getattr, and yes it lives in section 9 of the Kernel API Manual (the big-kid kernel-functions section, iykyk). it's a tiny little function but it's doing something very real, so let's get into it π«Ά
β¨ NAME β¨
selinux_netlbl_sock_getattr β gets you the cached NetLabel secattr. that's it. that's the whole vibe. π
πΈ SYNOPSIS πΈ
struct netlbl_lsm_secattr * selinux_netlbl_sock_getattr (const struct
sock *sk , u32 sid );
ok so it hands you back a struct netlbl_lsm_secattr * β a pointer, so like, handle with care and don't lose it β and it takes two things: a sk and a sid. slay. π
π¦ ARGUMENTS π¦
skβ the socket. the actual socket, bestie, the one you're asking about π§¦sidβ the SID. yes, that SID. the one you're matching against β¨
π DESCRIPTION π
so here's the whole lore: it queries the socket's cached secattr, right? and then β this is the main character moment β if the SID matches the cached value, it returns the cache. literally gives it to you. iconic.
but if the SID does not match? it returns NULL. no cache for you, bestie. nothing. empty. π that's the whole function, fr fr β no cap, no extra steps.
π₯ SEE ALSO π₯
- Kernel file
./security/selinux/netlabel.cβ the source of truth, go read it π selinux_netlbl_sidlookup_cached(9)selinux_netlbl_sock_genattr(9)selinux_netlbl_cache_invalidate(9)selinux_netlbl_err(9)selinux_netlbl_sk_security_free(9)selinux_netlbl_sk_security_reset(9)selinux_netlbl_skbuff_getsid(9)selinux_netlbl_skbuff_setsid(9)selinux_netlbl_sctp_assoc_request(9)selinux_netlbl_inet_conn_request(9)selinux_netlbl_inet_csk_clone(9)selinux_netlbl_sctp_sk_clone(9)selinux_netlbl_socket_post_create(9)selinux_netlbl_sock_rcv_skb(9)selinux_netlbl_option(9)selinux_netlbl_socket_setsockopt(9)selinux_netlbl_socket_connect_helper(9)selinux_netlbl_socket_connect_locked(9)selinux_netlbl_socket_connect(9)
like, that's the whole netlabel friend group and they all ate. go say hi π
lowkey reminder: if the SID doesn't match you get NULL back, so please check before you dereference. i'm not gonna say it again (i will) π
and that's the page!! mwah π this lil beauty comes to you from ./security/selinux and it's dated October 2026 β shoutout to the kernel docs, they're serving, they're mother, periodt. π
π¦ 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