Skip to content

Commit

Permalink
NFSv4.1 enforce rootpath check in fs_location query
Browse files Browse the repository at this point in the history
In commit 4ca9f31 ("NFSv4.1 test and add 4.1 trunking transport"),
we introduce the ability to query the NFS server for possible trunking
locations of the existing filesystem. However, we never checked the
returned file system path for these alternative locations. According
to the RFC, the server can say that the filesystem currently known
under "fs_root" of fs_location also resides under these server
locations under the following "rootpath" pathname. The client cannot
handle trunking a filesystem that reside under different location
under different paths other than what the main path is. This patch
enforces the check that fs_root path and rootpath path in fs_location
reply is the same.

Fixes: 4ca9f31 ("NFSv4.1 test and add 4.1 trunking transport")
Signed-off-by: Olga Kornievskaia <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
olgakorn1 authored and Trond Myklebust committed May 30, 2024
1 parent 296f4ce commit 28568c9
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4023,6 +4023,23 @@ static void test_fs_location_for_trunking(struct nfs4_fs_location *location,
}
}

static bool _is_same_nfs4_pathname(struct nfs4_pathname *path1,
struct nfs4_pathname *path2)
{
int i;

if (path1->ncomponents != path2->ncomponents)
return false;
for (i = 0; i < path1->ncomponents; i++) {
if (path1->components[i].len != path2->components[i].len)
return false;
if (memcmp(path1->components[i].data, path2->components[i].data,
path1->components[i].len))
return false;
}
return true;
}

static int _nfs4_discover_trunking(struct nfs_server *server,
struct nfs_fh *fhandle)
{
Expand Down Expand Up @@ -4056,9 +4073,13 @@ static int _nfs4_discover_trunking(struct nfs_server *server,
if (status)
goto out_free_3;

for (i = 0; i < locations->nlocations; i++)
for (i = 0; i < locations->nlocations; i++) {
if (!_is_same_nfs4_pathname(&locations->fs_path,
&locations->locations[i].rootpath))
continue;
test_fs_location_for_trunking(&locations->locations[i], clp,
server);
}
out_free_3:
kfree(locations->fattr);
out_free_2:
Expand Down

0 comments on commit 28568c9

Please sign in to comment.