Skip to content

Commit

Permalink
Compare prepaths when comparing superblocks
Browse files Browse the repository at this point in the history
The patch
fs/cifs: make share unaccessible at root level mountable
makes use of prepaths when any component of the underlying path is
inaccessible.

When mounting 2 separate shares having different prepaths but are other
wise similar in other respects, we end up sharing superblocks when we
shouldn't be doing so.

Signed-off-by: Sachin Prabhu <[email protected]>
Tested-by: Aurelien Aptel <[email protected]>
Signed-off-by: Steve French <[email protected]>
  • Loading branch information
spuiuk authored and smfrench committed Sep 10, 2016
1 parent 4214ebf commit c1d8b24
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion fs/cifs/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -2781,6 +2781,24 @@ compare_mount_options(struct super_block *sb, struct cifs_mnt_data *mnt_data)
return 1;
}

static int
match_prepath(struct super_block *sb, struct cifs_mnt_data *mnt_data)
{
struct cifs_sb_info *old = CIFS_SB(sb);
struct cifs_sb_info *new = mnt_data->cifs_sb;

if (old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) {
if (!(new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH))
return 0;
/* The prepath should be null terminated strings */
if (strcmp(new->prepath, old->prepath))
return 0;

return 1;
}
return 0;
}

int
cifs_match_super(struct super_block *sb, void *data)
{
Expand Down Expand Up @@ -2808,7 +2826,8 @@ cifs_match_super(struct super_block *sb, void *data)

if (!match_server(tcp_srv, volume_info) ||
!match_session(ses, volume_info) ||
!match_tcon(tcon, volume_info->UNC)) {
!match_tcon(tcon, volume_info->UNC) ||
!match_prepath(sb, mnt_data)) {
rc = 0;
goto out;
}
Expand Down

0 comments on commit c1d8b24

Please sign in to comment.