Skip to content

Commit 28568c9

Browse files
olgakorn1Trond Myklebust
authored andcommitted
NFSv4.1 enforce rootpath check in fs_location query
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]>
1 parent 296f4ce commit 28568c9

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

fs/nfs/nfs4proc.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4023,6 +4023,23 @@ static void test_fs_location_for_trunking(struct nfs4_fs_location *location,
40234023
}
40244024
}
40254025

4026+
static bool _is_same_nfs4_pathname(struct nfs4_pathname *path1,
4027+
struct nfs4_pathname *path2)
4028+
{
4029+
int i;
4030+
4031+
if (path1->ncomponents != path2->ncomponents)
4032+
return false;
4033+
for (i = 0; i < path1->ncomponents; i++) {
4034+
if (path1->components[i].len != path2->components[i].len)
4035+
return false;
4036+
if (memcmp(path1->components[i].data, path2->components[i].data,
4037+
path1->components[i].len))
4038+
return false;
4039+
}
4040+
return true;
4041+
}
4042+
40264043
static int _nfs4_discover_trunking(struct nfs_server *server,
40274044
struct nfs_fh *fhandle)
40284045
{
@@ -4056,9 +4073,13 @@ static int _nfs4_discover_trunking(struct nfs_server *server,
40564073
if (status)
40574074
goto out_free_3;
40584075

4059-
for (i = 0; i < locations->nlocations; i++)
4076+
for (i = 0; i < locations->nlocations; i++) {
4077+
if (!_is_same_nfs4_pathname(&locations->fs_path,
4078+
&locations->locations[i].rootpath))
4079+
continue;
40604080
test_fs_location_for_trunking(&locations->locations[i], clp,
40614081
server);
4082+
}
40624083
out_free_3:
40634084
kfree(locations->fattr);
40644085
out_free_2:

0 commit comments

Comments
 (0)