Skip to main content

do_sockaddr

Function do_sockaddr 

Source
fn do_sockaddr(
    r: &Req<'_>,
    sockfd: i32,
    addr: u64,
    len: usize,
    connect: bool,
) -> Result<Outcome, i32>
Expand description

connect/bind on an AF_UNIX path, done on a replacement socket.

The tracee’s socket cannot be reached (pidfd_getfd is not allowed in a default container), so a new socket of the same type, with the same O_NONBLOCK and O_CLOEXEC, is connected or bound by the supervisor and installed over the tracee’s descriptor number. The address names the socket through its pinned parent, /proc/self/fd/<parent>/<name>, since the socket calls have no dirfd form: the parents cannot be redirected, while the kernel resolves the final name itself, so a symlink the guest swaps in there during a connect is followed. Options set on the old socket before this call, and a bind made before a connect, do not carry over. A descriptor that is not a unix socket is left to the kernel, which reports the mismatch.

§Arguments

  • r - The notification.
  • sockfd - The tracee’s socket.
  • addr - Address of the sockaddr in the tracee.
  • len - Its length.
  • connect - connect (follow a final symlink) rather than bind.