Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9edb74cc authored by David S. Miller's avatar David S. Miller
Browse files

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: default avatarDavid S. Miller <davem@davemloft.net>
parent 5e659e4c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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;