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: e8f6979981 ("net/tls: Add generic NIC offload infrastructure")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jakub Kicinski 2019-04-29 12:19:12 -07:00 коммит произвёл David S. Miller
Родитель 15d55bae4e
Коммит 2dcb003314
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -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));