Message ID | 20240206161625.145373-1-martin@kaiser.cx |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-55310-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1669261dyb; Tue, 6 Feb 2024 08:47:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWhXHZ1AecYP0V01VkN01KiXMM+XGjuFRt/Yo2xVU67l2+pEKANDi34O+v6fJJ2P4/gCU81InDeUvPtQPtm9bXq/zkz6g== X-Google-Smtp-Source: AGHT+IHF0ZdCrhDG/e/db/JZazKdPbIkAnfsd50FVvUdEVYhvkWLiW9/2OvQ6C4iknGYgVmRJ0j+ X-Received: by 2002:a05:6a20:ae2a:b0:19c:7485:4f75 with SMTP id dp42-20020a056a20ae2a00b0019c74854f75mr1608762pzb.42.1707238054533; Tue, 06 Feb 2024 08:47:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707238054; cv=pass; d=google.com; s=arc-20160816; b=NPt+DTobX8gCchq1mbHpXpXI7QuWGGYTnJD+8SbAy7PE2P1buvzzJZzjdotEI4M0ff 2NEOnQhcuriEU70WXRX0HKhBM0xB2yaSrWRP0hSif9xXy/g/qPpiIammSNoZCrrYrXCH 46c6vWX08R/Z+0+GC8KGCwao7j9njTA6GQeBlvwj1NV45s/AJBpob1w4ICki4k+Qq8bo KOI61Glu3CUapmK5sMj9zzNKZxA28498G71hYrPWAAMfHmmHPM9uz48qC6Y+H+Ce8QMb v8Bf84BzuKffHh6UsQeoU+P34ayQP/mtkPqHheywcmCyFKjkfL+9poBQRG+ZDAZY2t56 QaEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=WveEMl923oL7k+AFVVExDsLUqRKAi9PPujhMNUYGeKQ=; fh=ger3+iDm41r5P3+r9OLOODwiJlCsHkvsjpTy+1A4Bdo=; b=0ysn3YdAYnI0nsSvS3EXhjk2tcjMTvHhSkQzMVm2gWOxLFNjlXKgFknwirPNaXYxF5 GhKRd8I6mqSl14OUgZPbpabpI8YOHTcwug9FfwD6KSSNa1AjLqTrCTQ0nMF0nIoe2EGN izphSKGXB0B/no9VlF/5s0SLAfVY+lglxPdmY8Xk5+mrtVl5qRq+AAEnSfVit1Obj4YY sPm3KafuWw1Ib3K8v8bc2AwjN2XgXCJZcc3eotv9EBogyJ39uvMvX1j8seFcM18vhsNl njgsVG7TCqiFis8oKEqItcJQM8wTf4zEVDK+B5qilw5XGnpnw7eMrmMFhNZabdzip3YX P4ag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=kaiser.cx); spf=pass (google.com: domain of linux-kernel+bounces-55310-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55310-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCWwZ4i2zJyGiULC89JzcbDnagSNEfbgcBu4V/haLEekkNg5L7u9Yi7zhycNgPLjMwrO1TpdvvSZg0WnJEMOlnuIh0/4Zw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p123-20020a634281000000b005d7bf204e26si1931704pga.899.2024.02.06.08.47.34 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 08:47:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55310-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=kaiser.cx); spf=pass (google.com: domain of linux-kernel+bounces-55310-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55310-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B37CAB2835A for <ouuuleilei@gmail.com>; Tue, 6 Feb 2024 16:17:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A32A134CFB; Tue, 6 Feb 2024 16:17:32 +0000 (UTC) Received: from akranes.kaiser.cx (akranes.kaiser.cx [152.53.16.207]) (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 E807612E1ED; Tue, 6 Feb 2024 16:17:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=152.53.16.207 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707236251; cv=none; b=bPS0td5Mh0X14N9VB5fwoRlwaCu4CZoFFuBicKNleAwMUZoML8e3c7no7t8PjwqAEg2h6HGnFUh3DQvPi5i3lu5hJHrfT6Kg2sFSnX2o1LRsgtwSaaKCA4b7vzVR+5JwdUt9p4kgDw2DyUw5fr6DQdfSPw7AZy0YXT3ZqteSkDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707236251; c=relaxed/simple; bh=ZIkXxwfLDy2zEl+CsRwUflruol8oIHsF7djmGyspYHk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=iPHBYtqwVWrfmJvZDWI/GlFna8UhllNPQ5+sMAqlkBRKFuJPqBi8Z2TfYOU/43yAsl2pfcLw/HBidt2uy5CfBmG5rZb1bwpWQgT+1syQMKWyWf7web7GNxGVl9zKM1EW/+LJx9rpUszLBiy6DM9Ftadq0QB5On8Q/rkYcdLkRBU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kaiser.cx; spf=pass smtp.mailfrom=kaiser.cx; arc=none smtp.client-ip=152.53.16.207 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kaiser.cx Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kaiser.cx Received: from dslb-178-004-206-106.178.004.pools.vodafone-ip.de ([178.4.206.106] helo=martin-debian-2.paytec.ch) by akranes.kaiser.cx with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from <martin@kaiser.cx>) id 1rXO8N-000CUo-2f; Tue, 06 Feb 2024 17:17:19 +0100 From: Martin Kaiser <martin@kaiser.cx> To: Trond Myklebust <trond.myklebust@hammerspace.com>, Anna Schumaker <anna@kernel.org>, David Howells <dhowells@redhat.com> Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Kaiser <martin@kaiser.cx> Subject: [PATCH] nfs: keep server info for remounts Date: Tue, 6 Feb 2024 17:16:25 +0100 Message-Id: <20240206161625.145373-1-martin@kaiser.cx> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790168850311987313 X-GMAIL-MSGID: 1790168850311987313 |
Series |
nfs: keep server info for remounts
|
|
Commit Message
Martin Kaiser
Feb. 6, 2024, 4:16 p.m. UTC
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 in
nfs_init_fs_context and later overwritten with invalid data 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 <martin@kaiser.cx>
---
I guess that we're taking this path for remounts
do_remount
fs_context_for_reconfigure
alloc_fs_context
init_fs_context == nfs_init_fs_context
fc->root is set for remounts
ctx->nfs_server is populated
parse_monolithic_mount_data
nfs_fs_context_parse_monolithic
nfs23_parse_monolithic
ctx->nfs_server is overwritten with data from mount request
An alternative to checking for !is_remount_fc(fc) would be to check
if (ctx->nfs_server.addrlen == 0)
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 853e8d609bb3..41126d6dcd76 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;