]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
packet: avoid out of bounds read in round robin fanout
authorWillem de Bruijn <willemb@google.com>
Wed, 17 Jun 2015 19:59:34 +0000 (15:59 -0400)
committerSasha Levin <sasha.levin@oracle.com>
Sun, 5 Jul 2015 14:12:58 +0000 (10:12 -0400)
commit154dcd0b49c499f2c5846e6d85a48735a67b0929
tree5990f6b6f995806def4204a432b0f22d5b89ac35
parent5c0e1a6b445f6709873959d69b367bc7f0c4ff06
packet: avoid out of bounds read in round robin fanout

[ Upstream commit 468479e6043c84f5a65299cc07cb08a22a28c2b1 ]

PACKET_FANOUT_LB computes f->rr_cur such that it is modulo
f->num_members. It returns the old value unconditionally, but
f->num_members may have changed since the last store. Ensure
that the return value is always < num.

When modifying the logic, simplify it further by replacing the loop
with an unconditional atomic increment.

Fixes: dc99f600698d ("packet: Add fanout support.")
Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
net/packet/af_packet.c