Skip to content

Commit

Permalink
tun: Multicast handling in tun_chr_ioctl() needs proper locking.
Browse files Browse the repository at this point in the history
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: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Apr 24, 2008
1 parent 5e659e4 commit 9edb74c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,15 +741,25 @@ 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;

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;
Expand Down

0 comments on commit 9edb74c

Please sign in to comment.