bug fixes and code cleanups for inaccessible root patch
Subsystems (2)
cover bug fixes and code cleanups for inaccessible root patch
The fix for unaccessible root with summary
"fs/cifs: make share unaccessible at root level mountable" introduces a few bugs. This series of patches cleans up some parts of the code and also fixes a couple of bugs seen in the patch.
Sachin Prabhu (3):
Fix memory leaks in cifs_do_mount()
Compare prepaths when comparing superblocks Move check for prefix path to within cifs_get_root()
fs/cifs/cifsfs.c | 29 ++++++++++++----------------- fs/cifs/cifsproto.h | 2 +- fs/cifs/connect.c | 31 +++++++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 20 deletions(-)
Signature · 1 line
2.5.5
A message that is not in the archive (sent off-list or not yet received): 1469828301-9937-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
PATCH 1/3 Fix memory leaks in cifs_do_mount()
Fix memory leaks introduced by the patch fs/cifs: make share unaccessible at root level mountable
Also move allocation of cifs_sb->prepath to cifs_setup_cifs_sb().
--- fs/cifs/cifsfs.c | 20 ++++++++------------ fs/cifs/cifsproto.h | 2 +- fs/cifs/connect.c | 10 +++++++++- 3 files changed, 18 insertions(+), 14 deletions(-)
fs/cifs/cifsfs.c +8 -12
@@ -686,26 +686,22 @@ cifs_do_mount(struct file_system_type *fs_type, cifs_sb->mountdata =kstrndup (data,PAGE_SIZE ,GFP_KERNEL );if (cifs_sb->mountdata ==NULL ) { root =ERR_PTR (-ENOMEM ); - goto out_cifs_sb; + goto out_free; } -if (volume_info->prepath) { - cifs_sb->prepath =kstrdup (volume_info->prepath,GFP_KERNEL ); -if (cifs_sb->prepath ==NULL ) { - root =ERR_PTR (-ENOMEM ); - goto out_cifs_sb; - } + rc =cifs_setup_cifs_sb (volume_info, cifs_sb); +if (rc) { + root =ERR_PTR (rc); + goto out_free; } -cifs_setup_cifs_sb (volume_info, cifs_sb); - rc =cifs_mount (cifs_sb, volume_info);if (rc) {if (!(flags &MS_SILENT ))cifs_dbg (VFS ,"cifs_mount failed w/return code = %d\n" , rc); root =ERR_PTR (rc); - goto out_mountdata; + goto out_free; } mnt_data.vol = volume_info;
@@ -752,9 +748,9 @@ out:cifs_cleanup_volume_info (volume_info);return root; -out_mountdata: +out_free: +kfree (cifs_sb->prepath);kfree (cifs_sb->mountdata); -out_cifs_sb:kfree (cifs_sb); out_nls:unload_nls (volume_info->local_nls);
fs/cifs/cifsproto.h +1 -1
@@ -184,7 +184,7 @@ extern int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, unsigned int to_read);extern int cifs_read_page_from_socket (struct TCP_Server_Info *server,struct page *page,unsigned int to_read); -extern void cifs_setup_cifs_sb (struct smb_vol *pvolume_info, +extern int cifs_setup_cifs_sb (struct smb_vol *pvolume_info,struct cifs_sb_info *cifs_sb);extern int cifs_match_super (struct super_block *,void *);extern void cifs_cleanup_volume_info (struct smb_vol *pvolume_info);
fs/cifs/connect.c +9 -1
@@ -3222,7 +3222,7 @@ void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon, } } -void cifs_setup_cifs_sb (struct smb_vol *pvolume_info, +int cifs_setup_cifs_sb (struct smb_vol *pvolume_info,struct cifs_sb_info *cifs_sb) {INIT_DELAYED_WORK (&cifs_sb->prune_tlinks, cifs_prune_tlinks);
@@ -3316,6 +3316,14 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info,if ((pvolume_info->cifs_acl) && (pvolume_info->dynperm))cifs_dbg (VFS ,"mount option dynperm ignored if cifsacl mount option supported\n" ); + +if (pvolume_info->prepath) { + cifs_sb->prepath =kstrdup (pvolume_info->prepath,GFP_KERNEL ); +if (cifs_sb->prepath ==NULL ) +return -ENOMEM ; + } + +return 0 ; } static void
Signature · 1 line
2.5.5
PATCH 2/3 Compare prepaths when comparing superblocks
In reply to a message not in the archiveThe 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.
--- fs/cifs/connect.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
fs/cifs/connect.c +20 -1
@@ -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) {
@@ -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; }
Signature · 1 line
2.5.5
PATCH 3/3 Move check for prefix path to within cifs_get_root()
In reply to a message not in the archive--- fs/cifs/cifsfs.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
fs/cifs/cifsfs.c +4 -5
@@ -609,6 +609,9 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)char *s, *p;char sep; +if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_USE_PREFIX_PATH ) +return dget (sb->s_root); + full_path =cifs_build_path_to_root (vol, cifs_sb,cifs_sb_master_tcon (cifs_sb));if (full_path ==NULL )
@@ -731,11 +734,7 @@ cifs_do_mount(struct file_system_type *fs_type, sb->s_flags |=MS_ACTIVE ; } -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_USE_PREFIX_PATH ) - root =dget (sb->s_root); -else - root =cifs_get_root (volume_info, sb); - + root =cifs_get_root (volume_info, sb);if (IS_ERR (root)) goto out_super;
Signature · 1 line
2.5.5
Quoted 4 lines · On Fri, 29 Jul 2016 22:38:18 +0100 Sachin Prabhu…
The fix for unaccessible root with summary
"fs/cifs: make share unaccessible at root level mountable" introduces a few bugs. This series of patches cleans up some parts of the code and also fixes a couple of bugs seen in the patch.
Good catch. Thanks for the cleanup!
Signature · 5 lines
Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
Aurélien Aptel
Tested-byQuoted 10 lines · On Fri, 29 Jul 2016 22:38:18 +0100 Sachin Prabhu…
The fix for unaccessible root with summary
"fs/cifs: make share unaccessible at root level mountable" introduces a few bugs. This series of patches cleans up some parts of the code and also fixes a couple of bugs seen in the patch.Sachin Prabhu (3):
Fix memory leaks incifs_do_mount()
Compare prepaths when comparing superblocks Move check for prefix path to withincifs_get_root()
Quoted 5 lines
fs/cifs/cifsfs.c | 29 ++++++++++++----------------- fs/cifs/cifsproto.h | 2 +- fs/cifs/connect.c | 31 +++++++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 20 deletions(-)
I've tested it, I can confirm it works as the original patch intended.
Signature · 5 lines
Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
Steve French
Appliedmerged into cifs-2.6.git for-next
Quoted 28 lines · Aurélien Aptel
Quoted 10 lines · On Fri, 29 Jul 2016 22:38:18 +0100 Sachin Prabhu…
The fix for unaccessible root with summary
"fs/cifs: make share unaccessible at root level mountable" introduces a few bugs. This series of patches cleans up some parts of the code and also fixes a couple of bugs seen in the patch.Sachin Prabhu (3):
Fix memory leaks incifs_do_mount()
Compare prepaths when comparing superblocks Move check for prefix path to withincifs_get_root()Quoted 5 lines
fs/cifs/cifsfs.c | 29 ++++++++++++----------------- fs/cifs/cifsproto.h | 2 +- fs/cifs/connect.c | 31 +++++++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 20 deletions(-)I've tested it, I can confirm it works as the original patch intended.
--
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
Signature · 3 lines
Thanks, Steve