virtiofs: include a newline in sysfs tag
authorBrian Foster <bfoster@redhat.com>
Thu, 25 Apr 2024 10:44:00 +0000 (06:44 -0400)
committerMiklos Szeredi <mszeredi@redhat.com>
Wed, 8 May 2024 07:31:21 +0000 (09:31 +0200)
The internal tag string doesn't contain a newline. Append one when
emitting the tag via sysfs.

[Stefan] Orthogonal to the newline issue, sysfs_emit(buf, "%s", fs->tag) is
needed to prevent format string injection.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Fixes: a8f62f50b4e4 ("virtiofs: export filesystem tags through sysfs")
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/virtio_fs.c

index 322af827a2329f9af0ee445116f1ef84114b2b4c..bb3e941b95031ac199532e6f2057f3df77c2939d 100644 (file)
@@ -170,7 +170,7 @@ static ssize_t tag_show(struct kobject *kobj,
 {
        struct virtio_fs *fs = container_of(kobj, struct virtio_fs, kobj);
 
-       return sysfs_emit(buf, fs->tag);
+       return sysfs_emit(buf, "%s\n", fs->tag);
 }
 
 static struct kobj_attribute virtio_fs_tag_attr = __ATTR_RO(tag);