Skip to contentSkip to conversation

cifs: escape spaces in share names

PATCH In review Maciek Borzecki 2 participants 2 messages Apr 6, 2021 – Apr 7, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: escape spaces in share names

Commit 653a5efb849a ("cifs: update super_operations to show_devname") introduced the display of devname for cifs mounts. However, when mounting a share which has a whitespace in the name, that exact share name is also displayed in mountinfo. Make sure that all whitespace is escaped.

---
 fs/cifs/cifsfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cifs/cifsfs.c +2 -1
index 099ad9f3660bb28db1b6a9aea9538282b41c6455..3c6cb85b95e207df222248f10cc9df937cdda24e 100644
@@ -476,7 +476,8 @@ static int cifs_show_devname(struct seq_file *m, struct dentry *root)
 		seq_puts(m, "none");
 	else {
 		convert_delimiter(devname, '/');
-		seq_puts(m, devname);
+		/* escape all spaces in share names */
+		seq_escape(m, devname, " ");
 		kfree(devname);
 	}
 	return 0;
Signature · 1 line
2.31.1
Reviewed-by Shyam Prasad N on v1 1/1
#1 lore raw

Good catch - added one other minor thing, whitespace in share name could be a space or a tab, so changed that line to:

+ seq_escape(m, devname, " \t");

from
+ seq_escape(m, devname, " ");

Quoted 28 lines · Maciek Borzecki

Commit 653a5efb849a ("cifs: update super_operations to show_devname") introduced the display of devname for cifs mounts. However, when mounting a share which has a whitespace in the name, that exact share name is also displayed in mountinfo. Make sure that all whitespace is escaped.

---
 fs/cifs/cifsfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cifs/cifsfs.c +2 -2
index 099ad9f3660bb28db1b6a9aea9538282b41c6455..3c6cb85b95e207df222248f10cc9df937cdda24e 100644
@@ -476,7 +476,8 @@ static int cifs_show_devname(struct seq_file *m, struct dentry *root)
                seq_puts(m, "none");
        else {
                convert_delimiter(devname, '/');
-               seq_puts(m, devname);
+               /* escape all spaces in share names */
+               seq_escape(m, devname, " ");
                kfree(devname);
        }
        return 0;
--

2.31.1

Signature · 3 lines
Thanks,

Steve

From 1ee4f33ffa830267d324b0d547facd25dd683a12 Mon Sep 17 00:00:00 2001
From: Maciek Borzecki <[email protected]>
Date: Tue, 6 Apr 2021 17:02:29 +0200
Subject: [PATCH] cifs: escape spaces in share names

Commit 653a5efb849a ("cifs: update super_operations to show_devname") introduced the display of devname for cifs mounts. However, when mounting a share which has a whitespace in the name, that exact share name is also displayed in mountinfo. Make sure that all whitespace is escaped.

---
 fs/cifs/cifsfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cifs/cifsfs.c +2 -1
index 099ad9f3660b..3c6cb85b95e2 100644
@@ -476,7 +476,8 @@ static int cifs_show_devname(struct seq_file *m, struct dentry *root)
 		seq_puts(m, "none");
 	else {
 		convert_delimiter(devname, '/');
-		seq_puts(m, devname);
+		/* escape all spaces in share names */
+		seq_escape(m, devname, " \t");
 		kfree(devname);
 	}
 	return 0;
Signature · 1 line
2.27.0