]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
cifs: fix regression when mounting shares with prefix paths
authorPaulo Alcantara <pc@cjr.nz>
Mon, 3 May 2021 14:55:26 +0000 (11:55 -0300)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 19 May 2021 08:31:56 +0000 (10:31 +0200)
commitd14749e5ee056a59426a18a9653d6523d1208a7b
tree1aee284a2421f44247323fa810238bc62170666f
parentface1adedd086cbfd3f0e2f0926284a928485202
cifs: fix regression when mounting shares with prefix paths

BugLink: https://bugs.launchpad.net/bugs/1928857
commit 5c1acf3fe05ce443edba5e2110c9e581765f66a8 upstream.

The commit 315db9a05b7a ("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: 315db9a05b7a ("cifs: fix leak in cifs_smb3_do_mount() ctx")
Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Acked-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/cifs/cifsfs.c
fs/cifs/connect.c
fs/cifs/fs_context.c