net: test nouarg before dereferencing zerocopy pointers
authorWillem de Bruijn <willemb@google.com>
Wed, 15 May 2019 17:29:16 +0000 (13:29 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 May 2019 16:25:16 +0000 (18:25 +0200)
commit723fdfbab894cae0ac1d231f07bff709fbf598ba
tree9b2bcd53d38aa55dfda8ec46e53bf4f86505ad6a
parent00b0f63783c32820b5f4b1ae0c63c6227e613261
net: test nouarg before dereferencing zerocopy pointers

[ Upstream commit 185ce5c38ea76f29b6bd9c7c8c7a5e5408834920 ]

Zerocopy skbs without completion notification were added for packet
sockets with PACKET_TX_RING user buffers. Those signal completion
through the TP_STATUS_USER bit in the ring. Zerocopy annotation was
added only to avoid premature notification after clone or orphan, by
triggering a copy on these paths for these packets.

The mechanism had to define a special "no-uarg" mode because packet
sockets already use skb_uarg(skb) == skb_shinfo(skb)->destructor_arg
for a different pointer.

Before deferencing skb_uarg(skb), verify that it is a real pointer.

Fixes: 5cd8d46ea1562 ("packet: copy user buffers before orphan or clone")
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/skbuff.h