Re: [PATCH bpf 1/2] bpf: sockmap, af_unix sockets need to hold ref for pair sock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



John Fastabend wrote:
> Martin KaFai Lau wrote:
> > On 11/6/23 4:35 AM, Jakub Sitnicki wrote:
> > >> diff --git a/net/unix/unix_bpf.c b/net/unix/unix_bpf.c
> > >> index 2f9d8271c6ec..705eeed10be3 100644
> > >> --- a/net/unix/unix_bpf.c
> > >> +++ b/net/unix/unix_bpf.c
> > >> @@ -143,6 +143,8 @@ static void unix_stream_bpf_check_needs_rebuild(struct proto *ops)
> > >>   
> > >>   int unix_dgram_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore)
> > >>   {
> > >> +	struct sock *skpair;
> > >> +
> > >>   	if (sk->sk_type != SOCK_DGRAM)
> > >>   		return -EOPNOTSUPP;
> > >>   
> > >> @@ -152,6 +154,9 @@ int unix_dgram_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool re
> > >>   		return 0;
> > >>   	}
> > >>   
> > >> +	skpair = unix_peer(sk);
> > >> +	sock_hold(skpair);
> > >> +	psock->skpair = skpair;
> > >>   	unix_dgram_bpf_check_needs_rebuild(psock->sk_proto);
> > >>   	sock_replace_proto(sk, &unix_dgram_bpf_prot);
> > >>   	return 0;
> > > unix_dgram should not need this, since it grabs a ref on each sendmsg.
> > 
> > John, could you address this comment and respin v2?
> 
> Respinning now just letting some tests run for a bit and I'll kick it out.


v2 on the list. Unfortunately the simple fix to the selftests to test STREAM
and DGRAM types caused a test failure. I look at it Monday unless someone
beats me to it.

> 
> Thanks.
> 
> > 
> > The unix_inet_redir_to_connected() seems needing a fix in patch 2 also as 
> > pointed out by JakubS.
> > 
> > Thanks.
> > 
> > > 
> > > I'm not able to reproduce this bug for unix_dgram.
> > > 
> > > Have you seen any KASAN reports for unix_dgram from syzcaller?






[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux