From patchwork Thu Jun 11 02:21:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namjae Jeon X-Patchwork-Id: 11599139 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A85F618 for ; Thu, 11 Jun 2020 02:26:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 25E6D2074B for ; Thu, 11 Jun 2020 02:26:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="gIa3Z0sm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726290AbgFKC01 (ORCPT ); Wed, 10 Jun 2020 22:26:27 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:62277 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726163AbgFKC0Z (ORCPT ); Wed, 10 Jun 2020 22:26:25 -0400 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20200611022621epoutp04024714d5a12320456dbdac3f45f48658~XXDZNXSAm1115911159epoutp049 for ; Thu, 11 Jun 2020 02:26:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20200611022621epoutp04024714d5a12320456dbdac3f45f48658~XXDZNXSAm1115911159epoutp049 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1591842381; bh=fBKyV3l/gqu0fqM1IfprJo2DLtP0K5DetVQ3tnGKVfg=; h=From:To:Cc:Subject:Date:References:From; b=gIa3Z0smTzLFCQWtGXCA7PGF0zDWCutW2ADng36Y5SG/7L5gEkp41e04UYvun9SOW lnYmde1qD55EeidpYOTfiFtJjaGzHmLMWMB2xOL2H57YEnlB0cg5YQvnwW/1ADQhpX vHoO/7nQmkrwmYMx6EgT+twX3NxUMrPDm9oLc5bY= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20200611022621epcas1p23387ad0ba15c5052c1ce3675dd906588~XXDY_zQIf2268522685epcas1p2-; Thu, 11 Jun 2020 02:26:21 +0000 (GMT) Received: from epsmges1p5.samsung.com (unknown [182.195.40.165]) by epsnrtp1.localdomain (Postfix) with ESMTP id 49j75S2tbwzMqYm3; Thu, 11 Jun 2020 02:26:20 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id 8C.C2.28578.B4691EE5; Thu, 11 Jun 2020 11:26:19 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20200611022619epcas1p46fd9d1d54396f0a4206b550949377d99~XXDXG4U3p2623526235epcas1p4b; Thu, 11 Jun 2020 02:26:19 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200611022619epsmtrp20a4eafa9091b25fa77161a88a728af10~XXDXGOz600085200852epsmtrp2_; Thu, 11 Jun 2020 02:26:19 +0000 (GMT) X-AuditID: b6c32a39-8dfff70000006fa2-32-5ee1964b9b55 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id B8.3B.08303.B4691EE5; Thu, 11 Jun 2020 11:26:19 +0900 (KST) Received: from localhost.localdomain (unknown [10.88.103.87]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200611022619epsmtip1ed4d948064c3f1fcb3f98a0949d7988d~XXDW8jgFo3014530145epsmtip1R; Thu, 11 Jun 2020 02:26:19 +0000 (GMT) From: Namjae Jeon To: linux-cifs@vger.kernel.org Cc: linkinjeon@kernel.org, Namjae Jeon , Stable , Aurelien Aptel , Steve French Subject: [PATCH] smb3: add indatalen that can be a non-zero value to calculation of credit charge in smb2 ioctl Date: Thu, 11 Jun 2020 11:21:19 +0900 Message-Id: <20200611022119.31506-1-namjae.jeon@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJKsWRmVeSWpSXmKPExsWy7bCmvq73tIdxBre+qFg0vj3NYjFx2lJm ixf/dzFb/Jheb/HmxWE2iwUbHzE6sHnsnHWX3WPTqk42j74tqxg91m+5yuLxeZNcAGtUjk1G amJKapFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5kkJeYm6qrZKLT4CuW2YO0AFKCmWJOaVA oYDE4mIlfTubovzSklSFjPziElul1IKUnAJDgwK94sTc4tK8dL3k/FwrQwMDI1OgyoScjBXb L7MUfOCtmNM/iamB8Tl3FyMnh4SAicSW+d1MXYxcHEICOxglbp18zwzhfGKUOLpqJxtIlZDA Z0aJ4w/5YDoONjxhhSjaxSjR2bWXFa5jevMDxi5GDg42AW2JP1tEQRpEBOQk1m46yQJSwyyw Cmjqks3MIAlhgUKJ9ev/MoLYLAKqEnOPnQWL8wrYSOxY/5wVYpu8xOoNB8BOkhBYxS5x9nIn G0TCReLW8aksELawxKvjW9ghbCmJz+/2soEcISFQLfFxPzNEuINR4sV3WwjbWOLm+g2sICXM ApoS63fpQ4QVJXb+ngt2DrMAn8S7rz2sEFN4JTrahCBKVCX6Lh1mgrClJbraP0At9ZD4PamL BRJWsRLnWpexTmCUnYWwYAEj4ypGsdSC4tz01GLDAlPkONrECE5TWpY7GKe//aB3iJGJg/EQ owQHs5IIr6D4wzgh3pTEyqrUovz4otKc1OJDjKbA4JrILCWanA9MlHkl8YamRsbGxhYmZuZm psZK4rxO1hfihATSE0tSs1NTC1KLYPqYODilGpi4fddOufW+cuuV3VOWsrUHeBZa/rPJ5hHn 2/whR95Z2WZh5Mqq7zLS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yUw 7mMe2yRpRX2W5pXL/y60/33HVXJpx5rmcOfFJWYXbq2I3rAkJ3SR96yG6Fd27JkcDbpClXOu 9RwK2jCRUzvE5906p6niAX+i5r/7Kndq8uzTEqe2borv7mteKiG46swUTV+HU0osxRmJhlrM RcWJAPhBMK+LAgAA X-CMS-MailID: 20200611022619epcas1p46fd9d1d54396f0a4206b550949377d99 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200611022619epcas1p46fd9d1d54396f0a4206b550949377d99 References: Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Some of tests in xfstests failed with cifsd kernel server since commit e80ddeb2f70e. cifsd kernel server validates credit charge from client by calculating it base on max((InputCount + OutputCount) and (MaxInputResponse + MaxOutputResponse)) according to specification. MS-SMB2 specification describe credit charge calculation of smb2 ioctl : If Connection.SupportsMultiCredit is TRUE, the server MUST validate CreditCharge based on the maximum of (InputCount + OutputCount) and (MaxInputResponse + MaxOutputResponse), as specified in section 3.3.5.2.5. If the validation fails, it MUST fail the IOCTL request with STATUS_INVALID_PARAMETER. This patch add indatalen that can be a non-zero value to calculation of credit charge in SMB2_ioctl_init(). Fixes: e80ddeb2f70e ("smb3: fix incorrect number of credits when ioctl MaxOutputResponse > 64K") Cc: Stable Cc: Aurelien Aptel Cc: Steve French Signed-off-by: Namjae Jeon Reviewed-by: Aurelien Aptel --- fs/cifs/smb2pdu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index ded96b529a4d..86d894499fbb 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2973,7 +2973,9 @@ SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server, * response size smaller. */ req->MaxOutputResponse = cpu_to_le32(max_response_size); - req->sync_hdr.CreditCharge = cpu_to_le16(DIV_ROUND_UP(max_response_size, SMB2_MAX_BUFFER_SIZE)); + req->sync_hdr.CreditCharge = + cpu_to_le16(DIV_ROUND_UP(max(indatalen, max_response_size), + SMB2_MAX_BUFFER_SIZE)); if (is_fsctl) req->Flags = cpu_to_le32(SMB2_0_IOCTL_IS_FSCTL); else