Skip to content

Commit

Permalink
afs: Fix mountpoint parsing
Browse files Browse the repository at this point in the history
BugLink: https://bugs.launchpad.net/bugs/1861710

[ Upstream commit 158d583 ]

Each AFS mountpoint has strings that define the target to be mounted.  This
is required to end in a dot that is supposed to be stripped off.  The
string can include suffixes of ".readonly" or ".backup" - which are
supposed to come before the terminal dot.  To add to the confusion, the "fs
lsmount" afs utility does not show the terminal dot when displaying the
string.

The kernel mount source string parser, however, assumes that the terminal
dot marks the suffix and that the suffix is always "" and is thus ignored.
In most cases, there is no suffix and this is not a problem - but if there
is a suffix, it is lost and this affects the ability to mount the correct
volume.

The command line mount command, on the other hand, is expected not to
include a terminal dot - so the problem doesn't arise there.

Fix this by making sure that the dot exists and then stripping it when
passing the string to the mount configuration.

Fixes: bec5eb6 ("AFS: Implement an autocell mount capability [ver #2]")
Reported-by: Jonathan Billings <[email protected]>
Signed-off-by: David Howells <[email protected]>
Reviewed-by: Marc Dionne <[email protected]>
Tested-by: Jonathan Billings <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Kamal Mostafa <[email protected]>
Signed-off-by: Khalid Elmously <[email protected]>
  • Loading branch information
dhowells authored and kelmously committed Feb 14, 2020
1 parent 82a09ac commit 19f9fda
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/afs/mntpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static int afs_mntpt_set_params(struct fs_context *fc, struct dentry *mntpt)
if (src_as->cell)
ctx->cell = afs_get_cell(src_as->cell);

if (size > PAGE_SIZE - 1)
if (size < 2 || size > PAGE_SIZE - 1)
return -EINVAL;

page = read_mapping_page(d_inode(mntpt)->i_mapping, 0, NULL);
Expand All @@ -140,7 +140,9 @@ static int afs_mntpt_set_params(struct fs_context *fc, struct dentry *mntpt)
}

buf = kmap(page);
ret = vfs_parse_fs_string(fc, "source", buf, size);
ret = -EINVAL;
if (buf[size - 1] == '.')
ret = vfs_parse_fs_string(fc, "source", buf, size - 1);
kunmap(page);
put_page(page);
if (ret < 0)
Expand Down

0 comments on commit 19f9fda

Please sign in to comment.