vsock_check_source(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 VSOCK_CHECK_SOURCE(9) πŸ’…

okay so bestie, welcome to the Kernel API Manual β€” yes we're reading kernel manpages now, this is our era ✨ and today's main character is vsock_check_source(9), a tiny function with big "am I supposed to be here" energy πŸŽ€


πŸ“› NAME πŸ“›

vsock_check_source β€” the vibe check for packets πŸ’– it validates whether a packet's source actually matches the socket's stored peer. no cap, it's just doing security door duty 🫢


✨ SYNOPSIS ✨

bool vsock_check_source (const struct vsock_sock *vsk , const struct
vsock_transport *transport , const struct sockaddr_vm *src );

look at her, three arguments, returns a bool, she's so clean, she's so iconic πŸ‘‘


🧚 ARGUMENTS 🧚

  • vsk β€” the socket that's receiving the packet, aka the one getting the mail πŸ“¬ (type: const struct vsock_sock *)
  • transport β€” the transport that's receiving the packet, the delivery service in question 🚚 (type: const struct vsock_transport *)
  • src β€” the source address pulled straight out of the packet, like checking the return address on an envelope βœ‰οΈ (type: const struct sockaddr_vm *)

πŸ”₯ RETURN πŸ”₯

it returns true when both of these slay πŸ’―:

  1. the packet arrived on the socket's assigned transport, and
  2. its source matches the stored peer 🫢

now for the loopback lore, because this part is lowkey important πŸ‘€: loopback packets are generated internally and they always use the local CID as their source β€” and yes, that includes connections that are using a valid CID alias 🌈. it's giving "internal mail doesn't need a stamp," iykyk.

if it's not both of those things, don't expect a true back, bestie πŸ™ˆ

πŸ’€ DESCRIPTION πŸ’€

two rules, and they're not optional, fr fr:

  • the caller must hold the socket lock πŸ”’ do not skip this, this is the whole assignment
  • do not call this for listening sockets πŸš«πŸ‘‚ listening sockets accept packets from any source and have no assigned transport β€” so this check literally doesn't apply to them, it's not their moment
⚠️ seriously, the socket lock thing is not a suggestion. and the listening-socket thing is a must not, not a "prolly shouldn't" 😭

πŸ‘‘ SEE ALSO πŸ‘‘

  • Kernel file ./net/vmw_vsock/af_vsock.c β€” go read the source, she's right there, go be nosy πŸ¦‹

🌸 okay that's the whole page, you ate that πŸ“ this diva lives in ./net/vmw_vsock and the calendar says October 2026 ⭐ periodt. now go hold that socket lock πŸ’œπŸ«Ά

πŸ“¦ where this page comes from