]> www.infradead.org Git - users/jedix/linux-maple.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Sep 2015 17:26:22 +0000 (19:26 +0200)
commitf21407a98826002e0274c09f1d77ab0f69b80a3d
tree3b3d809c15f9fbfd9906924b5ada363403f52bef
parent316590d25ea05263eb4869fa668bf8a78fa04c1c
net: Clone skb before setting peeked flag

[ Upstream commit 738ac1ebb96d02e0d23bc320302a6ea94c612dec ]

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: a59322be07c9 ("[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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/core/datagram.c