* Re: [PATCH net] net: fix use-after-free in the netdev_nl_sock_priv_destroy()
2025-03-28 6:22 [PATCH net] net: fix use-after-free in the netdev_nl_sock_priv_destroy() Taehee Yoo
@ 2025-03-28 11:51 ` Jakub Kicinski
2025-03-28 17:04 ` Mina Almasry
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jakub Kicinski @ 2025-03-28 11:51 UTC (permalink / raw)
To: Taehee Yoo
Cc: davem, pabeni, edumazet, andrew+netdev, horms, netdev, jdamato,
sdf, almasrymina, xuanzhuo
On Fri, 28 Mar 2025 06:22:37 +0000 Taehee Yoo wrote:
> In the netdev_nl_sock_priv_destroy(), an instance lock is acquired
> before calling net_devmem_unbind_dmabuf(), then releasing an instance
> lock(netdev_unlock(binding->dev)).
> However, a binding is freed in the net_devmem_unbind_dmabuf().
> So using a binding after net_devmem_unbind_dmabuf() occurs UAF.
> To fix this UAF, it needs to use temporary variable.
>
> Fixes: ba6f418fbf64 ("net: bubble up taking netdev instance lock to callers of net_devmem_unbind_dmabuf()")
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH net] net: fix use-after-free in the netdev_nl_sock_priv_destroy()
2025-03-28 6:22 [PATCH net] net: fix use-after-free in the netdev_nl_sock_priv_destroy() Taehee Yoo
2025-03-28 11:51 ` Jakub Kicinski
@ 2025-03-28 17:04 ` Mina Almasry
2025-03-31 1:53 ` Xuan Zhuo
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Mina Almasry @ 2025-03-28 17:04 UTC (permalink / raw)
To: Taehee Yoo
Cc: davem, kuba, pabeni, edumazet, andrew+netdev, horms, netdev,
jdamato, sdf, xuanzhuo
On Thu, Mar 27, 2025 at 11:22 PM Taehee Yoo <ap420073@gmail.com> wrote:
>
> In the netdev_nl_sock_priv_destroy(), an instance lock is acquired
> before calling net_devmem_unbind_dmabuf(), then releasing an instance
> lock(netdev_unlock(binding->dev)).
> However, a binding is freed in the net_devmem_unbind_dmabuf().
> So using a binding after net_devmem_unbind_dmabuf() occurs UAF.
> To fix this UAF, it needs to use temporary variable.
>
> Fixes: ba6f418fbf64 ("net: bubble up taking netdev instance lock to callers of net_devmem_unbind_dmabuf()")
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Reviewed-by: Mina Almasry <almasrymina@google.com>
--
Thanks,
Mina
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH net] net: fix use-after-free in the netdev_nl_sock_priv_destroy()
2025-03-28 6:22 [PATCH net] net: fix use-after-free in the netdev_nl_sock_priv_destroy() Taehee Yoo
2025-03-28 11:51 ` Jakub Kicinski
2025-03-28 17:04 ` Mina Almasry
@ 2025-03-31 1:53 ` Xuan Zhuo
2025-03-31 12:44 ` Simon Horman
2025-04-01 0:10 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: Xuan Zhuo @ 2025-03-31 1:53 UTC (permalink / raw)
To: Taehee Yoo
Cc: jdamato, sdf, almasrymina, ap420073, davem, kuba, pabeni,
edumazet, andrew+netdev, horms, netdev
On Fri, 28 Mar 2025 06:22:37 +0000, Taehee Yoo <ap420073@gmail.com> wrote:
> In the netdev_nl_sock_priv_destroy(), an instance lock is acquired
> before calling net_devmem_unbind_dmabuf(), then releasing an instance
> lock(netdev_unlock(binding->dev)).
> However, a binding is freed in the net_devmem_unbind_dmabuf().
> So using a binding after net_devmem_unbind_dmabuf() occurs UAF.
> To fix this UAF, it needs to use temporary variable.
>
> Fixes: ba6f418fbf64 ("net: bubble up taking netdev instance lock to callers of net_devmem_unbind_dmabuf()")
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> ---
> net/core/netdev-genl.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
> index fd1cfa9707dc..3afeaa8c5dc5 100644
> --- a/net/core/netdev-genl.c
> +++ b/net/core/netdev-genl.c
> @@ -951,12 +951,14 @@ void netdev_nl_sock_priv_destroy(struct netdev_nl_sock *priv)
> {
> struct net_devmem_dmabuf_binding *binding;
> struct net_devmem_dmabuf_binding *temp;
> + struct net_device *dev;
>
> mutex_lock(&priv->lock);
> list_for_each_entry_safe(binding, temp, &priv->bindings, list) {
> - netdev_lock(binding->dev);
> + dev = binding->dev;
> + netdev_lock(dev);
> net_devmem_unbind_dmabuf(binding);
> - netdev_unlock(binding->dev);
> + netdev_unlock(dev);
> }
> mutex_unlock(&priv->lock);
> }
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH net] net: fix use-after-free in the netdev_nl_sock_priv_destroy()
2025-03-28 6:22 [PATCH net] net: fix use-after-free in the netdev_nl_sock_priv_destroy() Taehee Yoo
` (2 preceding siblings ...)
2025-03-31 1:53 ` Xuan Zhuo
@ 2025-03-31 12:44 ` Simon Horman
2025-04-01 0:10 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2025-03-31 12:44 UTC (permalink / raw)
To: Taehee Yoo
Cc: davem, kuba, pabeni, edumazet, andrew+netdev, netdev, jdamato,
sdf, almasrymina, xuanzhuo
On Fri, Mar 28, 2025 at 06:22:37AM +0000, Taehee Yoo wrote:
> In the netdev_nl_sock_priv_destroy(), an instance lock is acquired
> before calling net_devmem_unbind_dmabuf(), then releasing an instance
> lock(netdev_unlock(binding->dev)).
> However, a binding is freed in the net_devmem_unbind_dmabuf().
> So using a binding after net_devmem_unbind_dmabuf() occurs UAF.
> To fix this UAF, it needs to use temporary variable.
>
> Fixes: ba6f418fbf64 ("net: bubble up taking netdev instance lock to callers of net_devmem_unbind_dmabuf()")
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH net] net: fix use-after-free in the netdev_nl_sock_priv_destroy()
2025-03-28 6:22 [PATCH net] net: fix use-after-free in the netdev_nl_sock_priv_destroy() Taehee Yoo
` (3 preceding siblings ...)
2025-03-31 12:44 ` Simon Horman
@ 2025-04-01 0:10 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-01 0:10 UTC (permalink / raw)
To: Taehee Yoo
Cc: davem, kuba, pabeni, edumazet, andrew+netdev, horms, netdev,
jdamato, sdf, almasrymina, xuanzhuo
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 28 Mar 2025 06:22:37 +0000 you wrote:
> In the netdev_nl_sock_priv_destroy(), an instance lock is acquired
> before calling net_devmem_unbind_dmabuf(), then releasing an instance
> lock(netdev_unlock(binding->dev)).
> However, a binding is freed in the net_devmem_unbind_dmabuf().
> So using a binding after net_devmem_unbind_dmabuf() occurs UAF.
> To fix this UAF, it needs to use temporary variable.
>
> [...]
Here is the summary with links:
- [net] net: fix use-after-free in the netdev_nl_sock_priv_destroy()
https://git.kernel.org/netdev/net/c/42f342387841
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread