From patchwork Fri Feb 10 23:32:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 55635 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1234441wrn; Fri, 10 Feb 2023 15:38:53 -0800 (PST) X-Google-Smtp-Source: AK7set/gTEKBroUQzj4CknTzVrS0MDxR6BKkdEJsDB+MkAg0E00ca9Yq6Tjlrzhm4dbyoAZswtv2 X-Received: by 2002:a17:907:1184:b0:878:6519:c740 with SMTP id uz4-20020a170907118400b008786519c740mr19286772ejb.44.1676072332881; Fri, 10 Feb 2023 15:38:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676072332; cv=none; d=google.com; s=arc-20160816; b=Oioq4VxXGbsperCqXmfb/fm1orBQ7wPabAed5JB6cM50yr5Y1o2h0yxQlFjXyGt6jV EitSswnAZeJgq9VL2HfZMYLhM9aR3n4V+hfMFlXGAULWA//MRahVDjKATz4FA6DJlgu9 LP2St7Z0Fp64ChzbkKyMlyOn1/3o2GNJBh8fq2j/bblr5el5wJf9keSesrUjyMY4/Fid T7YlvpaDILVw1SKqBjSG/u1HJmwoyw1a9G2XR+u7BWqQjkNqkQt+AWJ92QAvfKY1EmnL PEJ5O7h+qUokkMEGABUUAA5K6Wnq0/GwCQhqHZQtmf/uagqpRNOKum/wuj6Jxd/5PucT 6TWA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aLmvd4pDzTYQinLjtfbwp5ScV5jm5Tl15qoPAkwo1Wg=; b=p3Oht8gS/2/04pdt5Dae4//LeB6sJZGptiRiqGGi1ILFUntvQOXOWwFjHK4jtrq0Xs V4ivlH66RZ2+RHEYfWC19kGia/frTB+ldXGZQAedXATiG0BR6S8Q9Ga/cQ0Mf15/A2yS PbcuBZHmNs9yuwQpL2nB2H7Tz5LFVTNiGtzxbfuF+G/8PWKXmWjVhwF5/VEHB2aX7w2j 0PwnrtfsByCur+QWKkGqevQCPYpYL4sAkEmwFX1agZ4RhrvlZ2jspPYq00V+R6ul/+aN uMuxM3gFzwfCK7ImLn/6a9rpD7ySs/eF7u1Zr8wAfVtjTQULBQ3JsJ85n61cKv6520NJ rSAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=axb5sUMT; 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=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q13-20020aa7d44d000000b004aadaee6ddbsi6261363edr.525.2023.02.10.15.38.30; Fri, 10 Feb 2023 15:38:52 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=axb5sUMT; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229986AbjBJXfL (ORCPT + 99 others); Fri, 10 Feb 2023 18:35:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229987AbjBJXel (ORCPT ); Fri, 10 Feb 2023 18:34:41 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A0EC7E020 for ; Fri, 10 Feb 2023 15:32:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676071959; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aLmvd4pDzTYQinLjtfbwp5ScV5jm5Tl15qoPAkwo1Wg=; b=axb5sUMTFwqnNTI0sYeiDXXsyzK2aa5xInecpoqb01aJs6YmJJ5orK1opMpb5lfxOYhO8C BOimzoCBMn2h/fG2/v/iHHjh4qrXZxcdmOhSC6SPBzQhZA6ZrzlJDyV82z4pW7IfMWYCsP PiBqFOkstucO+h6RsoKVdW/rupLQojw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-588-wILtai1rOhmKtgpOFoLSzg-1; Fri, 10 Feb 2023 18:32:36 -0500 X-MC-Unique: wILtai1rOhmKtgpOFoLSzg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 08152101A521; Fri, 10 Feb 2023 23:32:36 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56FF0492B00; Fri, 10 Feb 2023 23:32:34 +0000 (UTC) From: David Howells To: Steve French Cc: David Howells , Al Viro , Shyam Prasad N , Rohith Surabattula , Tom Talpey , Stefan Metzmacher , Christoph Hellwig , Matthew Wilcox , Jeff Layton , linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Long Li , Namjae Jeon Subject: [PATCH 11/11] cifs: Fix problem with encrypted RDMA data read Date: Fri, 10 Feb 2023 23:32:05 +0000 Message-Id: <20230210233205.1517459-12-dhowells@redhat.com> In-Reply-To: <20230210233205.1517459-1-dhowells@redhat.com> References: <20230210233205.1517459-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757489222890111372?= X-GMAIL-MSGID: =?utf-8?q?1757489222890111372?= When the cifs client is talking to the ksmbd server by RDMA and the ksmbd server has "smb3 encryption = yes" in its config file, the normal PDU stream is encrypted, but the directly-delivered data isn't in the stream (and isn't encrypted), but is rather delivered by DDP/RDMA packets (at least with IWarp). Currently, the direct delivery fails with: buf can not contain only a part of read data WARNING: CPU: 0 PID: 4619 at fs/cifs/smb2ops.c:4731 handle_read_data+0x393/0x405 ... RIP: 0010:handle_read_data+0x393/0x405 ... smb3_handle_read_data+0x30/0x37 receive_encrypted_standard+0x141/0x224 cifs_demultiplex_thread+0x21a/0x63b kthread+0xe7/0xef ret_from_fork+0x22/0x30 The problem apparently stemming from the fact that it's trying to manage the decryption, but the data isn't in the smallbuf, the bigbuf or the page array). This can be fixed simply by inserting an extra case into handle_read_data() that checks to see if use_rdma_mr is true, and if it is, just setting rdata->got_bytes to the length of data delivered and allowing normal continuation. This can be seen in an IWarp packet trace. With the upstream code, it does a DDP/RDMA packet, which produces the warning above and then retries, retrieving the data inline, spread across several SMBDirect messages that get glued together into a single PDU. With the patch applied, only the DDP/RDMA packet is seen. Note that this doesn't happen if the server isn't told to encrypt stuff and it does also happen with softRoCE. Signed-off-by: David Howells cc: Steve French cc: Tom Talpey cc: Long Li cc: Namjae Jeon cc: Stefan Metzmacher cc: linux-cifs@vger.kernel.org Link: https://lore.kernel.org/r/166855224228.1998592.2212551359609792175.stgit@warthog.procyon.org.uk/ # v1 --- fs/cifs/smb2ops.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 744cd7374a43..636175850ca7 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -4734,6 +4734,9 @@ handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid, if (length < 0) return length; rdata->got_bytes = data_len; + } else if (use_rdma_mr) { + /* The data was delivered directly by RDMA. */ + rdata->got_bytes = data_len; } else { /* read response payload cannot be in both buf and pages */ WARN_ONCE(1, "buf can not contain only a part of read data");