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

Commit 8e6d91ae authored by Jason Wang's avatar Jason Wang Committed by David S. Miller
Browse files

tuntap: forbid changing mq flag for persistent device



We currently allow changing the mq flag (IFF_MULTI_QUEUE) for a persistent
device. This will result a mismatch between the number the queues in netdev and
tuntap. This is because we only allocate a 1q netdevice when IFF_MULTI_QUEUE was
not specified, so when we set the IFF_MULTI_QUEUE and try to attach more queues
later, netif_set_real_num_tx_queues() may fail which result a single queue
netdevice with multiple sockets attached.

Solve this by disallowing changing the mq flag for persistent device.

Bug was introduced by commit edfb6a14
(tuntap: reduce memory using of queues).

Reported-by: default avatarSriram Narasimhan <sriram.narasimhan@hp.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 456db6a4
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -1585,6 +1585,10 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
		else
		else
			return -EINVAL;
			return -EINVAL;


		if (!!(ifr->ifr_flags & IFF_MULTI_QUEUE) !=
		    !!(tun->flags & TUN_TAP_MQ))
			return -EINVAL;

		if (tun_not_capable(tun))
		if (tun_not_capable(tun))
			return -EPERM;
			return -EPERM;
		err = security_tun_dev_open(tun->security);
		err = security_tun_dev_open(tun->security);