Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1217673pxx; Tue, 27 Oct 2020 10:59:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcAgXzNQ7jeGEx47fSHgLIbXQ7dKa6CRILCR1v7pdSyRsq+JRS+t8ITjz8XXab/jSqc15B X-Received: by 2002:a17:906:742:: with SMTP id z2mr3482596ejb.57.1603821569967; Tue, 27 Oct 2020 10:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603821569; cv=none; d=google.com; s=arc-20160816; b=RIQnJEdskcBvR5NPFKVng6jsoo39Qxre2CVDd1JHQMka0WfQrGz6b0VQj4qJzM5PVL EUESI9lCDog+2sOwfOvQnDerH4VLUUhL9SdmGXMtfCre1FKwA3GtNI1fD20vOR94VyGP fMS2JwOSskRS9wn+2brc3vfUZ1InUFK5qKaoDr7/Q43jCDtKZ9CVkQ++GsIKs6Vu/g8p TBkpLCswIEUCM11d/+Vcj3TuEIvqinu8YZIALHycD2INsouMLMm7lpLhuw/HxUcUERLz h8Uw1YwSALSfkTdL7PjnLrqI0xuIwJgwddlnbDFuEIHTquUfzaID7/3RuTgHRjL6eOVc rPOQ== 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=49RwVBLACnZ0m7rn5Psaezp42nLODa36qeh7gz2BilA=; b=N1z69htWeC42PQwjJLoYV49S9vhvfeL5UzoTm1w9fQ8k4c7uVfS2TNADmoDe/12vP8 kz4/1bBoP66K4UxzLJ8OaRDzw4fQUP/zSWNqE4xPkX+MVs8lJfoBqPC7OTUdBcWE7ry9 Gz315CzRHrDbYtFC5skc+ll/fUFCZcl6tcpV8h/EEuiCBeTRooaToC+Ehd/4Plax2BPf zhkUy6PCDyYZEGgFVJdrV/HMCv9SVE6ayCfDMxleF6BKcJgjKwkBYt3A9yMsrfRGbdRX e3wZVPq+U1Cko68QKFt79UuaM5xxY5dk3mysUcAYvubcWYAZchNw9imYinVTwmaVS5aV asEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Cvg6JHtB; 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 lr20si1468834ejb.439.2020.10.27.10.59.08; Tue, 27 Oct 2020 10:59:29 -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=Cvg6JHtB; 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 S1762721AbgJ0Ow2 (ORCPT + 99 others); Tue, 27 Oct 2020 10:52:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:49678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1767017AbgJ0Ote (ORCPT ); Tue, 27 Oct 2020 10:49:34 -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 C9C3720709; Tue, 27 Oct 2020 14:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810173; bh=5a+DCJKtBG8G1Ol7P11ykdRfcDzfQXtZ8zNxZhg3XCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cvg6JHtBky1SkZDu+7c+mEox5Wii17z5EEAVpoKgIzhmlMPKVL06rvRuwYA9Fh2OT 3mdAoOILL1kTsd9Dxx4eM4CN4L+uEY+MnCRawoIN8Ye4RkTRjybIdG6FyJEARq7k8a lTjt4uqPQ93Ebf0u3Aru99mwivlDzII3lFAfHVFs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rohit Maheshwari , Jakub Kicinski Subject: [PATCH 5.8 015/633] net/tls: sendfile fails with ktls offload Date: Tue, 27 Oct 2020 14:45:58 +0100 Message-Id: <20201027135523.406194216@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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: Rohit Maheshwari [ Upstream commit ea1dd3e9d080c961b9a451130b61c72dc9a5397b ] At first when sendpage gets called, if there is more data, 'more' in tls_push_data() gets set which later sets pending_open_record_frags, but when there is no more data in file left, and last time tls_push_data() gets called, pending_open_record_frags doesn't get reset. And later when 2 bytes of encrypted alert comes as sendmsg, it first checks for pending_open_record_frags, and since this is set, it creates a record with 0 data bytes to encrypt, meaning record length is prepend_size + tag_size only, which causes problem. We should set/reset pending_open_record_frags based on more bit. Fixes: e8f69799810c ("net/tls: Add generic NIC offload infrastructure") Signed-off-by: Rohit Maheshwari Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/tls/tls_device.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -418,14 +418,14 @@ static int tls_push_data(struct sock *sk struct tls_context *tls_ctx = tls_get_ctx(sk); struct tls_prot_info *prot = &tls_ctx->prot_info; struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx); - int more = flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE); struct tls_record_info *record = ctx->open_record; int tls_push_record_flags; struct page_frag *pfrag; size_t orig_size = size; u32 max_open_record_len; - int copy, rc = 0; + bool more = false; bool done = false; + int copy, rc = 0; long timeo; if (flags & @@ -492,9 +492,8 @@ handle_error: if (!size) { last_record: tls_push_record_flags = flags; - if (more) { - tls_ctx->pending_open_record_frags = - !!record->num_frags; + if (flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE)) { + more = true; break; } @@ -526,6 +525,8 @@ last_record: } } while (!done); + tls_ctx->pending_open_record_frags = more; + if (orig_size - size > 0) rc = orig_size - size;