]> git.baikalelectronics.ru Git - kernel.git/commit
packet: fix send path when running with proto == 0
authorDaniel Borkmann <dborkman@redhat.com>
Fri, 6 Dec 2013 10:36:15 +0000 (11:36 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 10 Dec 2013 01:09:20 +0000 (20:09 -0500)
commit803148cbfb83b363527b72cd2f1ff06e5cf2e823
treed10e5ec58ce412c66700626e39fc363d87c71165
parentfbdd3a0b78c68961323034395f58931808bb7116
packet: fix send path when running with proto == 0

Commit 998e7f9a9095 introduced a cached dev pointer, that gets
hooked into register_prot_hook(), __unregister_prot_hook() to
update the device used for the send path.

We need to fix this up, as otherwise this will not work with
sockets created with protocol = 0, plus with sll_protocol = 0
passed via sockaddr_ll when doing the bind.

So instead, assign the pointer directly. The compiler can inline
these helper functions automagically.

While at it, also assume the cached dev fast-path as likely(),
and document this variant of socket creation as it seems it is
not widely used (seems not even the author of TX_RING was aware
of that in his reference example [1]). Tested with reproducer
from 998e7f9a9095.

 [1] http://wiki.ipxwarzone.com/index.php5?title=Linux_packet_mmap#Example

Fixes: 998e7f9a9095 ("packet: fix use after free race in send path when dev is released")
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Tested-by: Salam Noureddine <noureddine@aristanetworks.com>
Tested-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Documentation/networking/packet_mmap.txt
net/packet/af_packet.c