mainline inclusion from mainline-v6.10 commit 96d88f65adfbcaca153afd7d3e20d74ba379c599 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IB81UH
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
-------------------------------------------------
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 Signed-off-by: Shuai Wu wushuai51@huawei.com --- fs/fuse/virtio_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index 62a446037..5083e3f8f 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -169,7 +169,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);