virtiofs: use string format specifier for sysfs tag
Subsystems (3)
PATCH v2 1/1 virtiofs: use string format specifier for sysfs tag
The existing emit call is a vector for format string injection. Use the string format specifier to avoid this problem.
---
v2:
- Drop newline.
v1: https://lore.kernel.org/linux-fsdevel/[email protected]/
fs/fuse/virtio_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/virtio_fs.c +1 -1
@@ -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" , fs->tag); }static struct kobj_attribute virtio_fs_tag_attr =__ATTR_RO (tag);
Signature · 1 line
2.44.0
Stefan Hajnoczi
maintainerQuoted 19 lines · Brian Foster
The existing emit call is a vector for format string injection. Use the string format specifier to avoid this problem.
Reported-by Stefan Hajnoczi <[email protected]>Signed-off-by Brian Foster <[email protected]>---
v2:
- Drop newline.
v1: https://lore.kernel.org/linux-fsdevel/[email protected]/fs/fuse/virtio_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/fuse/virtio_fs.c +0
-0
fs/fuse/virtio_fs.c static ssize_t tag_show(struct kobject *kobj, · line 174
Quoted 6 lines
fs/fuse/virtio_fs.c +1
-1@@ -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" , fs->tag); }
Miklos: Would it be possible to change the format string to "%s\n" (with a newline) in this patch and merged for v6.9?
v6.9 will be the first kernel release with this new sysfs attr and I'd like to get the formatting right. Once a kernel is released I would rather not change the sysfs attr's format to avoid breaking userspace, hence the urgency.
Thank you,
Stefan
Quoted 30 lines · Stefan Hajnoczi
Quoted 19 lines · Brian Foster
The existing emit call is a vector for format string injection. Use the string format specifier to avoid this problem.
Reported-by Stefan Hajnoczi <[email protected]>Signed-off-by Brian Foster <[email protected]>---
v2:
- Drop newline.
v1: https://lore.kernel.org/linux-fsdevel/[email protected]/fs/fuse/virtio_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/fuse/virtio_fs.c +0
-0fs/fuse/virtio_fs.c static ssize_t tag_show(struct kobject *kobj, · line 174
Quoted 6 lines
fs/fuse/virtio_fs.c +1
-1@@ -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" , fs->tag); }Miklos: Would it be possible to change the format string to "%s\n" (with a newline) in this patch and merged for v6.9?
Quoted 5 lines
v6.9 will be the first kernel release with this new sysfs attr and I'd like to get the formatting right. Once a kernel is released I would rather not change the sysfs attr's format to avoid breaking userspace, hence the urgency.
It might be worth including the following tag in this as well:
... re: the discussion on v1.
I'd also advocate for including the newline either way, but again I defer to Stefan if he feels strongly about it. FWIW, if we do go that route I can also send a v3 with the tag and combined v1/v2 commit log if that is helpful.
Brian
Quoted 2 lines
Thank you,
Stefan
Quoted 5 lines · Brian Foster
The existing emit call is a vector for format string injection. Use the string format specifier to avoid this problem.
Reported-by Stefan Hajnoczi <[email protected]>Signed-off-by Brian Foster <[email protected]>
Quoted 8 lines
---
v2:
- Drop newline.
v1: https://lore.kernel.org/linux-fsdevel/[email protected]/fs/fuse/virtio_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)