]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
tcp: fix SCM_TIMESTAMPING_OPT_STATS for normal skbs
authorSoheil Hassas Yeganeh <soheil@google.com>
Sat, 18 Mar 2017 21:02:59 +0000 (17:02 -0400)
committerDavid S. Miller <davem@davemloft.net>
Wed, 22 Mar 2017 01:44:17 +0000 (18:44 -0700)
commit8605330aac5a5785630aec8f64378a54891937cc
treee8f9013a8686b4027210b60d747c55d4229c4e5a
parent23bb09cfbe04076ef647da3889a5a5ab6cbe6f15
tcp: fix SCM_TIMESTAMPING_OPT_STATS for normal skbs

__sock_recv_timestamp can be called for both normal skbs (for
receive timestamps) and for skbs on the error queue (for transmit
timestamps).

Commit 1c885808e456
(tcp: SOF_TIMESTAMPING_OPT_STATS option for SO_TIMESTAMPING)
assumes any skb passed to __sock_recv_timestamp are from
the error queue, containing OPT_STATS in the content of the skb.
This results in accessing invalid memory or generating junk
data.

To fix this, set skb->pkt_type to PACKET_OUTGOING for packets
on the error queue. This is safe because on the receive path
on local sockets skb->pkt_type is never set to PACKET_OUTGOING.
With that, copy OPT_STATS from a packet, only if its pkt_type
is PACKET_OUTGOING.

Fixes: 1c885808e456 ("tcp: SOF_TIMESTAMPING_OPT_STATS option for SO_TIMESTAMPING")
Reported-by: JongHwan Kim <zzoru007@gmail.com>
Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/skbuff.c
net/socket.c