]> git.baikalelectronics.ru Git - kernel.git/commit
net: Clone skb before setting peeked flag
authorHerbert Xu <herbert@gondor.apana.org.au>
Mon, 13 Jul 2015 08:04:13 +0000 (16:04 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Jul 2015 22:59:58 +0000 (15:59 -0700)
commitc7ba2dc443e4f48c0922014b2cd5a01575fd6dba
treeb2c9c3f8bdf874f4500c1419bfc0eba31b21efb8
parent623dd6842630d4c96dd5c393cd5484e4906647be
net: Clone skb before setting peeked flag

Shared skbs must not be modified and this is crucial for broadcast
and/or multicast paths where we use it as an optimisation to avoid
unnecessary cloning.

The function skb_recv_datagram breaks this rule by setting peeked
without cloning the skb first.  This causes funky races which leads
to double-free.

This patch fixes this by cloning the skb and replacing the skb
in the list when setting skb->peeked.

Fixes: 09a18c0f66d1 ("[UDP]: Only increment counter on first peek/recv")
Reported-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/datagram.c