Skip to content

Commit

Permalink
virtiofs: forbid newlines in tags
Browse files Browse the repository at this point in the history
Newlines in virtiofs tags are awkward for users and potential vectors
for string injection attacks.

Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Vivek Goyal <[email protected]>
Signed-off-by: Miklos Szeredi <[email protected]>
  • Loading branch information
stefanhaRH authored and Miklos Szeredi committed Feb 23, 2024
1 parent b401b62 commit 40488cc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fs/fuse/virtio_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 40488cc

Please sign in to comment.