mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-08 10:25:20 +02:00
virtiofs: forbid newlines in tags
[ Upstream commit 40488cc16f
]
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>
This commit is contained in:
parent
a48d12797e
commit
0b9f748da2
|
@ -323,6 +323,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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user