packet: fix tp_reserve race in packet_set_ring 22/155222/1
authorWillem de Bruijn <willemb@google.com>
Thu, 10 Aug 2017 16:41:58 +0000 (12:41 -0400)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Thu, 12 Oct 2017 10:00:11 +0000 (19:00 +0900)
commit79199edf5bac260c0e9162b58cdbdd340b68d0e2
tree2e310868ae1f74545dfe7d9732fb538c57b910e4
parent50ee5a12b68634121336023f23460446d7ac8f8a
packet: fix tp_reserve race in packet_set_ring

commit c27927e372f0785f3303e8fad94b85945e2c97b7 upstream.

Updates to tp_reserve can race with reads of the field in
packet_set_ring. Avoid this by holding the socket lock during
updates in setsockopt PACKET_RESERVE.

This bug was discovered by syzkaller.

Fixes: 8913336a7e8d ("packet: add PACKET_RESERVE sockopt")
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
[sw0312.kim: cherry-pick from linux-3.16.y to fix CVE-2017-1000111]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: Iac30a02e007bdcb8a431059e1ab358136cd92389
net/packet/af_packet.c