Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3429209imu; Sun, 11 Nov 2018 14:54:47 -0800 (PST) X-Google-Smtp-Source: AJdET5cNMIdjkaMjPM7+t2G6YlFg0HlF+1S650dgUQkbHabVjpA5vXuS5pBe8KvhLx0YcvCpS9Kl X-Received: by 2002:a63:344e:: with SMTP id b75mr14931332pga.184.1541976887638; Sun, 11 Nov 2018 14:54:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541976887; cv=none; d=google.com; s=arc-20160816; b=qQpvQMvz+tShtmOd+OoFJ8dccNOpitog2mjWz69ayburb/GpSdcGzQbkapJWBtEbOt MqbUqN+qfTW1dAlOmRdWlXtr0B3PK2N5ulSWYXsjDbjJVzdalN4IyJeMojczB0HXMLE6 1SrOvptHAvEBEBgEy6RXUBfNm1lMqOcJ4DcjkpLabKrLNmuadfEbMiXQ8ttpR10Bnfmo cR7xYPwP8Ftw7Ud+T5pqUBPo2+JyTZ8zK2iFU/g8oplxxGJGKRlwbBhMwdPFUbjk1/fG ViMbUb8V+FnGQNREj+PwXyBQrsip8XzZYtMwzG/mesA5l+l3PKttf993GFACVtEWiq03 YPqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tv/rmnBUA1eSyeZEqDDdPEnunqck+6TyLQFyptEIZRM=; b=HFjZll621MUM7egz5zXO9a47J9RZ5XBqiEx4bmnRG/t4Vb78IUQOWEhY0n3faqQqIq ZOSTnPKV6bD4CqX2so+/SP4WAkodAG2/MhdscqT30btSsLoWqa0lE/B/he8+VocMvfpb 2HylzKKeE7+7+i8yhZFxmQPtQwnJHfNVYABkodMeVoptp6Pa0TDqIaOcdu+p8byliueW 7Q0gfdFf79rLPW0dNvWhZwWaMaqPMPt/pMKr5QbsG7vK8CfXCE47AWaCXAJ32LTP5H4h VPguz55UtxLKq+ZhxJg9Sih2M6F8Z7pWWfS2wz2bGpo084VFlOYo++R2YzTI7338Oqxj l0uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VUvtmdfc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i63si14467228pge.515.2018.11.11.14.54.32; Sun, 11 Nov 2018 14:54:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VUvtmdfc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404191AbeKLIoP (ORCPT + 99 others); Mon, 12 Nov 2018 03:44:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:54642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403884AbeKLIW5 (ORCPT ); Mon, 12 Nov 2018 03:22:57 -0500 Received: from localhost (unknown [206.108.79.134]) (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 36603223C7; Sun, 11 Nov 2018 22:33:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975580; bh=iRk0cre2C0B8n18GsNgfB44Y+miMB1omj7y6XZnuOKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VUvtmdfcHQu02rLqrvTvrcO9Ji+1PpsEBZAHEfd5wLC6UHkb1BtmWGrE0YMdQyp4s jkL1FVdkw8xj/H+nxWiY/wukyolV+YNTpo5i6i1IxBev1nYet53SxPd1pCQhMGzi6X UfzQH0rCsnX+UupKg7NdWRcbTgfuc0wMZOiTsVHE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust Subject: [PATCH 4.14 169/222] NFSv4.1: Fix the r/wsize checking Date: Sun, 11 Nov 2018 14:24:26 -0800 Message-Id: <20181111221702.336640901@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Trond Myklebust commit 943cff67b842839f4f35364ba2db5c2d3f025d94 upstream. The intention of nfs4_session_set_rwsize() was to cap the r/wsize to the buffer sizes negotiated by the CREATE_SESSION. The initial code had a bug whereby we would not check the values negotiated by nfs_probe_fsinfo() (the assumption being that CREATE_SESSION will always negotiate buffer values that are sane w.r.t. the server's preferred r/wsizes) but would only check values set by the user in the 'mount' command. The code was changed in 4.11 to _always_ set the r/wsize, meaning that we now never use the server preferred r/wsizes. This is the regression that this patch fixes. Also rename the function to nfs4_session_limit_rwsize() in order to avoid future confusion. Fixes: 033853325fe3 (NFSv4.1 respect server's max size in CREATE_SESSION") Cc: stable@vger.kernel.org # v4.11+ Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman --- fs/nfs/nfs4client.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -925,10 +925,10 @@ EXPORT_SYMBOL_GPL(nfs4_set_ds_client); /* * Session has been established, and the client marked ready. - * Set the mount rsize and wsize with negotiated fore channel - * attributes which will be bound checked in nfs_server_set_fsinfo. + * Limit the mount rsize, wsize and dtsize using negotiated fore + * channel attributes. */ -static void nfs4_session_set_rwsize(struct nfs_server *server) +static void nfs4_session_limit_rwsize(struct nfs_server *server) { #ifdef CONFIG_NFS_V4_1 struct nfs4_session *sess; @@ -941,9 +941,11 @@ static void nfs4_session_set_rwsize(stru server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead; server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead; - if (!server->rsize || server->rsize > server_resp_sz) + if (server->dtsize > server_resp_sz) + server->dtsize = server_resp_sz; + if (server->rsize > server_resp_sz) server->rsize = server_resp_sz; - if (!server->wsize || server->wsize > server_rqst_sz) + if (server->wsize > server_rqst_sz) server->wsize = server_rqst_sz; #endif /* CONFIG_NFS_V4_1 */ } @@ -990,12 +992,12 @@ static int nfs4_server_common_setup(stru (unsigned long long) server->fsid.minor); nfs_display_fhandle(mntfh, "Pseudo-fs root FH"); - nfs4_session_set_rwsize(server); - error = nfs_probe_fsinfo(server, mntfh, fattr); if (error < 0) goto out; + nfs4_session_limit_rwsize(server); + if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN) server->namelen = NFS4_MAXNAMLEN;