lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z9tNAhMV1Y5znONo@pop-os.localdomain>
Date: Wed, 19 Mar 2025 16:02:26 -0700
From: Cong Wang <xiyou.wangcong@...il.com>
To: Jiayuan Chen <jiayuan.chen@...ux.dev>
Cc: john.fastabend@...il.com, jakub@...udflare.com, davem@...emloft.net,
	edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
	horms@...nel.org, andrii@...nel.org, eddyz87@...il.com,
	mykolal@...com, ast@...nel.org, daniel@...earbox.net,
	martin.lau@...ux.dev, song@...nel.org, yonghong.song@...ux.dev,
	kpsingh@...nel.org, sdf@...ichev.me, haoluo@...gle.com,
	jolsa@...nel.org, shuah@...nel.org, mhal@...x.co,
	sgarzare@...hat.com, netdev@...r.kernel.org, bpf@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH bpf-next v3 1/3] bpf, sockmap: avoid using sk_socket
 after free when sending

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.

> skb_send_sock(), there is a race condition with the release of sk_socket.
> All types of sockets(tcp/udp/unix/vsock) will be affected.
> 
> Race conditions:
> '''
> CPU0                               CPU1
> skb_send_sock
>   sendmsg_unlocked
>     sock_sendmsg
>       sock_sendmsg_nosec
>                                    close(fd):
>                                      ...
>                                    ops->release()

IIRC, ->release() is only called when the refcnt of fd becomes zero, so
I wonder how we reach here despite we have a reference of psock->refcnt?

>                                      sock_map_close()
>                                    sk_socket->ops = NULL
>                                    free(socket)
>       sock->ops->sendmsg
>             ^
>             panic here

Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ