Skip to content

Commit 42f3423

Browse files
TaeheeYookuba-moo
authored andcommitted
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. Fixes: ba6f418 ("net: bubble up taking netdev instance lock to callers of net_devmem_unbind_dmabuf()") Signed-off-by: Taehee Yoo <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Reviewed-by: Mina Almasry <[email protected]> Reviewed-by: Xuan Zhuo <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5c60528 commit 42f3423

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/core/netdev-genl.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,12 +951,14 @@ void netdev_nl_sock_priv_destroy(struct netdev_nl_sock *priv)
951951
{
952952
struct net_devmem_dmabuf_binding *binding;
953953
struct net_devmem_dmabuf_binding *temp;
954+
struct net_device *dev;
954955

955956
mutex_lock(&priv->lock);
956957
list_for_each_entry_safe(binding, temp, &priv->bindings, list) {
957-
netdev_lock(binding->dev);
958+
dev = binding->dev;
959+
netdev_lock(dev);
958960
net_devmem_unbind_dmabuf(binding);
959-
netdev_unlock(binding->dev);
961+
netdev_unlock(dev);
960962
}
961963
mutex_unlock(&priv->lock);
962964
}

0 commit comments

Comments
 (0)