Message ID | 20230809142843.13944-1-magnus.karlsson@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 85c2c79a07302fe68a1ad5cc449458cc559e314d |
Delegated to: | BPF |
Headers | show |
Series | [bpf] xsk: fix refcount underflow in error path | expand |
Hello: This patch was applied to bpf/bpf.git (master) by Martin KaFai Lau <martin.lau@kernel.org>: On Wed, 9 Aug 2023 16:28:43 +0200 you wrote: > From: Magnus Karlsson <magnus.karlsson@intel.com> > > Fix a refcount underflow problem reported by syzbot that can happen > when a system is running out of memory. If xp_alloc_tx_descs() fails, > and it can only fail due to not having enough memory, then the error > path is triggered. In this error path, the refcount of the pool is > decremented as it has incremented before. However, the reference to > the pool in the socket was not nulled. This means that when the socket > is closed later, the socket teardown logic will think that there is a > pool attached to the socket and try to decrease the refcount again, > leading to a refcount underflow. > > [...] Here is the summary with links: - [bpf] xsk: fix refcount underflow in error path https://git.kernel.org/bpf/bpf/c/85c2c79a0730 You are awesome, thank you!
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index b89adb52a977..10ea85c03147 100644 --- a/net/xdp/xsk.c +++ b/net/xdp/xsk.c @@ -994,6 +994,7 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len) err = xp_alloc_tx_descs(xs->pool, xs); if (err) { xp_put_pool(xs->pool); + xs->pool = NULL; sockfd_put(sock); goto out_unlock; }