Skip to content

Commit

Permalink
sock: fix possible NULL sk dereference in __skb_tstamp_tx
Browse files Browse the repository at this point in the history
Test that sk != NULL before reading sk->sk_tsflags.

Fixes: 49ca0d8 ("net-timestamp: no-payload option")
Reported-by: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
wdebruij authored and davem330 committed Mar 12, 2015
1 parent c29390c commit 3a8dd97
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -3733,9 +3733,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)
Expand Down

0 comments on commit 3a8dd97

Please sign in to comment.