Commit 2dcb0033 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

net/tls: avoid NULL pointer deref on nskb->sk in fallback

update_chksum() accesses nskb->sk before it has been set
by complete_skb(), move the init up.

Fixes: e8f69799 ("net/tls: Add generic NIC offload infrastructure")
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 15d55bae
...@@ -201,13 +201,14 @@ static void complete_skb(struct sk_buff *nskb, struct sk_buff *skb, int headln) ...@@ -201,13 +201,14 @@ static void complete_skb(struct sk_buff *nskb, struct sk_buff *skb, int headln)
skb_put(nskb, skb->len); skb_put(nskb, skb->len);
memcpy(nskb->data, skb->data, headln); memcpy(nskb->data, skb->data, headln);
update_chksum(nskb, headln);
nskb->destructor = skb->destructor; nskb->destructor = skb->destructor;
nskb->sk = sk; nskb->sk = sk;
skb->destructor = NULL; skb->destructor = NULL;
skb->sk = NULL; skb->sk = NULL;
update_chksum(nskb, headln);
delta = nskb->truesize - skb->truesize; delta = nskb->truesize - skb->truesize;
if (likely(delta < 0)) if (likely(delta < 0))
WARN_ON_ONCE(refcount_sub_and_test(-delta, &sk->sk_wmem_alloc)); WARN_ON_ONCE(refcount_sub_and_test(-delta, &sk->sk_wmem_alloc));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment