sock_read_xattr(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 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 of value in 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 with sock_read_xattr(9) πŸ’… periodt.
πŸ“¦ where this page comes from