Commit 5be6824
packet: hold bind lock when rebinding to fanout hook
[ Upstream commit 008ba2a13f2d04c947adc536d19debb8fe66f110 ]
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: dc99f60 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent aa90be3 commit 5be6824
1 file changed
Lines changed: 11 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1652 | 1652 | | |
1653 | 1653 | | |
1654 | 1654 | | |
1655 | | - | |
1656 | | - | |
1657 | | - | |
1658 | | - | |
1659 | 1655 | | |
1660 | 1656 | | |
1661 | 1657 | | |
| |||
1704 | 1700 | | |
1705 | 1701 | | |
1706 | 1702 | | |
1707 | | - | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
1708 | 1707 | | |
1709 | 1708 | | |
1710 | 1709 | | |
| |||
1716 | 1715 | | |
1717 | 1716 | | |
1718 | 1717 | | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
1719 | 1725 | | |
1720 | 1726 | | |
1721 | 1727 | | |
| |||
0 commit comments