From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97C661A186C; Thu, 6 Jun 2024 14:21:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717683710; cv=none; b=qpZBWcMKHTzf8nJC8CSw62cUkQh5f3k0x7Hl8tehHOsaMu60eDfPzOfAzxDqjiYu82qmumznzDZ305/HDmIJ27DhRNAoVyJBGwewW0cdHH9PSvOPgoEDEpQZ7+UpgRHGOdQV1998rnS197xgGPO239O0dM/aH2P13a0sUSpCOJU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717683710; c=relaxed/simple; bh=xG59/KK5G5sRmxUess8kGaCv16aNOydmlRxn2fjpf3k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KpE1IYRuk9cZrbVXZ5wERoruusbrbYUor+0paXh9Nz6c59f3jE7nrNxFqB/+Qwr1Nf70BunHFrjto5m4M24zJm+ZqBCIaSM4JwX62XO6EjrT85TERGnGF/TuclD1VWoMYIWQ0hIyEz/yrEizkcKHXLGNTRbSzYsvYJH+Sw6eGiI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=c1Y1uf8T; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="c1Y1uf8T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77061C2BD10; Thu, 6 Jun 2024 14:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1717683710; bh=xG59/KK5G5sRmxUess8kGaCv16aNOydmlRxn2fjpf3k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c1Y1uf8TXwBOKCqDlRh0lZGha/HizYdX4OdKf4MQWlTAbgA9H1ioqb/BwKcl17xe2 8ZjHVbgGi+ks3+HOGwJJoo7/wD7RFqiVt4qC3z+npNcqHzf/sza0fJu/jG/fmIqVJg RbyAPQfaEwSjIgAIArXkIS+fUeqvcwghpCM/VaYQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Martin Kaiser , Trond Myklebust , Sasha Levin Subject: [PATCH 6.6 640/744] nfs: keep server info for remounts Date: Thu, 6 Jun 2024 16:05:12 +0200 Message-ID: <20240606131753.002785673@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240606131732.440653204@linuxfoundation.org> References: <20240606131732.440653204@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Martin Kaiser [ Upstream commit b322bf9e983addedff0894c55e92d58f4d16d92a ] With newer kernels that use fs_context for nfs mounts, remounts fail with -EINVAL. $ mount -t nfs -o nolock 10.0.0.1:/tmp/test /mnt/test/ $ mount -t nfs -o remount /mnt/test/ mount: mounting 10.0.0.1:/tmp/test on /mnt/test failed: Invalid argument For remounts, the nfs server address and port are populated by nfs_init_fs_context and later overwritten with 0x00 bytes by nfs23_parse_monolithic. The remount then fails as the server address is invalid. Fix this by not overwriting nfs server info in nfs23_parse_monolithic if we're doing a remount. Fixes: f2aedb713c28 ("NFS: Add fs_context support.") Signed-off-by: Martin Kaiser Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/fs_context.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c index 853e8d609bb3b..41126d6dcd760 100644 --- a/fs/nfs/fs_context.c +++ b/fs/nfs/fs_context.c @@ -1111,9 +1111,12 @@ static int nfs23_parse_monolithic(struct fs_context *fc, ctx->acdirmax = data->acdirmax; ctx->need_mount = false; - memcpy(sap, &data->addr, sizeof(data->addr)); - ctx->nfs_server.addrlen = sizeof(data->addr); - ctx->nfs_server.port = ntohs(data->addr.sin_port); + if (!is_remount_fc(fc)) { + memcpy(sap, &data->addr, sizeof(data->addr)); + ctx->nfs_server.addrlen = sizeof(data->addr); + ctx->nfs_server.port = ntohs(data->addr.sin_port); + } + if (sap->ss_family != AF_INET || !nfs_verify_server_address(sap)) goto out_no_address; -- 2.43.0