From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3452BC433F5 for ; Fri, 15 Apr 2022 06:50:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350727AbiDOGxU (ORCPT ); Fri, 15 Apr 2022 02:53:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343864AbiDOGxN (ORCPT ); Fri, 15 Apr 2022 02:53:13 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E6FFB3DC0; Thu, 14 Apr 2022 23:50:46 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id s25so8500403edi.13; Thu, 14 Apr 2022 23:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=FuI2l9kDOo4LiYnP+oGo08tHGCFvEiqQxGIgY3zlKIA=; b=Dz7hxGHDeM5WnsAFMqIITeeKULRipD+St4//j1pf82am51Ed9InFiST07WqtKVMdOm uBSITb/oa9bo8SGPYJEJnMK6fkDCaXrvBd933+oAb9Tyb3KearAu9DcInWJznOW442r0 7TZrMqJOexp8wXZLWvdqy4xZSzPfd/24xu/HiCMClXJGA0hbkjP2hoiFNoai4rYkkmP/ MBFXGVFB69N1yno5X6W5VJlt3zZUZ4ucvS4hbMdJ80eXVelJYVhtWnuZGgCAB3yuEaKC U7ONGlWpwMlLAfI8QbVwYBpkMLLEp6PeEwAJxqIXhrDX/KIYCrOVC8sq9xuzqYYJj2Fi rMlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FuI2l9kDOo4LiYnP+oGo08tHGCFvEiqQxGIgY3zlKIA=; b=GlnE7m09xQRa+jvbausuOC2XjqtGSqMAazIylwCtpXT6kDz0TCmj6Wh6MaIJfT4IWR CkVbkgN9iT50+n4W8t75zDl3Emn8E2VnNmQwF3Zg4AYTm9NGX9sJj62SlO2kJjGh3Sg1 2WHaIeccOH9FJRpKA97QuyXJK97w0n8eIriJ+aXj4Jr5cwnzSWoO5N+RVNydKfm771iw 0ZYp+joLRP78L9n0el9wT5x5CSNi7k6BAJs5mV7ju8On1w9O5J5vFVkG0EQo+yo0pG38 bsY8SI+C8aWWM1u6ek3qfjTSdpAgrakFDnnKU4qMkENud9q/1IhJByffYAaAmgPaGTyf 9shA== X-Gm-Message-State: AOAM533PNCskqw0vUAkntTX8jsDaD1xT5ezidm2vxmwtUWZmom+YuixG jC+rQMdUVJeMnREP+2hAerIClz1zQXH3hE9x X-Google-Smtp-Source: ABdhPJyvG6erOo3dT0Ozq8rJ75PwgZ+s/hBNzb+6RwjUN21kmuAXGLK65+mJnqz24BCHAYJpl28FlA== X-Received: by 2002:a05:6402:1912:b0:41d:975b:9496 with SMTP id e18-20020a056402191200b0041d975b9496mr6930321edz.222.1650005445000; Thu, 14 Apr 2022 23:50:45 -0700 (PDT) Received: from anparri (host-79-52-64-69.retail.telecomitalia.it. [79.52.64.69]) by smtp.gmail.com with ESMTPSA id n13-20020a170906724d00b006cedd6d7e24sm1371176ejk.119.2022.04.14.23.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 23:50:44 -0700 (PDT) Date: Fri, 15 Apr 2022 08:50:41 +0200 From: Andrea Parri To: "Michael Kelley (LINUX)" Cc: KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Stefano Garzarella , David Miller , Jakub Kicinski , Paolo Abeni , "linux-hyperv@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [RFC PATCH 4/6] hv_sock: Initialize send_buf in hvs_stream_enqueue() Message-ID: <20220415065041.GC2961@anparri> References: <20220413204742.5539-1-parri.andrea@gmail.com> <20220413204742.5539-5-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 > > @@ -655,7 +655,7 @@ static ssize_t hvs_stream_enqueue(struct vsock_sock *vsk, > > struct msghdr *msg, > > > > BUILD_BUG_ON(sizeof(*send_buf) != HV_HYP_PAGE_SIZE); > > > > - send_buf = kmalloc(sizeof(*send_buf), GFP_KERNEL); > > + send_buf = kzalloc(sizeof(*send_buf), GFP_KERNEL); > > Is this change really needed? The idea was... > All fields are explicitly initialized, and in the data > array, only the populated bytes are copied to the ring buffer. There should not > be any uninitialized values sent to the host. Zeroing the memory ahead of > time certainly provides an extra protection (particularly against padding bytes, > but there can't be any since the layout of the data is part of the protocol with > Hyper-V). Rather than keeping checking that... > It is expensive protection to zero out 16K+ bytes every time we send > out a small message. Do this. ;-) Will drop the patch. Thanks, Andrea