diff mbox

cifs: Mangle string used for unc in /proc/mounts

Message ID 1347554937-28369-1-git-send-email-sprabhu@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sachin Prabhu Sept. 13, 2012, 4:48 p.m. UTC
The string for "unc=" in /proc/mounts needs to be escaped. The current
behaviour can create problems in cases when mounting a share starting
with a number.

example:
>mount -t cifs -o username=test,password=x vm140-31:/17000-test /mnt
>mount -o remount,password=x /mnt
mount error: could not resolve address for vm140-31x00-test: Unknown
error

The sub-string "\170" which is part of the unc for the mount above in
/proc/mounts is interpreted as character'x' in the case above. Escaping
the string fixes the problem.

Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
---
 fs/cifs/cifsfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jeff Layton Sept. 13, 2012, 5:42 p.m. UTC | #1
On Thu, 13 Sep 2012 17:48:57 +0100
Sachin Prabhu <sprabhu@redhat.com> wrote:

> The string for "unc=" in /proc/mounts needs to be escaped. The current
> behaviour can create problems in cases when mounting a share starting
> with a number.
> 
> example:
> >mount -t cifs -o username=test,password=x vm140-31:/17000-test /mnt
> >mount -o remount,password=x /mnt
> mount error: could not resolve address for vm140-31x00-test: Unknown
> error
> 
> The sub-string "\170" which is part of the unc for the mount above in
> /proc/mounts is interpreted as character'x' in the case above. Escaping
> the string fixes the problem.
> 
> Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
> ---
>  fs/cifs/cifsfs.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
> index db8a404..2ac02aa 100644
> --- a/fs/cifs/cifsfs.c
> +++ b/fs/cifs/cifsfs.c
> @@ -360,7 +360,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
>  	cifs_show_security(s, tcon->ses->server);
>  	cifs_show_cache_flavor(s, cifs_sb);
>  
> -	seq_printf(s, ",unc=%s", tcon->treeName);
> +	seq_printf(s, ",unc=");
> +	seq_escape(s, tcon->treeName, " \t\n\\");
>  
>  	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)
>  		seq_printf(s, ",multiuser");

Reviewed-by: Jeff Layton <jlayton@redhat.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Steve French Sept. 15, 2012, 8:52 p.m. UTC | #2
---------- Forwarded message ----------
From: Steve French <smfrench@gmail.com>
Date: Sat, Sep 15, 2012 at 3:52 PM
Subject: Re: [PATCH] cifs: Mangle string used for unc in /proc/mounts
To: Sachin Prabhu <sprabhu@redhat.com>
Cc: linux-cifs <linux-cifs@vger.kernel.org>, Jeff Layton
<jlayton@redhat.com>


merged into cifs-2.6.git


On Thu, Sep 13, 2012 at 11:48 AM, Sachin Prabhu <sprabhu@redhat.com> wrote:
>
> The string for "unc=" in /proc/mounts needs to be escaped. The current
> behaviour can create problems in cases when mounting a share starting
> with a number.
>
> example:
> >mount -t cifs -o username=test,password=x vm140-31:/17000-test /mnt
> >mount -o remount,password=x /mnt
> mount error: could not resolve address for vm140-31x00-test: Unknown
> error
>
> The sub-string "\170" which is part of the unc for the mount above in
> /proc/mounts is interpreted as character'x' in the case above. Escaping
> the string fixes the problem.
>
> Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
> ---
>  fs/cifs/cifsfs.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
> index db8a404..2ac02aa 100644
> --- a/fs/cifs/cifsfs.c
> +++ b/fs/cifs/cifsfs.c
> @@ -360,7 +360,8 @@ cifs_show_options(struct seq_file *s, struct dentry
> *root)
>         cifs_show_security(s, tcon->ses->server);
>         cifs_show_cache_flavor(s, cifs_sb);
>
> -       seq_printf(s, ",unc=%s", tcon->treeName);
> +       seq_printf(s, ",unc=");
> +       seq_escape(s, tcon->treeName, " \t\n\\");
>
>         if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)
>                 seq_printf(s, ",multiuser");
> --
> 1.7.11.4
>



--
Thanks,

Steve



--
Thanks,

Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index db8a404..2ac02aa 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -360,7 +360,8 @@  cifs_show_options(struct seq_file *s, struct dentry *root)
 	cifs_show_security(s, tcon->ses->server);
 	cifs_show_cache_flavor(s, cifs_sb);
 
-	seq_printf(s, ",unc=%s", tcon->treeName);
+	seq_printf(s, ",unc=");
+	seq_escape(s, tcon->treeName, " \t\n\\");
 
 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)
 		seq_printf(s, ",multiuser");