[PATCH] afs_show_devname: escape whitespace in cell or volume names

Matthias Gerstner matthias.gerstner at suse.de
Mon Nov 7 06:10:30 PST 2022


To protect userspace from parsing errors due to whitespace in the device
name make sure the variable cell and volume names are escaped
accordingly.

Signed-off-by: Matthias Gerstner <matthias.gerstner at suse.de>
---
 fs/afs/super.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/afs/super.c b/fs/afs/super.c
index 95d713074dc8..d63202f37fc3 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -180,7 +180,12 @@ 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);
+	// [pref][cell]:[volume][suf]
+	seq_putc(m, pref);
+	seq_escape(m, cell->name, " \t\n\\");
+	seq_putc(m, ':');
+	seq_escape(m, volume->name, " \t\n\\");
+	seq_puts(m, suf);
 	return 0;
 }
 
-- 
2.37.3




More information about the linux-afs mailing list