Message ID | 20180607183627-mutt-send-email-mst@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Jun 7, 2018 at 5:38 PM, Michael S. Tsirkin <mst@redhat.com> wrote: > #syz test: https://github.com/google/kmsan.git/master d2d741e5d1898dfde1a75ea3d29a9a3e2edf0617 Hi Michael, We need: #syz test: https://github.com/google/kmsan.git master here. Please see https://github.com/google/syzkaller/blob/master/docs/syzbot.md#testing-patches for more info. Please also add the Reported-by tag when mailing the patch for review. Thanks > Subject: vhost: fix info leak > > Fixes: CVE-2018-1118 > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > --- > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index f0be5f35ab28..9beefa6ed1ce 100644 > --- a/drivers/vhost/vhost.c > +++ b/drivers/vhost/vhost.c > @@ -2345,6 +2345,9 @@ struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type) > struct vhost_msg_node *node = kmalloc(sizeof *node, GFP_KERNEL); > if (!node) > return NULL; > + > + /* Make sure all padding within the structure is initialized. */ > + memset(&node->msg, 0, sizeof node->msg); > node->vq = vq; > node->msg.type = type; > return node; > > -- > You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group. > To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/20180607183627-mutt-send-email-mst%40kernel.org. > For more options, visit https://groups.google.com/d/optout.
Hello, syzbot has tested the proposed patch and the reproducer did not trigger crash: Reported-and-tested-by: syzbot+87cfa083e727a224754b@syzkaller.appspotmail.com Tested on: commit: c6a6aed994b6 kmsan: remove dead code to trigger syzbot build git tree: https://github.com/google/kmsan.git/master kernel config: https://syzkaller.appspot.com/x/.config?x=848e40757852af3e compiler: clang version 7.0.0 (trunk 334104) patch: https://syzkaller.appspot.com/x/patch.diff?x=17dc3a8f800000 Note: testing is done by a robot and is best-effort only.
On Thu, Jun 07, 2018 at 06:38:48PM +0300, Michael S. Tsirkin wrote: > #syz test: https://github.com/google/kmsan.git/master d2d741e5d1898dfde1a75ea3d29a9a3e2edf0617 > > Subject: vhost: fix info leak > > Fixes: CVE-2018-1118 > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > --- > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index f0be5f35ab28..9beefa6ed1ce 100644 > --- a/drivers/vhost/vhost.c > +++ b/drivers/vhost/vhost.c > @@ -2345,6 +2345,9 @@ struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type) > struct vhost_msg_node *node = kmalloc(sizeof *node, GFP_KERNEL); > if (!node) > return NULL; > + > + /* Make sure all padding within the structure is initialized. */ > + memset(&node->msg, 0, sizeof node->msg); Umm... Maybe kzalloc(), then? You have struct vhost_msg_node { struct vhost_msg msg; struct vhost_virtqueue *vq; struct list_head node; }; and that's what, 68 bytes in msg, then either 4 bytes pointer or 4 bytes padding + 8 bytes pointer, then two pointers? How much does explicit partial memset() save you here? > node->vq = vq; > node->msg.type = type; > return node;
On Thu, Jun 07, 2018 at 06:43:55PM +0100, Al Viro wrote: > On Thu, Jun 07, 2018 at 06:38:48PM +0300, Michael S. Tsirkin wrote: > > #syz test: https://github.com/google/kmsan.git/master d2d741e5d1898dfde1a75ea3d29a9a3e2edf0617 > > > > Subject: vhost: fix info leak > > > > Fixes: CVE-2018-1118 > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > > --- > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > > index f0be5f35ab28..9beefa6ed1ce 100644 > > --- a/drivers/vhost/vhost.c > > +++ b/drivers/vhost/vhost.c > > @@ -2345,6 +2345,9 @@ struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type) > > struct vhost_msg_node *node = kmalloc(sizeof *node, GFP_KERNEL); > > if (!node) > > return NULL; > > + > > + /* Make sure all padding within the structure is initialized. */ > > + memset(&node->msg, 0, sizeof node->msg); > > Umm... Maybe kzalloc(), then? You have > > struct vhost_msg_node { > struct vhost_msg msg; > struct vhost_virtqueue *vq; > struct list_head node; > }; > > and that's what, 68 bytes in msg, then either 4 bytes pointer or > 4 bytes padding + 8 bytes pointer, then two pointers? How much > does explicit partial memset() save you here? Yes but 0 isn't a nop here so if this struct is used without a sensible initialization, it will crash elsewhere. I prefer KASAN to catch such uses. > > node->vq = vq; > > node->msg.type = type; > > return node;
On Thu, Jun 07, 2018 at 08:59:06PM +0300, Michael S. Tsirkin wrote: > On Thu, Jun 07, 2018 at 06:43:55PM +0100, Al Viro wrote: > > On Thu, Jun 07, 2018 at 06:38:48PM +0300, Michael S. Tsirkin wrote: > > > #syz test: https://github.com/google/kmsan.git/master d2d741e5d1898dfde1a75ea3d29a9a3e2edf0617 > > > > > > Subject: vhost: fix info leak > > > > > > Fixes: CVE-2018-1118 > > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > > > --- > > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > > > index f0be5f35ab28..9beefa6ed1ce 100644 > > > --- a/drivers/vhost/vhost.c > > > +++ b/drivers/vhost/vhost.c > > > @@ -2345,6 +2345,9 @@ struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type) > > > struct vhost_msg_node *node = kmalloc(sizeof *node, GFP_KERNEL); > > > if (!node) > > > return NULL; > > > + > > > + /* Make sure all padding within the structure is initialized. */ > > > + memset(&node->msg, 0, sizeof node->msg); > > > > Umm... Maybe kzalloc(), then? You have > > > > struct vhost_msg_node { > > struct vhost_msg msg; > > struct vhost_virtqueue *vq; > > struct list_head node; > > }; > > > > and that's what, 68 bytes in msg, then either 4 bytes pointer or > > 4 bytes padding + 8 bytes pointer, then two pointers? How much > > does explicit partial memset() save you here? > > Yes but 0 isn't a nop here so if this struct is used without > a sensible initialization, it will crash elsewhere. > I prefer KASAN to catch such uses. > > > > > node->vq = vq; > > > node->msg.type = type; IDGI - what would your variant catch that kzalloc + 2 assignments won't? Accesses to uninitialized ->node? Because that's the only difference in what is and is not initialized between those variants...
On Thu, Jun 07, 2018 at 07:04:49PM +0100, Al Viro wrote: > On Thu, Jun 07, 2018 at 08:59:06PM +0300, Michael S. Tsirkin wrote: > > On Thu, Jun 07, 2018 at 06:43:55PM +0100, Al Viro wrote: > > > On Thu, Jun 07, 2018 at 06:38:48PM +0300, Michael S. Tsirkin wrote: > > > > #syz test: https://github.com/google/kmsan.git/master d2d741e5d1898dfde1a75ea3d29a9a3e2edf0617 > > > > > > > > Subject: vhost: fix info leak > > > > > > > > Fixes: CVE-2018-1118 > > > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > > > > --- > > > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > > > > index f0be5f35ab28..9beefa6ed1ce 100644 > > > > --- a/drivers/vhost/vhost.c > > > > +++ b/drivers/vhost/vhost.c > > > > @@ -2345,6 +2345,9 @@ struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type) > > > > struct vhost_msg_node *node = kmalloc(sizeof *node, GFP_KERNEL); > > > > if (!node) > > > > return NULL; > > > > + > > > > + /* Make sure all padding within the structure is initialized. */ > > > > + memset(&node->msg, 0, sizeof node->msg); > > > > > > Umm... Maybe kzalloc(), then? You have > > > > > > struct vhost_msg_node { > > > struct vhost_msg msg; > > > struct vhost_virtqueue *vq; > > > struct list_head node; > > > }; > > > > > > and that's what, 68 bytes in msg, then either 4 bytes pointer or > > > 4 bytes padding + 8 bytes pointer, then two pointers? How much > > > does explicit partial memset() save you here? > > > > Yes but 0 isn't a nop here so if this struct is used without > > a sensible initialization, it will crash elsewhere. > > I prefer KASAN to catch such uses. > > > > > > > > node->vq = vq; > > > > node->msg.type = type; > > IDGI - what would your variant catch that kzalloc + 2 assignments won't? > Accesses to uninitialized ->node? Because that's the only difference in > what is and is not initialized between those variants... For now yes but we'll likely add more fields in this structure down the road, which is where I'd expect new bugs to come from.
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index f0be5f35ab28..9beefa6ed1ce 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -2345,6 +2345,9 @@ struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type) struct vhost_msg_node *node = kmalloc(sizeof *node, GFP_KERNEL); if (!node) return NULL; + + /* Make sure all padding within the structure is initialized. */ + memset(&node->msg, 0, sizeof node->msg); node->vq = vq; node->msg.type = type; return node;
#syz test: https://github.com/google/kmsan.git/master d2d741e5d1898dfde1a75ea3d29a9a3e2edf0617 Subject: vhost: fix info leak Fixes: CVE-2018-1118 Signed-off-by: Michael S. Tsirkin <mst@redhat.com> ---