Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4683244iob; Sun, 8 May 2022 21:53:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPzeUpcKkSF4Nkx/N2wnAytbEOIZkf5dvzVEBJydIuxwV9Bo0Gkfig0cYzn3MZ/qouw93j X-Received: by 2002:a05:6a00:1941:b0:50d:807d:530b with SMTP id s1-20020a056a00194100b0050d807d530bmr14184984pfk.17.1652071985826; Sun, 08 May 2022 21:53:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652071985; cv=none; d=google.com; s=arc-20160816; b=tVMT+eoNxKiHLjqEIMjwARz7NdhKRscjGOor2umH01bhVTYhI/xKxrM8h5H66wmwc+ ILKHMH420tAXZgZ3lts3Aq1KbPSeeCHJEDBpvkaFrHIQLQnAaNiprawtrgAGAetnNV4c rcy0maYUG8euQv9QH8XdMeOBDr4C79fc5QXvWwl4ueM8N2VgJgE6g208XDhAPpf1C74P 6HoXdu4X/sTyGwpFA5fE3G1RzmAtEVPsl1TOtOSlkPUapNdUdfkWL0yJKdhJ5l2hT+la UhCYhD5Ch+ITEmTArhFeGErQEwh87Axi9/FRvayNkAhtT7GA5BFrR3HAXgkRTuGVJX3o TnNA== 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=/ch253jaBI07mzkhfPWAyzj2boDY/0jKojRkm3XiS8k=; b=UxtvQ1hahDpmoouNihYSqbx6jRK2SUDcolJifHr2GcfFNhaEoLswA4pwSSBk4YjFPy G0MdtOsTRFG/gaej40ZM3TMWL8MpMdOyKefuHBfNI8k19BXiReSqS3p38cwh439XM6ej JquU9jxMnRgQdPZsMKBcPjvtJgE9z06vvY/904dUgK+AvsI8SDRVSqakvRtSWxweDn7p kX5IY/IrvgSfgBtpVKaDsQbCHkec/ULZtOoI0/2z+fjemj4jyWNvA3krXSrY1wSn/2Nt nhhdG+WcW2cfxcQGMDtXV9UM1DoIiQMpqLivpjgWxzCBjuJqaJ/ibHOTzvwjoCUtPyv6 YC2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XVTAjgYI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id ob3-20020a17090b390300b001dc4eff067asi22053861pjb.91.2022.05.08.21.53.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 21:53:05 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XVTAjgYI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 620093A5E9; Sun, 8 May 2022 21:50:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354621AbiEDRHL (ORCPT + 99 others); Wed, 4 May 2022 13:07:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355331AbiEDQ7y (ORCPT ); Wed, 4 May 2022 12:59:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C5584AE16; Wed, 4 May 2022 09:51:32 -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 dfw.source.kernel.org (Postfix) with ESMTPS id DD518617C3; Wed, 4 May 2022 16:51:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3209DC385A5; Wed, 4 May 2022 16:51:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683088; bh=8/4Fbs9/GbSJ2Y8kjigEuSA44LNwUjllrxVYoEi/q6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XVTAjgYIRjR7a9G9STfhXY2oVngKlwRjABkrybN6gRBsJWHeffmyAIQ4wQ08aD5C0 bhEGKRvzuBzmseRyx6vtY5cp8YdUjKxfDL0i2HAo8GpPcmqAx4PKsmJoZq8XRRq2yI vpNTwOtlVTBGwvDrykdK92t+mINCDJffKoo59uzM= 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.10 092/129] tls: Skip tls_append_frag on zero copy size Date: Wed, 4 May 2022 18:44:44 +0200 Message-Id: <20220504153028.256636406@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153021.299025455@linuxfoundation.org> References: <20220504153021.299025455@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=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 f718c7346088..1f56225a10e3 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