]> git.baikalelectronics.ru Git - kernel.git/commit
tuntap: fix a possible race between queue selection and changing queues
authorJason Wang <jasowang@redhat.com>
Wed, 5 Jun 2013 08:44:57 +0000 (16:44 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 10 Jun 2013 21:32:47 +0000 (14:32 -0700)
commit8e5b6a045049d2708e21d359f7ac07317a8266d0
tree3b310ab023ab438175bd2aa0ccf71814e3760ae9
parent1562a570b6337020443628e73c8151d3513d1a71
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 ad875707461d9d1409ce0203780868f6dde7245d
(tuntap: multiqueue support).

Reported-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/tun.c