Re: [RFC] does # really need to be escaped in devnames?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2 Sept 2025 at 10:48, David Howells <dhowells@xxxxxxxxxx> wrote:
>
> The problem with that is that it appears that people are making use of this.

Ok. So disallowing it isn't in the cards, but let's try to minimize the impact.

> The standard format of AFS volume names is [%#][<cell>:]<volume-name-or-id>
> but I could make it an option to stick something on the front and use that
> internally and display that in /proc/mounts, e.g.:
>
>         mount afs:#openafs.org:afs.root /mnt

Yeah, let's aim for trying to avoid the '#' at the beginning when all
possible, by trying to make at least the default formats not start
with a hash.

And then make the escaping logic only escape the hashmark if it's the
first character.

> I don't think there should be a problem with still accepting lines beginning
> with '#' in mount() if I display them with an appropriate prefix.  That would
> at least permit backward compatibility.

Well, right now we obviously escape it everywhere, but how about we
make it the rule that 'show_devname()' at least doesn't use it as the
first character, and then if somebody uses '#' for the mount name from
user space, we would just do the octal-escape then.

Something ENTIRELY UNTESTED like this, in other words?

                Linus
 fs/afs/super.c      | 2 +-
 fs/proc_namespace.c | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/afs/super.c b/fs/afs/super.c
index da407f2d6f0d..31f9cc30ae23 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -180,7 +180,7 @@ static int afs_show_devname(struct seq_file *m, struct dentry *root)
 		break;
 	}
 
-	seq_printf(m, "%c%s:%s%s", pref, cell->name, volume->name, suf);
+	seq_printf(m, "afs-%c%s:%s%s", pref, cell->name, volume->name, suf);
 	return 0;
 }
 
diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c
index 5c555db68aa2..ca5773bfb98e 100644
--- a/fs/proc_namespace.c
+++ b/fs/proc_namespace.c
@@ -86,7 +86,7 @@ static void show_vfsmnt_opts(struct seq_file *m, struct vfsmount *mnt)
 
 static inline void mangle(struct seq_file *m, const char *s)
 {
-	seq_escape(m, s, " \t\n\\#");
+	seq_escape(m, s, " \t\n\\");
 }
 
 static void show_type(struct seq_file *m, struct super_block *sb)
@@ -111,7 +111,12 @@ static int show_vfsmnt(struct seq_file *m, struct vfsmount *mnt)
 		if (err)
 			goto out;
 	} else {
-		mangle(m, r->mnt_devname);
+		const char *mnt_devname = r->mnt_devname;
+		if (*mnt_devname == '#') {
+			seq_printf(m, "\\%o", '#');
+			mnt_devname++;
+		}
+		mangle(m, mnt_devname);
 	}
 	seq_putc(m, ' ');
 	/* mountpoints outside of chroot jail will give SEQ_SKIP on this */

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux