vsock_check_source(9)
πΈ 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 π―:
- the packet arrived on the socket's assigned transport, and
- 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
- 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