]> www.infradead.org Git - users/jedix/linux-maple.git/commit
packet: hold bind lock when rebinding to fanout hook
authorWillem de Bruijn <willemb@google.com>
Thu, 14 Sep 2017 21:14:41 +0000 (17:14 -0400)
committerKirtikar Kashyap <kirtikar.kashyap@oracle.com>
Thu, 16 Nov 2017 21:04:53 +0000 (13:04 -0800)
commitb4920736961e461dd026949957fd057241a06d70
tree873c63fa34318a460434115c24093dbddba0e8a3
parent0a296cd0b186401d20de2ffbbc2c5c20f95ae645
packet: hold bind lock when rebinding to fanout hook

Packet socket bind operations must hold the po->bind_lock. This keeps
po->running consistent with whether the socket is actually on a ptype
list to receive packets.

fanout_add unbinds a socket and its packet_rcv/tpacket_rcv call, then
binds the fanout object to receive through packet_rcv_fanout.

Make it hold the po->bind_lock when testing po->running and rebinding.
Else, it can race with other rebind operations, such as that in
packet_set_ring from packet_rcv to tpacket_rcv. Concurrent updates
can result in a socket being added to a fanout group twice, causing
use-after-free KASAN bug reports, among others.

Reported independently by both trinity and syzkaller.
Verified that the syzkaller reproducer passes after this patch.

Fixes: dc99f600698d ("packet: Add fanout support.")
Reported-by: nixioaming <nixiaoming@huawei.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 008ba2a13f2d04c947adc536d19debb8fe66f110)

Orabug: 27050772
CVE: CVE-2017-15649

Signed-off-by: Kirtikar Kashyap <kirtikar.kashyap@oracle.com>
Reviewed-by: Jack Vogel <jack.vogel@oracle.com>
net/packet/af_packet.c