提交 9edb74cc 编写于 作者: D David S. Miller

tun: Multicast handling in tun_chr_ioctl() needs proper locking.

Since these operations don't go through the normal
device calls, we have to ensure we synchronize with
those paths.

Noticed by Alan Cox.
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 5e659e4c
......@@ -741,7 +741,12 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
case SIOCADDMULTI:
/** Add the specified group to the character device's multicast filter
* list. */
rtnl_lock();
netif_tx_lock_bh(tun->dev);
add_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data);
netif_tx_unlock_bh(tun->dev);
rtnl_unlock();
DBG(KERN_DEBUG "%s: add multi: %s\n",
tun->dev->name, print_mac(mac, ifr.ifr_hwaddr.sa_data));
return 0;
......@@ -749,7 +754,12 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
case SIOCDELMULTI:
/** Remove the specified group from the character device's multicast
* filter list. */
rtnl_lock();
netif_tx_lock_bh(tun->dev);
del_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data);
netif_tx_unlock_bh(tun->dev);
rtnl_unlock();
DBG(KERN_DEBUG "%s: del multi: %s\n",
tun->dev->name, print_mac(mac, ifr.ifr_hwaddr.sa_data));
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册