Received: by 10.192.165.148 with SMTP id m20csp3064456imm; Mon, 7 May 2018 06:07:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq5C9fn4LEU7X0gbN9CfY8UHASQ2e7V0ep/LpkUNa/c8/sX3AMEJsCjtx8NrmeWtGlTKySV X-Received: by 2002:a65:4306:: with SMTP id j6-v6mr11240627pgq.341.1525698428102; Mon, 07 May 2018 06:07:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525698428; cv=none; d=google.com; s=arc-20160816; b=ewSUhqMEvQvEjohrluZ7qijya79lqcoUONCJviWDE28FQP0D/NylTtCpehMkpAUgJO gvV3xG/AX9PjR9VW5ZH76S35z/6G5XSR6bx4aiZMJFzB0ZOQxBr9h/bYVjp3K9LG0QxE t09nBj+JdkgPVOqPzf9H4nBe3rRcAmHSZ3lN4rlzbZDlAAxx9QDO1kMUJKBp9cieJXVP R1i0cOn+KH+h+3Z4vUKUYV9T6VxDnaWJ6SsMDn3lXb4n8JRO8RfYdfTQL/ipW2IC1Myq 0iJVjnSIj+DmNoUeyUxwy8OYq42XLOftWICeby2+HabpYIxXAtQXMbQNF3I83TMRSim4 sZ/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=u4M5Eh9O5B/5WE/XJjIJee9iijifsxH5Ndu53q1uKTQ=; b=dsIcWOQP2NqvOJXQA2M+ZADDYwAHZvg9h+/3uFjIvRAQY+7CZ9h11GBCqIx2z6qRZA KtaVK4hDhTiKFodoL+ZrZVXnToMvSJafnXI06/QhyznLM3KrK5pHjt8DgE8zjAH2MFIJ l2XfyT80re4kjfZOPXZiAVFvAO6GGHu8yxEvC4ZiXPrJ7iqfvnm4cUo0p8nEAOfiL4i8 t6VIXOHRJadqqSdHw+lehIv6kBX+Oimmn48nYzbZ9BC63J0+tj22lQo6tx6Ft6ksW6ow xbn1WnAxvdvBoieFX0m6w83Q5sO4NEnw+gxxktkCKxMD2VgWVZ1hzZjo4I4YrlLrMIJW 6xtg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x12-v6si18930138pln.97.2018.05.07.06.06.52; Mon, 07 May 2018 06:07:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752418AbeEGNDb (ORCPT + 99 others); Mon, 7 May 2018 09:03:31 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43630 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752248AbeEGND1 (ORCPT ); Mon, 7 May 2018 09:03:27 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 308E181A8B88; Mon, 7 May 2018 13:03:27 +0000 (UTC) Received: from redhat.com (ovpn-123-58.rdu2.redhat.com [10.10.123.58]) by smtp.corp.redhat.com (Postfix) with SMTP id AD5C27C57; Mon, 7 May 2018 13:03:25 +0000 (UTC) Date: Mon, 7 May 2018 16:03:25 +0300 From: "Michael S. Tsirkin" To: Kevin Easton Cc: Jason Wang , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [PATCH net] vhost: Use kzalloc() to allocate vhost_msg_node Message-ID: <20180507155534-mutt-send-email-mst@kernel.org> References: <000000000000a5b2b1056a86e98c@google.com> <20180427154502.GA22544@la.guarana.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180427154502.GA22544@la.guarana.org> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 07 May 2018 13:03:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 07 May 2018 13:03:27 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 27, 2018 at 11:45:02AM -0400, Kevin Easton wrote: > The struct vhost_msg within struct vhost_msg_node is copied to userspace, > so it should be allocated with kzalloc() to ensure all structure padding > is zeroed. > > Signed-off-by: Kevin Easton > Reported-by: syzbot+87cfa083e727a224754b@syzkaller.appspotmail.com > --- > drivers/vhost/vhost.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index f3bd8e9..1b84dcff 100644 > --- a/drivers/vhost/vhost.c > +++ b/drivers/vhost/vhost.c > @@ -2339,7 +2339,7 @@ EXPORT_SYMBOL_GPL(vhost_disable_notify); > /* Create a new message. */ > struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type) > { > - struct vhost_msg_node *node = kmalloc(sizeof *node, GFP_KERNEL); > + struct vhost_msg_node *node = kzalloc(sizeof *node, GFP_KERNEL); > if (!node) > return NULL; > node->vq = vq; Let's just init the msg though. OK it seems this is the best we can do for now, we need a new feature bit to fix it for 32 bit userspace on 64 bit kernels. Does the following help? Signed-off-by: Michael S. Tsirkin diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index f3bd8e9..58d9aec 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -2342,6 +2342,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;