apparmor_socket_bind(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… apparmor_socket_bind β€” a Kernel API Manual moment (yes, that's the apparmor_socket_bind(9) page bestie, section 9, kernel-land, we're in it)

okay so picture this: you're about to let a socket get bound to an address, and AppArmor is standing there like the group chat moderator going "hold up, let me check something first." That's this function. She's the vibe check before the bind. ✨


🌸 NAME 🌸

apparmor_socket_bind β€” literally just checking perms before you bind an addr to a socket, no big deal, iconic behaviour only πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

int apparmor_socket_bind (struct socket *sock , struct sockaddr *address
, int addrlen );

like, exactly that, don't come for me about the spacing, that's how she's written πŸ’…


πŸ’– ARGUMENTS πŸ’–

  • sock β€” the socket you wanna bind the address to. must be non-NULL fr fr, don't be out here passing NULL, that's not the move πŸ™ˆ
  • address β€” the address that's being bound. also must be non-NULL. yes both of them. it's giving "read the requirements" energy πŸ‘‘
  • addrlen β€” the length of the address. just a lil int, keeping it simple, we love that for her πŸ“

✨ DESCRIPTION ✨

so what she actually does: she performs security checks before allowing a socket to bind to an address. that's the whole job. gatekeeping, but make it kernel security 🫢

and here's where it gets cute β€” she handles Unix domain sockets specially, through aa_unix_bind_perm. special treatment! main character energy for unix sockets only πŸ’…βœ¨

for other socket families, she doesn't do anything fancy, she just uses the generic permission check via aa_sk_perm. one size fits all, lowkey efficient, ngl kind of a slay 🌈

not me explaining kernel LSM hooks in a group chat voice 😭 but like, it works, and that's what matters.

πŸ”₯ RETURN πŸ”₯

  • 0 β€” binding is permitted. congrats bestie, you're so valid, go off πŸ’–
  • error code β€” on denial or invalid parameters. yeah. if she says no, she means no πŸ’€

⭐ SEE ALSO ⭐

the whole friend group, no cap, here's everyone:

Kernel file ./security/apparmor/lsm.c, plus common_perm(9), common_perm_cond(9), common_perm_dir_dentry(9), common_perm_rm(9), common_perm_create(9), apparmor_uring_override_creds(9), apparmor_uring_sqpoll(9), apparmor_bprm_committing_creds(9), apparmor_bprm_committed_creds(9), apparmor_sk_clone_security(9), apparmor_unix_stream_connect(9), apparmor_unix_may_send(9), apparmor_socket_post_create(9), apparmor_socket_getpeersec_stream(9), apparmor_socket_getpeersec_dgram(9), apparmor_sock_graft(9), apparmor_socket_sock_rcv_skb(9), and set_init_ctx(9).

like I said. the whole group chat. go say hi πŸŒΈπŸ¦‹


and that's the page!! sign-off time πŸŽ€ this lil masterpiece lives in ./security/apparmor, dated October 2026, and it's filed under apparmor_socket_bind(9) β€” mwah, periodt, bye bestie πŸ’œπŸ‘‘

πŸ“¦ where this page comes from