mbox series

[bpf,v2,0/2] sockmap fix for KASAN_VMALLOC and af_unix

Message ID 20231122192452.335312-1-john.fastabend@gmail.com (mailing list archive)
Headers show
Series sockmap fix for KASAN_VMALLOC and af_unix | expand

Message

John Fastabend Nov. 22, 2023, 7:24 p.m. UTC
The af_unix tests in sockmap_listen causes a splat from KASAN_VMALLOC.
Fix it here and include an extra test to catch case where both pairs
of the af_unix socket are included in a BPF sockmap.

Also it seems the test infra is not passing type through correctly when
testing unix_inet_redir_to_connected. Unfortunately, the simple fix
also caused some CI tests to fail so investigating that now.

v2: drop changes to dgram side its fine per Jakub's point it graps a
    reference on the peer socket from each sendmsg.

John Fastabend (2):
  bpf: sockmap, af_unix stream sockets need to hold ref for pair sock
  bpf: sockmap, add af_unix test with both sockets in map

 include/linux/skmsg.h                         |  1 +
 include/net/af_unix.h                         |  1 +
 net/core/skmsg.c                              |  2 +
 net/unix/af_unix.c                            |  2 -
 net/unix/unix_bpf.c                           |  5 +++
 .../selftests/bpf/prog_tests/sockmap_listen.c | 39 ++++++++++++++++---
 .../selftests/bpf/progs/test_sockmap_listen.c |  7 ++++
 7 files changed, 49 insertions(+), 8 deletions(-)

Comments

Jakub Sitnicki Nov. 24, 2023, 1:53 p.m. UTC | #1
On Wed, Nov 22, 2023 at 11:24 AM -08, John Fastabend wrote:
> The af_unix tests in sockmap_listen causes a splat from KASAN_VMALLOC.
> Fix it here and include an extra test to catch case where both pairs
> of the af_unix socket are included in a BPF sockmap.
>
> Also it seems the test infra is not passing type through correctly when
> testing unix_inet_redir_to_connected. Unfortunately, the simple fix
> also caused some CI tests to fail so investigating that now.
>
> v2: drop changes to dgram side its fine per Jakub's point it graps a
>     reference on the peer socket from each sendmsg.
>
> John Fastabend (2):
>   bpf: sockmap, af_unix stream sockets need to hold ref for pair sock
>   bpf: sockmap, add af_unix test with both sockets in map
>
>  include/linux/skmsg.h                         |  1 +
>  include/net/af_unix.h                         |  1 +
>  net/core/skmsg.c                              |  2 +
>  net/unix/af_unix.c                            |  2 -
>  net/unix/unix_bpf.c                           |  5 +++
>  .../selftests/bpf/prog_tests/sockmap_listen.c | 39 ++++++++++++++++---
>  .../selftests/bpf/progs/test_sockmap_listen.c |  7 ++++
>  7 files changed, 49 insertions(+), 8 deletions(-)

Short of the nit pointed out by Yonghong Song:

Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>