From: Eric Dumazet Date: Fri, 9 Oct 2015 22:42:21 +0000 (-0700) Subject: tun: use sk_fullsock() before reading sk->sk_tsflags X-Git-Tag: firefly_0821_release~176^2~818^2~154 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5fcd2d8be43664f1b6a5add3d21a367411add9d4;p=firefly-linux-kernel-4.4.55.git tun: use sk_fullsock() before reading sk->sk_tsflags timewait or request sockets are small and do not contain sk->sk_tsflags Without this fix, we might read garbage, and crash later in __skb_complete_tx_timestamp() -> sock_queue_err_skb() (These pseudo sockets do not have an error queue either) Fixes: ca6fb0651883 ("tcp: attach SYNACK messages to request sockets instead of listener") Signed-off-by: Eric Dumazet Cc: Willem de Bruijn Acked-by: Michael S. Tsirkin Signed-off-by: David S. Miller --- diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 976aa9704297..b1878faea397 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -858,7 +858,7 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev) if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC))) goto drop; - if (skb->sk) { + if (skb->sk && sk_fullsock(skb->sk)) { sock_tx_timestamp(skb->sk, &skb_shinfo(skb)->tx_flags); sw_tx_timestamp(skb); }