Skip to contentSkip to conversation

sock: fix possible NULL sk dereference in __skb_tstamp_tx

PATCH Applied Willem de Bruijn 2 participants 2 messages Mar 11, 2015 – Mar 12, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sock: fix possible NULL sk dereference in __skb_tstamp_tx

From: Willem de Bruijn <[email protected]>

Test that sk != NULL before reading sk->sk_tsflags.

Fixes 49ca0d8bfaf3 ("net-timestamp: no-payload option")
---
 net/core/skbuff.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
net/core/skbuff.c +6 -2
index 47c3241..5bffca7 100644
@@ -3689,9 +3689,13 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb,
 		     struct sock *sk, int tstype)
 {
 	struct sk_buff *skb;
-	bool tsonly = sk->sk_tsflags & SOF_TIMESTAMPING_OPT_TSONLY;
+	bool tsonly;
 
-	if (!sk || !skb_may_tx_timestamp(sk, tsonly))
+	if (!sk)
+		return;
+
+	tsonly = sk->sk_tsflags & SOF_TIMESTAMPING_OPT_TSONLY;
+	if (!skb_may_tx_timestamp(sk, tsonly))
 		return;
 
 	if (tsonly)
Signature · 1 line
2.2.0.rc0.207.ga3a616c