Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp337175yba; Sat, 4 May 2019 03:30:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGuEN6R83ykUqqENvV2Edledc+in7tpVHhQcL+5XyMeaNOiff2WMwTrbM18kBbxt0ba6OH X-Received: by 2002:a63:fd0c:: with SMTP id d12mr17934112pgh.172.1556965848716; Sat, 04 May 2019 03:30:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556965848; cv=none; d=google.com; s=arc-20160816; b=WXrkXApuv54cniSL44Wbwzs1zCGD3w/KaJV08YMPacM9xCDtqfFU8JfzmynxlTtVqc 58+HhJ0CVZxgpan4KNKsGHmR7A7+8BQsHbEtQskmIf12B1qFAz/EHTylZEHuPrQ8O+OP fizdY1yCYQ1R/JPAtLq5yi6c5uhVNl2EdiuajyCe/N3zx4U6if+ETCG1oT+z9UdcdwI/ LYjTQrwLdO5RNC1rI7+i/PWreZDI5btbgKx9SGic6G3FiI69zbV/J2SUB8tRODqMb+BG /QgblTOKBO1+H+TLvFGMvkVMikq+RGroOA+fPEXim0luPMBjQA89ul4L+hwrrFjJMyvh gFgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J63PqkJX0weZObq2HYIZ1qcMvBGOZg1ceS1RdDwYzsU=; b=GAouPXvgbxbI2B29yXgBEcwamWsAU8juFqTcXeQlA3UGLdDF/RHV73ROGp70LyuaQG /ddv+Q0KT/mld5G/IktEZPZDWkwpwMX5koUFcMWuGwXnEn7vHRtTJ0DCX/7095+/uYSt J2KFufo5/CIumZHBkhtjldIFK/MYfg6Qnx4X4IICvOLgB7+kQ1/N01e72rjZ94untOWO 6lKZ1iMCr0cXF+GpIjLveUHTY8YZun/Befp/NPC4KuNxiDiq7e3c9yYsyZsFqxoX3nuH DqHkgfyO2ElKOG2H+4tdMhwKU7ELMU2bXyoGcFcBZ3YgNC2M7aBOLafRUxwxjuCtQyH7 bnWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u0SdDuXs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g16si6441177pgj.18.2019.05.04.03.30.33; Sat, 04 May 2019 03:30:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u0SdDuXs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727519AbfEDK3J (ORCPT + 99 others); Sat, 4 May 2019 06:29:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:36978 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727312AbfEDK1F (ORCPT ); Sat, 4 May 2019 06:27:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0DC7F20859; Sat, 4 May 2019 10:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556965624; bh=mj5bq9ExhWvppyqu2OGwhYDfO1FA/a7oNaWdZHOr7yo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u0SdDuXsq//Ny4RJGUpWG/H4O91Zy6YhJOF4F/xo0QHF55TO+Ivkbs6J3ekSFGXoQ vzqGh43gogPf0QQqL+GR2SnPc94z7AyfjtCPY4cLpb33JrNQAvagX3frNIYYd8pJPf 4yNFDxm6HHgz9vqx8NnZ2aLwJpOIz5zPppnWOH9A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakub Kicinski , Simon Horman , "David S. Miller" Subject: [PATCH 4.19 10/23] net/tls: avoid NULL pointer deref on nskb->sk in fallback Date: Sat, 4 May 2019 12:25:12 +0200 Message-Id: <20190504102451.887482769@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190504102451.512405835@linuxfoundation.org> References: <20190504102451.512405835@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jakub Kicinski [ Upstream commit 2dcb003314032c6efb13a065ffae60d164b2dd35 ] update_chksum() accesses nskb->sk before it has been set by complete_skb(), move the init up. Fixes: e8f69799810c ("net/tls: Add generic NIC offload infrastructure") Signed-off-by: Jakub Kicinski Reviewed-by: Simon Horman Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tls/tls_device_fallback.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/tls/tls_device_fallback.c +++ b/net/tls/tls_device_fallback.c @@ -200,13 +200,14 @@ static void complete_skb(struct sk_buff skb_put(nskb, skb->len); memcpy(nskb->data, skb->data, headln); - update_chksum(nskb, headln); nskb->destructor = skb->destructor; nskb->sk = sk; skb->destructor = NULL; skb->sk = NULL; + update_chksum(nskb, headln); + delta = nskb->truesize - skb->truesize; if (likely(delta < 0)) WARN_ON_ONCE(refcount_sub_and_test(-delta, &sk->sk_wmem_alloc));