diff options
| author | Stefan Hajnoczi <stefanha@redhat.com> | 2024-02-12 19:11:47 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-09-04 13:14:55 +0200 |
| commit | 6ca28b54adf3e92f8357cbe663f8b4f02af279c3 (patch) | |
| tree | 5679d9432d4602963bd49dffb1f4b30ca3392b18 /fs/fuse | |
| parent | 5766a74fe6b225c19b5bf9f88ec51088ed18633a (diff) | |
| download | linux-6ca28b54adf3e92f8357cbe663f8b4f02af279c3.tar.gz linux-6ca28b54adf3e92f8357cbe663f8b4f02af279c3.tar.bz2 linux-6ca28b54adf3e92f8357cbe663f8b4f02af279c3.zip | |
virtiofs: forbid newlines in tags
[ Upstream commit 40488cc16f7ea0d193a4e248f0d809c25cc377db ]
Newlines in virtiofs tags are awkward for users and potential vectors
for string injection attacks.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/fuse')
| -rw-r--r-- | fs/fuse/virtio_fs.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index fadf6fb90fe2..48f144d08381 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -237,6 +237,16 @@ static int virtio_fs_read_tag(struct virtio_device *vdev, struct virtio_fs *fs) return -ENOMEM; memcpy(fs->tag, tag_buf, len); fs->tag[len] = '\0'; + + /* While the VIRTIO specification allows any character, newlines are + * awkward on mount(8) command-lines and cause problems in the sysfs + * "tag" attr and uevent TAG= properties. Forbid them. + */ + if (strchr(fs->tag, '\n')) { + dev_dbg(&vdev->dev, "refusing virtiofs tag with newline character\n"); + return -EINVAL; + } + return 0; } |
