packet: avoid panic in packet_getsockopt()
authorEric Dumazet <edumazet@google.com>
Wed, 18 Oct 2017 23:14:52 +0000 (16:14 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 21 Oct 2017 00:51:34 +0000 (01:51 +0100)
commit509c7a1ecc8601f94ffba8a00889fefb239c00c6
treef9dcb3f8a8782f6c6bbc6231e9eea2382146d36b
parentc92e8c02fe664155ac4234516e32544bec0f113d
packet: avoid panic in packet_getsockopt()

syzkaller got crashes in packet_getsockopt() processing
PACKET_ROLLOVER_STATS command while another thread was managing
to change po->rollover

Using RCU will fix this bug. We might later add proper RCU annotations
for sparse sake.

In v2: I replaced kfree(rollover) in fanout_add() to kfree_rcu()
variant, as spotted by John.

Fixes: a9b6391814d5 ("packet: rollover statistics")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Cc: John Sperbeck <jsperbeck@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/packet/af_packet.c