Linux-CIFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] cifs: fix crash in cifs_dfs_do_automount
@ 2019-07-11  3:46 Ronnie Sahlberg
  2019-07-12  7:56 ` Aurélien Aptel
  0 siblings, 1 reply; 3+ messages in thread
From: Ronnie Sahlberg @ 2019-07-11  3:46 UTC (permalink / raw)
  To: linux-cifs; +Cc: Steve French, Aurelien Aptel, Paulo Alcantara, Ronnie Sahlberg

RHBZ: 1649907

Fix a crash that happens while attempting to mount a DFS referral from the same server on the root of a filesystem.

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/connect.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 8ad8bbe8003b..9b0f9f346c5b 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -4484,11 +4484,13 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server,
 					unsigned int xid,
 					struct cifs_tcon *tcon,
 					struct cifs_sb_info *cifs_sb,
-					char *full_path)
+					char *full_path,
+					int added_treename)
 {
 	int rc;
 	char *s;
 	char sep, tmp;
+	int skip = added_treename ? 1 : 0;
 
 	sep = CIFS_DIR_SEP(cifs_sb);
 	s = full_path;
@@ -4503,7 +4505,13 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server,
 		/* next separator */
 		while (*s && *s != sep)
 			s++;
-
+		/* if the treename is added, we then have to skip the first
+		 * part within the separators
+		 */
+		if (skip) {
+			skip = 0;
+			continue;
+		}
 		/*
 		 * temporarily null-terminate the path at the end of
 		 * the current component
@@ -4551,8 +4559,7 @@ static int is_path_remote(struct cifs_sb_info *cifs_sb, struct smb_vol *vol,
 
 	if (rc != -EREMOTE) {
 		rc = cifs_are_all_path_components_accessible(server, xid, tcon,
-							     cifs_sb,
-							     full_path);
+			cifs_sb, full_path, tcon->Flags & SMB_SHARE_IS_IN_DFS);
 		if (rc != 0) {
 			cifs_dbg(VFS, "cannot query dirs between root and final path, "
 				 "enabling CIFS_MOUNT_USE_PREFIX_PATH\n");
-- 
2.13.6


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

* Re: [PATCH] cifs: fix crash in cifs_dfs_do_automount
  2019-07-11  3:46 [PATCH] cifs: fix crash in cifs_dfs_do_automount Ronnie Sahlberg
@ 2019-07-12  7:56 ` Aurélien Aptel
  2019-07-13 17:10   ` Steve French
  0 siblings, 1 reply; 3+ messages in thread
From: Aurélien Aptel @ 2019-07-12  7:56 UTC (permalink / raw)
  To: Ronnie Sahlberg, linux-cifs
  Cc: Steve French, Paulo Alcantara, Ronnie Sahlberg

Hi Ronnie,

Ronnie Sahlberg <lsahlber@redhat.com> writes:

> RHBZ: 1649907
>
> Fix a crash that happens while attempting to mount a DFS referral from the same server on the root of a filesystem.
>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
>  fs/cifs/connect.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 8ad8bbe8003b..9b0f9f346c5b 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -4484,11 +4484,13 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server,
>  					unsigned int xid,
>  					struct cifs_tcon *tcon,
>  					struct cifs_sb_info *cifs_sb,
> -					char *full_path)
> +					char *full_path,
> +					int added_treename)
>  {
>  	int rc;
>  	char *s;
>  	char sep, tmp;
> +	int skip = added_treename ? 1 : 0;
>  
>  	sep = CIFS_DIR_SEP(cifs_sb);
>  	s = full_path;
> @@ -4503,7 +4505,13 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server,
>  		/* next separator */
>  		while (*s && *s != sep)
>  			s++;
> -
> +		/* if the treename is added, we then have to skip the first
> +		 * part within the separators
> +		 */

Nitpicking (Steve can probably fix this when he applies) but comment
style should be

/*
 * foo
 */


> +		if (skip) {
> +			skip = 0;
> +			continue;
> +		}
>  		/*
>  		 * temporarily null-terminate the path at the end of
>  		 * the current component
> @@ -4551,8 +4559,7 @@ static int is_path_remote(struct cifs_sb_info *cifs_sb, struct smb_vol *vol,
>  
>  	if (rc != -EREMOTE) {
>  		rc = cifs_are_all_path_components_accessible(server, xid, tcon,
> -							     cifs_sb,
> -							     full_path);
> +			cifs_sb, full_path, tcon->Flags & SMB_SHARE_IS_IN_DFS);

Just FYI this flag is just set in SMB1. Can we test this change in the buildbot?

>  		if (rc != 0) {
>  			cifs_dbg(VFS, "cannot query dirs between root and final path, "
>  				 "enabling CIFS_MOUNT_USE_PREFIX_PATH\n");
> -- 
> 2.13.6
>
>

Cheers,
-- 
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, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg)

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

* Re: [PATCH] cifs: fix crash in cifs_dfs_do_automount
  2019-07-12  7:56 ` Aurélien Aptel
@ 2019-07-13 17:10   ` Steve French
  0 siblings, 0 replies; 3+ messages in thread
From: Steve French @ 2019-07-13 17:10 UTC (permalink / raw)
  To: Aurélien Aptel; +Cc: Ronnie Sahlberg, linux-cifs, Paulo Alcantara

fixed comment and pushed to cifs-2.6.git for-next

On Fri, Jul 12, 2019 at 2:56 AM Aurélien Aptel <aaptel@suse.com> wrote:
>
> Hi Ronnie,
>
> Ronnie Sahlberg <lsahlber@redhat.com> writes:
>
> > RHBZ: 1649907
> >
> > Fix a crash that happens while attempting to mount a DFS referral from the same server on the root of a filesystem.
> >
> > Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> > ---
> >  fs/cifs/connect.c | 15 +++++++++++----
> >  1 file changed, 11 insertions(+), 4 deletions(-)
> >
> > diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> > index 8ad8bbe8003b..9b0f9f346c5b 100644
> > --- a/fs/cifs/connect.c
> > +++ b/fs/cifs/connect.c
> > @@ -4484,11 +4484,13 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server,
> >                                       unsigned int xid,
> >                                       struct cifs_tcon *tcon,
> >                                       struct cifs_sb_info *cifs_sb,
> > -                                     char *full_path)
> > +                                     char *full_path,
> > +                                     int added_treename)
> >  {
> >       int rc;
> >       char *s;
> >       char sep, tmp;
> > +     int skip = added_treename ? 1 : 0;
> >
> >       sep = CIFS_DIR_SEP(cifs_sb);
> >       s = full_path;
> > @@ -4503,7 +4505,13 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server,
> >               /* next separator */
> >               while (*s && *s != sep)
> >                       s++;
> > -
> > +             /* if the treename is added, we then have to skip the first
> > +              * part within the separators
> > +              */
>
> Nitpicking (Steve can probably fix this when he applies) but comment
> style should be
>
> /*
>  * foo
>  */
>
>
> > +             if (skip) {
> > +                     skip = 0;
> > +                     continue;
> > +             }
> >               /*
> >                * temporarily null-terminate the path at the end of
> >                * the current component
> > @@ -4551,8 +4559,7 @@ static int is_path_remote(struct cifs_sb_info *cifs_sb, struct smb_vol *vol,
> >
> >       if (rc != -EREMOTE) {
> >               rc = cifs_are_all_path_components_accessible(server, xid, tcon,
> > -                                                          cifs_sb,
> > -                                                          full_path);
> > +                     cifs_sb, full_path, tcon->Flags & SMB_SHARE_IS_IN_DFS);
>
> Just FYI this flag is just set in SMB1. Can we test this change in the buildbot?
>
> >               if (rc != 0) {
> >                       cifs_dbg(VFS, "cannot query dirs between root and final path, "
> >                                "enabling CIFS_MOUNT_USE_PREFIX_PATH\n");
> > --
> > 2.13.6
> >
> >
>
> Cheers,
> --
> 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, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg)



-- 
Thanks,

Steve

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-11  3:46 [PATCH] cifs: fix crash in cifs_dfs_do_automount Ronnie Sahlberg
2019-07-12  7:56 ` Aurélien Aptel
2019-07-13 17:10   ` Steve French

Linux-CIFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-cifs/0 linux-cifs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-cifs linux-cifs/ https://lore.kernel.org/linux-cifs \
		linux-cifs@vger.kernel.org linux-cifs@archiver.kernel.org
	public-inbox-index linux-cifs


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-cifs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox