1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: "Michael S. Tsirkin" <mst@redhat.com>
3 Date: Thu, 16 Aug 2018 17:02:36 +0800
4 Subject: [PATCH] vhost: fix info leak due to uninitialized memory
8 struct vhost_msg within struct vhost_msg_node is copied to userspace.
9 Unfortunately it turns out on 64 bit systems vhost_msg has padding after
10 type which gcc doesn't initialize, leaking 4 uninitialized bytes to
13 This padding also unfortunately means 32 bit users of this interface are
14 broken on a 64 bit kernel which will need to be fixed separately.
17 Cc: stable@vger.kernel.org
18 Reported-by: Kevin Easton <kevin@guarana.org>
19 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
20 Reported-by: syzbot+87cfa083e727a224754b@syzkaller.appspotmail.com
21 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
22 (cherry picked from commit 670ae9caaca467ea1bfd325cb2a5c98ba87f94ad)
23 Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
24 Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
25 Acked-by: Kamal Mostafa <kamal@canonical.com>
26 Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
27 Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
29 drivers/vhost/vhost.c | 3 +++
30 1 file changed, 3 insertions(+)
32 diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
33 index 31bdfd296ced..a922d3d28a20 100644
34 --- a/drivers/vhost/vhost.c
35 +++ b/drivers/vhost/vhost.c
36 @@ -2383,6 +2383,9 @@ struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type)
37 struct vhost_msg_node *node = kmalloc(sizeof *node, GFP_KERNEL);
41 + /* Make sure all padding within the structure is initialized. */
42 + memset(&node->msg, 0, sizeof node->msg);
44 node->msg.type = type;