Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1981800pxx; Sat, 31 Oct 2020 04:45:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvrXOuWdj4GduXfAKv+sTLPQEcrjYpZCSmC2eXNLmef10He2MMHIOFsk42mfEIMl5TSm+/ X-Received: by 2002:a17:906:911:: with SMTP id i17mr6720051ejd.40.1604144747563; Sat, 31 Oct 2020 04:45:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604144747; cv=none; d=google.com; s=arc-20160816; b=tt+T8Zv3nCiiqt4bEBHBag2OqwjDg1/arhGaJUQRPbyuEQEfCK8WldZqz617+U1rI2 YAsdlAKF21CJSuk//c4gLrF4WG7Hf9oCkHW4LFglvtbZd1ne0GSZATcCh3z0ydRVP8xx RNwTkZTKYkNF4CQ3dQnlli+qxW3QcxTP1Uw6zrem8RQVtfmyJI7oMxB/BjzSkhPeOYxB fJkKlmZG4PO7ObQcAx1Wfal1lVHjSUgj1PJCunV9pGmD2N1ML5eQxhjIoP7lMZu5/N4G LABv+LEb2Zl2dgYw7Vm4+gwBaBIHfpfnsxIut+9ARXC9Q9NKfW9D2ohGFA+/6OnwVyAv pdSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fNP+djHUytaN8Krov2mdXsd/rZ1iLQIqFUWVd3LTTTI=; b=uyaSfDha79dhEfsTX2KrL1f6L6fXjITywCNIsBzyRK2MLHCOsMFQ4emfAjKo+85Y83 T+oSRpnyTgMadIqUNVtI4eoQ7PwzYfAB59iqsW/RE2B3Ctluyf7OSGADqM017BqCyWm9 ZT531PL7I3QORGi1lVyCrqNUQKSlJin9uKzKw/JTF2Dyz9NgN3ZWZXPPY/4y91qvvvJ+ GXwhRX2XTXX/LXzi6fqallzuRcx9LNAIUj7h4V98P+AufwSfUvM0VHxC7cKPgkV2qO3S BnzAqvzMR1vMsiIQ+d/7uUSmQx3gAVQELTbQn2OzoXq0rW4oo1OwDlWn12FW0cpUIEkT 2amw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zhH6Su+w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gs18si7142738ejb.225.2020.10.31.04.45.24; Sat, 31 Oct 2020 04:45:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zhH6Su+w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727149AbgJaLlX (ORCPT + 99 others); Sat, 31 Oct 2020 07:41:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:40396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727146AbgJaLlT (ORCPT ); Sat, 31 Oct 2020 07:41:19 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 3DB1920731; Sat, 31 Oct 2020 11:41:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604144478; bh=tas5cm9xxl8iJAKYimul3Q9oDvKpwNk4kkBAmDm6xj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zhH6Su+wA6CtoaLNTSs5WeQhbM0nnL79QErwRjiUzhXTQ3trE3pN1asEKUxCKRlnn Xkvkztcc9eBb/FYoB7OYJenyWk68voNisbfFcz1xL5QGvvg7BAdrJPWWTiChKScZvM tCaAoz5+xLXYk/TEe7vdoIvIiZIWwmQN19wWIGk8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vinay Kumar Yadav , Jakub Kicinski Subject: [PATCH 5.8 34/70] chelsio/chtls: fix tls record info to user Date: Sat, 31 Oct 2020 12:36:06 +0100 Message-Id: <20201031113501.132118417@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201031113459.481803250@linuxfoundation.org> References: <20201031113459.481803250@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vinay Kumar Yadav [ Upstream commit 4f3391ce8f5a69e7e6d66d0a3fc654eb6dbdc919 ] chtls_pt_recvmsg() receives a skb with tls header and subsequent skb with data, need to finalize the data copy whenever next skb with tls header is available. but here current tls header is overwritten by next available tls header, ends up corrupting user buffer data. fixing it by finalizing current record whenever next skb contains tls header. v1->v2: - Improved commit message. Fixes: 17a7d24aa89d ("crypto: chtls - generic handling of data and hdr") Signed-off-by: Vinay Kumar Yadav Link: https://lore.kernel.org/r/20201022190556.21308-1-vinay.yadav@chelsio.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/chelsio/chtls/chtls_io.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/crypto/chelsio/chtls/chtls_io.c +++ b/drivers/crypto/chelsio/chtls/chtls_io.c @@ -1585,6 +1585,7 @@ skip_copy: tp->urg_data = 0; if ((avail + offset) >= skb->len) { + struct sk_buff *next_skb; if (ULP_SKB_CB(skb)->flags & ULPCB_FLAG_TLS_HDR) { tp->copied_seq += skb->len; hws->rcvpld = skb->hdr_len; @@ -1595,8 +1596,10 @@ skip_copy: chtls_free_skb(sk, skb); buffers_freed++; hws->copied_seq = 0; - if (copied >= target && - !skb_peek(&sk->sk_receive_queue)) + next_skb = skb_peek(&sk->sk_receive_queue); + if (copied >= target && !next_skb) + break; + if (ULP_SKB_CB(next_skb)->flags & ULPCB_FLAG_TLS_HDR) break; } } while (len > 0);