Skip to content

Commit

Permalink
packet: unconditionally free po->rollover
Browse files Browse the repository at this point in the history
Rollover used to use a complex RCU mechanism for assignment, which had
a race condition. The below patch fixed the bug and greatly simplified
the logic.

The feature depends on fanout, but the state is private to the socket.
Fanout_release returns f only when the last member leaves and the
fanout struct is to be freed.

Destroy rollover unconditionally, regardless of fanout state.

Fixes: 57f015f ("packet: fix crash in fanout_demux_rollover()")
Reported-by: syzbot <[email protected]>
Diagnosed-by: Dmitry Vyukov <[email protected]>
Signed-off-by: Willem de Bruijn <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
wdebruij authored and davem330 committed Jun 3, 2019
1 parent 8c26859 commit afa0925
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -3014,8 +3014,8 @@ static int packet_release(struct socket *sock)

synchronize_net();

kfree(po->rollover);
if (f) {
kfree(po->rollover);
fanout_release_data(f);
kfree(f);
}
Expand Down

0 comments on commit afa0925

Please sign in to comment.