All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] bug fixes and code cleanups for inaccessible root patch
@ 2016-07-29 21:38 Sachin Prabhu
       [not found] ` <1469828301-9937-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Sachin Prabhu @ 2016-07-29 21:38 UTC (permalink / raw)
  To: linux-cifs; +Cc: Steve French, Aurélien Aptel, Pavel Shilovsky

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(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] Fix memory leaks in cifs_do_mount()
       [not found] ` <1469828301-9937-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2016-07-29 21:38   ` Sachin Prabhu
  2016-07-29 21:38   ` [PATCH 2/3] Compare prepaths when comparing superblocks Sachin Prabhu
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Sachin Prabhu @ 2016-07-29 21:38 UTC (permalink / raw)
  To: linux-cifs; +Cc: Steve French, Aurélien Aptel, Pavel Shilovsky

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().

Signed-off-by: Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 fs/cifs/cifsfs.c    | 20 ++++++++------------
 fs/cifs/cifsproto.h |  2 +-
 fs/cifs/connect.c   | 10 +++++++++-
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 6bbec5e..cc9cdab 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -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);
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 1243bd3..95dab43 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -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);
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 7ae0328..4546926 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -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
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] Compare prepaths when comparing superblocks
       [not found] ` <1469828301-9937-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2016-07-29 21:38   ` [PATCH 1/3] Fix memory leaks in cifs_do_mount() Sachin Prabhu
@ 2016-07-29 21:38   ` Sachin Prabhu
  2016-07-29 21:38   ` [PATCH 3/3] Move check for prefix path to within cifs_get_root() Sachin Prabhu
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Sachin Prabhu @ 2016-07-29 21:38 UTC (permalink / raw)
  To: linux-cifs; +Cc: Steve French, Aurélien Aptel, Pavel Shilovsky

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 <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 fs/cifs/connect.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 4546926..2e4f4ba 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -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;
 	}
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] Move check for prefix path to within cifs_get_root()
       [not found] ` <1469828301-9937-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2016-07-29 21:38   ` [PATCH 1/3] Fix memory leaks in cifs_do_mount() Sachin Prabhu
  2016-07-29 21:38   ` [PATCH 2/3] Compare prepaths when comparing superblocks Sachin Prabhu
@ 2016-07-29 21:38   ` Sachin Prabhu
  2016-08-01  7:56   ` [PATCH 0/3] bug fixes and code cleanups for inaccessible root patch Aurélien Aptel
  2016-08-03 13:25   ` Aurélien Aptel
  4 siblings, 0 replies; 7+ messages in thread
From: Sachin Prabhu @ 2016-07-29 21:38 UTC (permalink / raw)
  To: linux-cifs; +Cc: Steve French, Aurélien Aptel, Pavel Shilovsky

Signed-off-by: Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 fs/cifs/cifsfs.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index cc9cdab..14ae4b8 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -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;
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] bug fixes and code cleanups for inaccessible root patch
       [not found] ` <1469828301-9937-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
                     ` (2 preceding siblings ...)
  2016-07-29 21:38   ` [PATCH 3/3] Move check for prefix path to within cifs_get_root() Sachin Prabhu
@ 2016-08-01  7:56   ` Aurélien Aptel
  2016-08-03 13:25   ` Aurélien Aptel
  4 siblings, 0 replies; 7+ messages in thread
From: Aurélien Aptel @ 2016-08-01  7:56 UTC (permalink / raw)
  To: Sachin Prabhu; +Cc: linux-cifs, Steve French, Pavel Shilovsky

[-- Attachment #1: Type: text/plain, Size: 637 bytes --]

On Fri, 29 Jul 2016 22:38:18 +0100 Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
wrote:
> 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!

-- 
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)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] bug fixes and code cleanups for inaccessible root patch
       [not found] ` <1469828301-9937-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
                     ` (3 preceding siblings ...)
  2016-08-01  7:56   ` [PATCH 0/3] bug fixes and code cleanups for inaccessible root patch Aurélien Aptel
@ 2016-08-03 13:25   ` Aurélien Aptel
  2016-08-03 21:54     ` Steve French
  4 siblings, 1 reply; 7+ messages in thread
From: Aurélien Aptel @ 2016-08-03 13:25 UTC (permalink / raw)
  To: Sachin Prabhu; +Cc: linux-cifs, Steve French, Pavel Shilovsky

[-- Attachment #1: Type: text/plain, Size: 1128 bytes --]

On Fri, 29 Jul 2016 22:38:18 +0100 Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
wrote:
> 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(-)
> 

I've tested it, I can confirm it works as the original patch intended.

Tested-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org>

-- 
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)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] bug fixes and code cleanups for inaccessible root patch
  2016-08-03 13:25   ` Aurélien Aptel
@ 2016-08-03 21:54     ` Steve French
  0 siblings, 0 replies; 7+ messages in thread
From: Steve French @ 2016-08-03 21:54 UTC (permalink / raw)
  To: Aurélien Aptel; +Cc: Sachin Prabhu, linux-cifs, Pavel Shilovsky

merged into cifs-2.6.git for-next

On Wed, Aug 3, 2016 at 8:25 AM, Aurélien Aptel <aaptel-IBi9RG/b67k@public.gmane.org> wrote:
> On Fri, 29 Jul 2016 22:38:18 +0100 Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> wrote:
>> 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(-)
>>
>
> I've tested it, I can confirm it works as the original patch intended.
>
> Tested-by: Aurelien Aptel <aaptel-IBi9RG/b67k@public.gmane.org>
>
> --
> 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)



-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-08-03 21:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-29 21:38 [PATCH 0/3] bug fixes and code cleanups for inaccessible root patch Sachin Prabhu
     [not found] ` <1469828301-9937-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-07-29 21:38   ` [PATCH 1/3] Fix memory leaks in cifs_do_mount() Sachin Prabhu
2016-07-29 21:38   ` [PATCH 2/3] Compare prepaths when comparing superblocks Sachin Prabhu
2016-07-29 21:38   ` [PATCH 3/3] Move check for prefix path to within cifs_get_root() Sachin Prabhu
2016-08-01  7:56   ` [PATCH 0/3] bug fixes and code cleanups for inaccessible root patch Aurélien Aptel
2016-08-03 13:25   ` Aurélien Aptel
2016-08-03 21:54     ` Steve French

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.