Re: [PATCH bpf-next v3 1/3] bpf, sockmap: avoid using sk_socket after free when sending

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

 



2025/3/20 07:02, "Cong Wang" <xiyou.wangcong@xxxxxxxxx> wrote:

> 
> On Mon, Mar 17, 2025 at 05:22:54PM +0800, Jiayuan Chen wrote:
> 
> > 
> > The sk->sk_socket is not locked or referenced, and during the call to
> > 
> 
> Hm? We should have a reference in socket map, whether directly or
> 
> indirectly, right? When we add a socket to a socket map, we do call
> 
> sock_map_psock_get_checked() to obtain a reference.
> 

Yes, but we remove psock from sockmap when sock_map_close() was called
'''
sock_map_close
	lock_sock(sk);
	rcu_read_lock();
	psock = sk_psock(sk);
        // here we remove psock and the reference of psock become 0
	sock_map_remove_links(sk, psock)
        psock = sk_psock_get(sk);
        if (unlikely(!psock))
            goto no_psock;     <=== jmp to no_psock
        rcu_read_unlock();
        release_sock(sk);
        cancel_delayed_work_sync(&psock->work); <== no chance to run cancel
'''

So I think we should hold the psock when backlog running

Thanks,





[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