tuntap: fix a possible race between queue selection and changing queues
Subsystems (3)
PATCH 1/1 tuntap: fix a possible race between queue selection and changing queues
Complier may generate codes that re-read the tun->numqueues during tun_select_queue(). This may be a race if vlan->numqueues were changed in the same time and can lead unexpected result (e.g. very huge value).
We need prevent the compiler from generating such codes by adding an ACCESS_ONCE() to make sure tun->numqueues were only read once.
Bug were introduced by commit c8d68e6be1c3b242f1c598595830890b65cea64a (tuntap: multiqueue support).
--- drivers/net/tun.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/tun.c +1 -1
@@ -352,7 +352,7 @@ static u16 tun_select_queue(struct net_device *dev, struct sk_buff *skb)u32 numqueues =0 ;rcu_read_lock (); - numqueues = tun->numqueues; + numqueues =ACCESS_ONCE (tun->numqueues); txq =skb_get_rxhash (skb);if (txq) {
Signature · 1 line
1.7.1
Quoted 7 lines · Jason Wang
Complier may generate codes that re-read the
tun->numqueuesduringtun_select_queue(). This may be a race ifvlan->numqueueswere changed in the same time and can lead unexpected result (e.g. very huge value).We need prevent the compiler from generating such codes by adding an
ACCESS_ONCE()to make suretun->numqueueswere only read once.
Quoted 6 lines
Bug were introduced by commit
c8d68e6be1c3b242f1c598595830890b65cea64a(tuntap: multiqueue support).Reported-by Michael S. Tsirkin <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Jason Wang <[email protected]>
This is a theoretical problem, right?
So no need for stable.
Quoted 19 lines
--- drivers/net/tun.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/net/tun.c +1
-1@@ -352,7 +352,7 @@ static u16 tun_select_queue(struct net_device *dev, struct sk_buff *skb)u32 numqueues =0 ;rcu_read_lock (); - numqueues = tun->numqueues; + numqueues =ACCESS_ONCE (tun->numqueues); txq =skb_get_rxhash (skb);if (txq) {Signature · 1 line
1.7.1
From: "Michael S. Tsirkin" <[email protected]>
Date: Wed, 5 Jun 2013 13:33:32 +0300
Quoted 11 lines · Jason Wang
Quoted 10 lines
Complier may generate codes that re-read the
tun->numqueuesduringtun_select_queue(). This may be a race ifvlan->numqueueswere changed in the same time and can lead unexpected result (e.g. very huge value).We need prevent the compiler from generating such codes by adding an
ACCESS_ONCE()to make suretun->numqueueswere only read once.Bug were introduced by commit
c8d68e6be1c3b242f1c598595830890b65cea64a(tuntap: multiqueue support).
Quoted 8 lines
Quoted 3 lines
Reported-by Michael S. Tsirkin <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Jason Wang <[email protected]>This is a theoretical problem, right?
So no need for stable.
Applied, thanks.