03 Aug, 2021

1 commit

  • As of now, only AF_UNIX datagram socket supports sockmap. But
    unix_proto is shared for all kinds of AF_UNIX sockets, so we
    have to check the socket type in unix_bpf_update_proto() to
    explicitly reject other types, otherwise they could be added
    into sockmap, too.

    Fixes: c63829182c37 ("af_unix: Implement ->psock_update_sk_prot()")
    Reported-by: Jakub Sitnicki
    Signed-off-by: Cong Wang
    Signed-off-by: Daniel Borkmann
    Acked-by: Jakub Sitnicki
    Link: https://lore.kernel.org/bpf/20210731195038.8084-1-xiyou.wangcong@gmail.com

    Cong Wang
     

31 Jul, 2021

1 commit

  • As Eric noticed, __unix_dgram_recvmsg() may acquire u->iolock
    too, so we have to release it before calling this function.

    Fixes: 9825d866ce0d ("af_unix: Implement unix_dgram_bpf_recvmsg()")
    Reported-by: Eric Dumazet
    Signed-off-by: Cong Wang
    Signed-off-by: Andrii Nakryiko
    Acked-by: Jakub Sitnicki
    Acked-by: John Fastabend

    Cong Wang
     

16 Jul, 2021

2 commits

  • We have to implement unix_dgram_bpf_recvmsg() to replace the
    original ->recvmsg() to retrieve skmsg from ingress_msg.

    AF_UNIX is again special here because the lack of
    sk_prot->recvmsg(). I simply add a special case inside
    unix_dgram_recvmsg() to call sk->sk_prot->recvmsg() directly.

    Signed-off-by: Cong Wang
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210704190252.11866-8-xiyou.wangcong@gmail.com

    Cong Wang
     
  • Now we can implement unix_bpf_update_proto() to update
    sk_prot, especially prot->close().

    Signed-off-by: Cong Wang
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210704190252.11866-7-xiyou.wangcong@gmail.com

    Cong Wang