Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4049150imm; Tue, 29 May 2018 20:42:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKD2tAUKizODBLxWGhGCyhjlgDaHI7KzTxOsUelkigkcm+5OMf5zqVESYoZAmPBnl9ojpwu X-Received: by 2002:a62:d1a:: with SMTP id v26-v6mr1131415pfi.90.1527651777196; Tue, 29 May 2018 20:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527651777; cv=none; d=google.com; s=arc-20160816; b=EGJx+xvb/qajo3ilW/Vz9Dzzw05EhRwundK+JrN7mVbuIVMqYbcJQcrhEjGZJjLFTh PkN1/RH9e0VtVZSg7Nn/Sa/OTm24AeqgbsjaAv3r+lVg6+s7qCTwrTqR6sVgbYKNbRAj /7zNsbzgNdKsSkrz0M3IFlUqpBwateobWnT1YrY+BV4gLQ5YLhbOppxflYxW4xF2ohzx nLR3NLrxK804QsOPo8MD/Gj/Zzvn9YYnXVvPg/0j/ShgdajnUw5ph4x/Cfa9S+Ji5n5X vhI/LKCyzCDinbeNzcmpJx1/SvwevKpHQpqQxoOEZhAau2HoB1v6p4uEGm3OZqHC1Tr5 EN9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=QqefKrM1GCQKN785ogpLdvOVlZliOH6udKFgkY02iNU=; b=QuOXhi0Qv+b1cYizxIzXZhftIG2ki2CzzdWBCig+2fsoeJKk9zQZ8ETr01Yfebq9dF f/NJjLA2o3g648We+7ZS3dBUEzQAFdSpdrATmkZTfptq9DU4rNL2IVQOyyRC/Ffsp5Aw F+d+l54sgDCKwxqbS/iJz5YXcSJOrsZbfAZ+KXNtcgrYUjSCq5k+kaRcPpPE0I+/haL/ DEQe5kaz3QtJtWHthXLa5ISiXW9wc1Fr56WoY4xLIwycPur1d/kKT2JKETvsOgraatVP ViO1IFwGDVkmwA6+2qxdpgWlW/UUEHLEE7krfZbaUmvTqZAXhDdf6IEabAOa1OmmH6vk KCHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GAUZbtdV; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2-v6si14426095pgp.147.2018.05.29.20.42.42; Tue, 29 May 2018 20:42:57 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GAUZbtdV; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755044AbeE3DmM (ORCPT + 99 others); Tue, 29 May 2018 23:42:12 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:36525 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750885AbeE3DmK (ORCPT ); Tue, 29 May 2018 23:42:10 -0400 Received: by mail-pg0-f65.google.com with SMTP id m5-v6so3123812pgd.3; Tue, 29 May 2018 20:42:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=QqefKrM1GCQKN785ogpLdvOVlZliOH6udKFgkY02iNU=; b=GAUZbtdVquTOWYqhDfgMDG8n2thitKvbPwMztnRWm2dDOjQucox4QOYLwFcELm+lcH HkLVOQYelCiMtECeWr1JEHDT/sHJa2LISlv9iTyKh4BIRnJhbh7Pv38EsTqy/21drOxm bV3bBs5K5WcffxS4/OOilJH0X/lzvz9nGoEu39VGZdIgJWdlPCVOlMYvcC8ZcIVlVpq3 DEwzWm7TED0bXLZ/H9aKxkmY5iAwBHy/BkAUZb8qATeqqO9u+18Cm+IWDtmA5lvsJ98m KXMD9YccK3HutWh5SnQtdtj9DihafP3etj3MIux6Kb0LQiHECqC6QJ6XENF/6TA/XdZ1 GMAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QqefKrM1GCQKN785ogpLdvOVlZliOH6udKFgkY02iNU=; b=U3AxUr5leDxP09BP6bFct1FquDoJYlbVZ80SYnJgjmRjcDI99OrXrhhtucSgzpkAJI ox+71GQNhB63UaMnlGy6biVe3vDYz1aRd05a5Huqm7q3Vi8gkzWnj9rbWAASffVaK5lN /f/5dE633JtQPj5STRK6g/GNVj8aSzI7HIeanNxJSK30pzGKo77pwmtWQWhIRmyyrOxR f/kJrhWp8cwUyV9IQ2AHGd+Aad8zKXkUyo7ZHGQ/bN8Mgty6TafSclpVcziPchRuleku eBtAUbENvFcgVKOAQzvUu3QjVX7UzympRsWViMCoL53TJkr9uhrI5XL2YLMCOUeRKXjL Vt/Q== X-Gm-Message-State: ALKqPwdRnPrnYWm5lYXVNBdlKnDDVkJWyTFEpDqgtvoqSdu6bsqPCK5C zqsm167QGvInCA/TGnVlIIo= X-Received: by 2002:aa7:8051:: with SMTP id y17-v6mr1108049pfm.148.1527651729647; Tue, 29 May 2018 20:42:09 -0700 (PDT) Received: from server.roeck-us.net (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id v16-v6sm57859673pfl.12.2018.05.29.20.42.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 20:42:08 -0700 (PDT) Subject: Re: [net] vhost: Use kzalloc() to allocate vhost_msg_node To: "Michael S. Tsirkin" Cc: Kevin Easton , Jason Wang , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com References: <20180427154502.GA22544@la.guarana.org> <20180529221908.GA22742@roeck-us.net> <20180530055704-mutt-send-email-mst@kernel.org> From: Guenter Roeck Message-ID: <436712fe-c927-5f42-9cd0-f4234c55a9f7@roeck-us.net> Date: Tue, 29 May 2018 20:42:06 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180530055704-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/29/2018 08:01 PM, Michael S. Tsirkin wrote: > On Tue, May 29, 2018 at 03:19:08PM -0700, Guenter Roeck wrote: >> 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 >> >> Is this patch going anywhere ? >> >> The patch fixes CVE-2018-1118. It would be useful to understand if and when >> this problem is going to be fixed. >> >> Thanks, >> Guenter >>> --- >>> 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; > > As I pointed out, we don't need to init the whole structure. The proper > fix is thus (I think) below. > > Could you use your testing infrastructure to confirm this fixes the issue? > Sorry, I don't have the means to test the fix. Guenter > Thanks! > > Signed-off-by: Michael S. Tsirkin > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index f3bd8e941224..58d9aec90afb 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; >