Skip to content

Commit

Permalink
virtiofs: include a newline in sysfs tag
Browse files Browse the repository at this point in the history
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: a8f62f5 ("virtiofs: export filesystem tags through sysfs")
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
  • Loading branch information
Brian Foster authored and Miklos Szeredi committed May 8, 2024
1 parent aef8acd commit 96d88f6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/fuse/virtio_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 96d88f6

Please sign in to comment.