sock_read_xattr(9)
πΈ NAME πΈ
sock_read_xattr β read a user.* xattr from a socket's sockfs inode π
okay so bestie, this page lives in the Kernel API Manual (sock_read_xattr(9)), and it's giving "tiny helper, big sockfs energy" β¨ no cap.
β¨ SYNOPSIS β¨
int sock_read_xattr (struct socket *sock , const char *name , void
*value , size_t size );
π ARGUMENTS π
sockβ the socket whose inode holds the xattr 𧦠literally the main character here.nameβ the full xattr name, e.g."user.bpf_test"β¨ yes, the whole name, prefix included.valueβ output buffer π«Ά this is where the value lands.sizeβ size ofvaluein bytes π bytes, not vibes.
π¦ DESCRIPTION π¦
So here's the tea: SOCK_INODE is valid only for sockfs sockets, periodt. sock_from_file rejects anything else (e.g. tun, tap) π.
This lookup is lockless: simple_xattr_get looks up the value under RCU, and there is no inode lock π. The inode lock is literally not invited to this party.
π RETURN π
On success you get the length of the value π. On error you get a negative errno π.
π SEE ALSO π
Kernel file ./net/socket.c is the main character, and the whole friend group is: move_addr_to_kernel(9), move_addr_to_user(9), sock_alloc_file(9), sock_from_file(9), sockfd_lookup(9), sock_alloc(9), sock_release(9), sock_sendmsg(9), kernel_sendmsg(9), sock_recvmsg(9), kernel_recvmsg(9), sock_create_lite(9), __sock_create(9), sock_create(9), sock_create_kern(9), sock_register(9), sock_unregister(9), kernel_bind(9), kernel_listen(9), kernel_accept(9), kernel_connect(9), kernel_getsockname(9), kernel_getpeername(9), kernel_sock_shutdown(9), kernel_sock_ip_overhead(9) β¨.
that's the page, bestie π«Ά source/version:./netβ¨ date:October 2026π and yes, we close withsock_read_xattr(9)π 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