net: fix use-after-free in the netdev_nl_sock_priv_destroy()
Subsystems (2)
PATCH 1/1 net: fix use-after-free in the netdev_nl_sock_priv_destroy()
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.
--- net/core/netdev-genl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/core/netdev-genl.c +4 -2
@@ -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); }
Signature · 1 line
2.34.1
Quoted 9 lines · 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 callingnet_devmem_unbind_dmabuf(), then releasing an instance lock(netdev_unlock(binding->dev)).
However, a binding is freed in thenet_devmem_unbind_dmabuf(). So using a binding afternet_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 <[email protected]>
Thanks!
Quoted 10 lines · Taehee Yoo
In the
netdev_nl_sock_priv_destroy(), an instance lock is acquired before callingnet_devmem_unbind_dmabuf(), then releasing an instance lock(netdev_unlock(binding->dev)).
However, a binding is freed in thenet_devmem_unbind_dmabuf(). So using a binding afternet_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 <[email protected]>
Signature · 2 lines
Thanks, Mina
Quoted 9 lines · Taehee Yoo
In the
netdev_nl_sock_priv_destroy(), an instance lock is acquired before callingnet_devmem_unbind_dmabuf(), then releasing an instance lock(netdev_unlock(binding->dev)).
However, a binding is freed in thenet_devmem_unbind_dmabuf(). So using a binding afternet_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 <[email protected]>
Quoted 28 lines
--- net/core/netdev-genl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)net/core/netdev-genl.c +4
-3@@ -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
Quoted 9 lines · Taehee Yoo
In the
netdev_nl_sock_priv_destroy(), an instance lock is acquired before callingnet_devmem_unbind_dmabuf(), then releasing an instance lock(netdev_unlock(binding->dev)).
However, a binding is freed in thenet_devmem_unbind_dmabuf(). So using a binding afternet_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 <[email protected]>
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Fri, 28 Mar 2025 06:22:37 +0000 you wrote:
In the
netdev_nl_sock_priv_destroy(), an instance lock is acquired before callingnet_devmem_unbind_dmabuf(), then releasing an instance lock(netdev_unlock(binding->dev)).
However, a binding is freed in thenet_devmem_unbind_dmabuf(). So using a binding afternet_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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html