Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2514349iob; Fri, 6 May 2022 04:45:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7RTFFTUQO+54aEhuEXOmLwNdV98DW2M6gUh6BKxliL8rrYiBK+zKmcMQf+gIhd194/2or X-Received: by 2002:a65:6bc4:0:b0:3c2:2f7c:cc74 with SMTP id e4-20020a656bc4000000b003c22f7ccc74mr2423440pgw.307.1651837553009; Fri, 06 May 2022 04:45:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651837553; cv=none; d=google.com; s=arc-20160816; b=cnJ4K9XSXU57xqr+HKPLSPZ/wsOo1UXaY9GEV2ZKK2072PUM/MMlBeqx9ps+E8Hx+s aDqX63+Wpxi/cBYUlkAaolrfESf2q7BqjywD9rrONvJnoCJd7n+9Pe45YRFbKy6oHRWs JaEFG8VagWztTR/cslfhlNS0GQ5/sf2ET+8vBBGKWjuJUhUs1AA/Qtpql2YksSQXbZ9V EoEXLZPX5IExUJZpQ9LfUyg8yyfik/LJ32bwyY3BHpHuSUjsZx/AJI2r3qTC9TR2AiYy fMCeN9sUd6UfGSR7SLhCY9uLT1VvOGBuw/irXoSjGHyXGIaZGXhWbpOsPt1nYOknYmSW bTDQ== 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=bziilUzzcC1Dq2/YSGGeZU0bE1DCguhGLgPC0LmAYEc=; b=DKI8tELqCm9jNOdWYRhe8LihTyRoVaJ+vZOtTTfQJxxl5t+q423cDYTOFUu+kjFSeY Uu72sOFSQ7rPzkXdtw/rpCJz03ciIpROd4H4MYWf8ge1fBNVxADGG2V18xRw8wmrBMig 31qigqfu3GDaKlRudDowb7zLZwdwaLDRI6r+LHzDiI0nMv6GKYctBYre2UzXH/QxP5V7 ZmVfrDDC4YzfxEOp0yBrzKpPyVlZOAc89qW6efkJC7GOIDrFSeol14IETXyogL2gG5jA sY9LqqNgePia35Eq8WvrUUwB6x0IhfxTzC6WIZTRZZ8fd0IlAUAyZZWuLuI9nYGFaN0N rscQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CQXT048V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 187-20020a6308c4000000b0039d76139daasi4738615pgi.432.2022.05.06.04.45.38; Fri, 06 May 2022 04:45:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CQXT048V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377055AbiEDRpf (ORCPT + 99 others); Wed, 4 May 2022 13:45:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356214AbiEDRMH (ORCPT ); Wed, 4 May 2022 13:12:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96B884BFC2; Wed, 4 May 2022 09:57:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 385B6B8278E; Wed, 4 May 2022 16:57:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDE14C385AF; Wed, 4 May 2022 16:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683470; bh=FC9DjzQV9hBsv5/eiTjlSjGGc3F9HI+yaL5So1/yfBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CQXT048VMd3QYP23KLrc1rJ9/0mbLzCpLdD/ccsUlzA3SJZ7lfmRjK2B9T59ceo3X 9HNrJl1Ek9EHt3NEGWm8nIrPoFZ9KSR0tLmqoFVXQPUr8UAw50I04TSzdi8pTcSciH 3pqxr0Tt+LkJDlyHhT3DHBCNu/RWR1QxfiAVThQU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Mikityanskiy , Tariq Toukan , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.17 145/225] tls: Skip tls_append_frag on zero copy size Date: Wed, 4 May 2022 18:46:23 +0200 Message-Id: <20220504153123.114142016@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153110.096069935@linuxfoundation.org> References: <20220504153110.096069935@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maxim Mikityanskiy [ Upstream commit a0df71948e9548de819a6f1da68f5f1742258a52 ] Calling tls_append_frag when max_open_record_len == record->len might add an empty fragment to the TLS record if the call happens to be on the page boundary. Normally tls_append_frag coalesces the zero-sized fragment to the previous one, but not if it's on page boundary. If a resync happens then, the mlx5 driver posts dump WQEs in tx_post_resync_dump, and the empty fragment may become a data segment with byte_count == 0, which will confuse the NIC and lead to a CQE error. This commit fixes the described issue by skipping tls_append_frag on zero size to avoid adding empty fragments. The fix is not in the driver, because an empty fragment is hardly the desired behavior. Fixes: e8f69799810c ("net/tls: Add generic NIC offload infrastructure") Signed-off-by: Maxim Mikityanskiy Reviewed-by: Tariq Toukan Link: https://lore.kernel.org/r/20220426154949.159055-1-maximmi@nvidia.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/tls/tls_device.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index b932469ee69c..a40553e83f8b 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -483,11 +483,13 @@ static int tls_push_data(struct sock *sk, copy = min_t(size_t, size, (pfrag->size - pfrag->offset)); copy = min_t(size_t, copy, (max_open_record_len - record->len)); - rc = tls_device_copy_data(page_address(pfrag->page) + - pfrag->offset, copy, msg_iter); - if (rc) - goto handle_error; - tls_append_frag(record, pfrag, copy); + if (copy) { + rc = tls_device_copy_data(page_address(pfrag->page) + + pfrag->offset, copy, msg_iter); + if (rc) + goto handle_error; + tls_append_frag(record, pfrag, copy); + } size -= copy; if (!size) { -- 2.35.1