Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1867547pxu; Sun, 6 Dec 2020 09:58:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbbmTf7hlPgz/WLgnPDkUeiHEq/crTriPomg8QZE/HDHThVu97PzUsbfj1cpVUKhOMNWa0 X-Received: by 2002:a17:906:6a45:: with SMTP id n5mr16211852ejs.514.1607277485465; Sun, 06 Dec 2020 09:58:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607277485; cv=none; d=google.com; s=arc-20160816; b=FuJDmvGrjl7y0PqB5I7vXXL/+8ObxA+fOnKGkY5NEo0cG1//euxdUPe/5TFTGN+wQA WvYSy8XRoCzj8jrdvqy7v3wnLdbpzdTtBuMd5pm0YYtfMui8g5bF9EKglGOSQzUM4daG 6xhMC8L+ZkZKg3foru3XH1RB2YouSlsK8nCctDhd7dG9bHsStl/7NeE1RPhNCf4RQWy5 RpRqJY6S7TShtMBekPxVGJ7XPHb43TSPX/OoneiZoIn+Lz53WC9eeBGTR6aonS8Ojg2q crE10uv/RQ/8JpeVqeoKvYyPNFKTw9lpF5H0VpW64xE5XMqJfACKxrXINMuZemazFrRG 27Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8hPz3fXD4d18hl2wdf9fe7bSAOyqTTVMV/KSC4uywkY=; b=A4TMUyD/DjeQR3C9zI1z999KfteT6yvFjOjL0qkglmkSzU96U+vdprnKB5OoQEZF0q pl5zzf/ilWSYFHc3LdjzK/GUcqhBG5AZ/ZPe5WI59qkvBqpVKrxPiawTnApa5BlUvg90 cxFfahX53Y8ITujoSv3KZZSGcleOBKi1cCIXPt80DYyGU5R/RkovGsYykwpQxs4EA7za YrnR2kuuDUMMw8vTobrDCsQH1BNwZ1OsqVP4t8OPR1IuFMXyBmY+qIw9SKBqHxcpcfot RBUBYW9m4tYFbtDJ+Pn+4S7gOmtbcY4nyHYUOtKG0cRIO9ffLQnQmpHoh+pDFrz7KWFj rysw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uBK0NQxE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c6si5290104ejr.584.2020.12.06.09.57.42; Sun, 06 Dec 2020 09:58:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uBK0NQxE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726641AbgLFRzN (ORCPT + 99 others); Sun, 6 Dec 2020 12:55:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbgLFRzN (ORCPT ); Sun, 6 Dec 2020 12:55:13 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAF01C0613D0; Sun, 6 Dec 2020 09:54:32 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id g185so11586489wmf.3; Sun, 06 Dec 2020 09:54:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8hPz3fXD4d18hl2wdf9fe7bSAOyqTTVMV/KSC4uywkY=; b=uBK0NQxE8iF0KwU+lcMnKiKiBhUVCD1VpC8jl07R8gba9N5baU4BggiCv/J+Iaf9wT 7rDTbQtAzAfS6x4kiiHwUfodAHPWJVcC3dpUlO+a2P4+kOXU/0lzY/1emIZQxnUqdhge yjOJovOvA8aNukFIyIICu09dTO3nQuIWHCNZc04FTedXjTJiTY8bVoP2vRz7H4aHJR1r HSS6S6eZljo4E2T9PeYzJ9mM6YLtQLFlQIgBZrtSwefP4YaLmX4+fADJoy8Q684eYOi9 t8DdkLaCNgjvubqTj93Pf+5ezsZt1mOAa2QcJnAts9OU4gX4WOP+K4cl43E9zQGisUjk vWnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8hPz3fXD4d18hl2wdf9fe7bSAOyqTTVMV/KSC4uywkY=; b=A2iWaSLFnfcgcHw+LNFhaswadpPEh/b0c6fPifjp67LkgZw5GCtzeGgzmbhsiYs5AZ JV7aiG7FFpCh4CSFTz7g1oZJjF+lyiOtn3tffdE4yy542BYUKZu+uHW1uZHeu51gePW8 YAD6Z1g4EfJJt3bOSzPTziYzfjzucARIu3NPTpUqNIaFparswq8lu7+Ig5OaFUWlKmAV 8Yrre1+Mn00Ac/RZfwP8fosWrUDN5gJEp8UnIIfJ87jxnIlWulfHK6kwMBlU8f956wPo aKDbm06MfHIGY/PY8Rj2cVDrK64MQC3CMy3DDSQ97NPauoQzTgolT6bV3IuPU/a0l9Aa iLkw== X-Gm-Message-State: AOAM532eJ2n1XrJuHWsM/g+yzxf9PNQnFiyFoeR7oNumipqDElw8CSOW wnthM4vNL56SVm9qOQ2MHhk= X-Received: by 2002:a1c:f60b:: with SMTP id w11mr10372604wmc.180.1607277271305; Sun, 06 Dec 2020 09:54:31 -0800 (PST) Received: from andrea (host-95-239-64-30.retail.telecomitalia.it. [95.239.64.30]) by smtp.gmail.com with ESMTPSA id q25sm13008690wmq.37.2020.12.06.09.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2020 09:54:30 -0800 (PST) Date: Sun, 6 Dec 2020 18:54:22 +0100 From: Andrea Parri To: Michael Kelley Cc: "linux-kernel@vger.kernel.org" , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Wei Liu , "linux-hyperv@vger.kernel.org" , Juan Vazquez , Saruhan Karademir Subject: Re: [PATCH 1/6] Drivers: hv: vmbus: Initialize memory to be sent to the host Message-ID: <20201206175422.GA3256@andrea> References: <20201118143649.108465-1-parri.andrea@gmail.com> <20201118143649.108465-2-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 06, 2020 at 04:59:32PM +0000, Michael Kelley wrote: > From: Andrea Parri (Microsoft) Sent: Wednesday, November 18, 2020 6:37 AM > > > > __vmbus_open() and vmbus_teardown_gpadl() do not inizialite the memory > > for the vmbus_channel_open_channel and the vmbus_channel_gpadl_teardown > > objects they allocate respectively. These objects contain padding bytes > > and fields that are left uninitialized and that are later sent to the > > host, potentially leaking guest data. Zero initialize such fields to > > avoid leaking sensitive information to the host. > > > > Reported-by: Juan Vazquez > > Signed-off-by: Andrea Parri (Microsoft) > > --- > > drivers/hv/channel.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c > > index 0d63862d65518..9aa789e5f22bb 100644 > > --- a/drivers/hv/channel.c > > +++ b/drivers/hv/channel.c > > @@ -621,7 +621,7 @@ static int __vmbus_open(struct vmbus_channel *newchannel, > > goto error_clean_ring; > > > > /* Create and init the channel open message */ > > - open_info = kmalloc(sizeof(*open_info) + > > + open_info = kzalloc(sizeof(*open_info) + > > sizeof(struct vmbus_channel_open_channel), > > GFP_KERNEL); > > if (!open_info) { > > @@ -748,7 +748,7 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 > > gpadl_handle) > > unsigned long flags; > > int ret; > > > > - info = kmalloc(sizeof(*info) + > > + info = kzalloc(sizeof(*info) + > > sizeof(struct vmbus_channel_gpadl_teardown), GFP_KERNEL); > > if (!info) > > return -ENOMEM; > > -- > > 2.25.1 > > This change is actually zero'ing more memory than is necessary. Only the > 'msg' portion is sent to Hyper-V, so that's all that needs to be zero'ed. > But this code is not performance sensitive, and doing the tighter zero'ing > would add lines of code with no real value. So, > > Reviewed-by: Michael Kelley Thank you for the review. Please notice that I posted a v2 of this series: https://lkml.kernel.org/r/20201202092214.13520-1-parri.andrea@gmail.com Thanks, Andrea