• Paulo Alcantara's avatar
    cifs: fix regression when mounting shares with prefix paths · 5c1acf3f
    Paulo Alcantara authored
    The commit 315db9a0 ("cifs: fix leak in cifs_smb3_do_mount() ctx")
    revealed an existing bug when mounting shares that contain a prefix
    path or DFS links.
    
    cifs_setup_volume_info() requires the @devname to contain the full
    path (UNC + prefix) to update the fs context with the new UNC and
    prepath values, however we were passing only the UNC
    path (old_ctx->UNC) in @device thus discarding any prefix paths.
    
    Instead of concatenating both old_ctx->{UNC,prepath} and pass it in
    @devname, just keep the dup'ed values of UNC and prepath in
    cifs_sb->ctx after calling smb3_fs_context_dup(), and fix
    smb3_parse_devname() to correctly parse and not leak the new UNC and
    prefix paths.
    
    Cc: <stable@vger.kernel.org> # v5.11+
    Fixes: 315db9a0 ("cifs: fix leak in cifs_smb3_do_mount() ctx")
    Signed-off-by: default avatarPaulo Alcantara (SUSE) <pc@cjr.nz>
    Acked-by: default avatarDavid Disseldorp <ddiss@suse.de>
    Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
    5c1acf3f
fs_context.c 43.5 KB