Skip to content

Commit

Permalink
packet: free packet_rollover after synchronize_net
Browse files Browse the repository at this point in the history
Destruction of the po->rollover must be delayed until there are no
more packets in flight that can access it. The field is destroyed in
packet_release, before synchronize_net. Delay using rcu.

Fixes: 0648ab7 ("packet: rollover prepare: per-socket state")

Suggested-by: Eric Dumazet <[email protected]>
Signed-off-by: Willem de Bruijn <[email protected]>
Acked-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
wdebruij authored and davem330 committed Jun 21, 2015
1 parent 1201196 commit 59f2111
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,8 @@ static void fanout_release(struct sock *sk)
}
mutex_unlock(&fanout_mutex);

kfree(po->rollover);
if (po->rollover)
kfree_rcu(po->rollover, rcu);
}

static const struct proto_ops packet_ops;
Expand Down
1 change: 1 addition & 0 deletions net/packet/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ struct packet_fanout {

struct packet_rollover {
int sock;
struct rcu_head rcu;
atomic_long_t num;
atomic_long_t num_huge;
atomic_long_t num_failed;
Expand Down

0 comments on commit 59f2111

Please sign in to comment.