From: Brian Foster Date: Thu, 25 Apr 2024 10:44:00 +0000 (-0400) Subject: virtiofs: include a newline in sysfs tag X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=96d88f65adfbcaca153afd7d3e20d74ba379c599;p=linux.git virtiofs: include a newline in sysfs tag 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 Fixes: a8f62f50b4e4 ("virtiofs: export filesystem tags through sysfs") Signed-off-by: Miklos Szeredi --- diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index 322af827a2329..bb3e941b95031 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -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);