Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp987383pxb; Fri, 15 Apr 2022 17:30:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwS1ZdyGmVSIjNg1lKpw8nc02ZsCNxVFunxgDpicGovbNrS9Qq62xEkPDneBWcKChSHPIGu X-Received: by 2002:a17:90a:6c64:b0:1cb:a150:52d with SMTP id x91-20020a17090a6c6400b001cba150052dmr1438613pjj.111.1650069041277; Fri, 15 Apr 2022 17:30:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650069041; cv=none; d=google.com; s=arc-20160816; b=R8CRtQRCYxlUUekVjh6lkRJwXtzNkQf9HzeuIb+JoGZyU1TkpNRtgNaN5erIBYwDI2 kvREbi6NQZhGGmas6taDjracO5LQJaJYoCmRhKsIptAMYzN27ZeG+eRPELPVagZqUike /uCC5NiU/5U9Zj8cV17zwt+u5puCUcXL8hjuopHYZkUeY5ZHnoJEutyWLFJzrydIWV13 ld9PG8HrI0UJdBJzLULU7oV/sdBUTUw9m8Kzhp/QgTu7T5NCp2etQlinXp3nR83Odz5J ndj3JC5Gg9OROZibp/OC1WD0vu0S6Yeud+O5G5nE/wiSIcJl04XSviS+CdLDcHY/k1iz rtPQ== 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=Mj8Kd2iaxdzZLtP+lkn5ZFqD1Z3Svx/w2u5MGhXQFl4=; b=hYI7MLxVukpEcT30MV2ASJR75eR9LFqYabJ2j7m+IG8CX+LZtbY33PDqpk8IdCT0Jp 6X3VdlP1aqINmWbGJizxyloWk7rwYaV/BXQwiEzwbW8fStNYXzaL15Mcnm+JPhuW6zKb RSRjWLK1SSxlJssAGcPKWdSB7JJrEs2DNVVqAp8pfRNrbB2JAst2DMeulRo6DCPGxbwv N9G+2eBFGrD7UiuULTInYMKFb4wuAq0inPIla78wlmKYD03nqUrb7rtE8OqTEKO0rP5V g7scHjh9lXEQSQa6NhsTJZ968DVQ+e18pQm3G+Yw+awkxtxvsffedv/4pgLa0wxbXowm 1ttg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bI5nLF7g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t71-20020a63814a000000b003816043eecesi2564319pgd.195.2022.04.15.17.30.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 17:30:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bI5nLF7g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B3077E9953; Fri, 15 Apr 2022 17:27:52 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355776AbiDOQSl (ORCPT + 99 others); Fri, 15 Apr 2022 12:18:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355761AbiDOQSf (ORCPT ); Fri, 15 Apr 2022 12:18:35 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C53097BA2; Fri, 15 Apr 2022 09:16:07 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id s25so9944877edi.13; Fri, 15 Apr 2022 09:16:07 -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=Mj8Kd2iaxdzZLtP+lkn5ZFqD1Z3Svx/w2u5MGhXQFl4=; b=bI5nLF7gOH5fv+8CP/CcpZvHtE/YkpEJ7pdSo6kPPHCCY1r5/XqoNcnQ1uaxXY+dZP yj0nBoF5wG4uOR3ic7tkxW+2Q7fON1wnFMlREAfAE3XIgGj6J/mluz9sK6iRhH/LR/34 ly3rUt0CTm5jYczR93kve/CY9CHWsfbVUwigeBqIUyIpSRVnlyhw0f02QvA1eqpDDn6Y x1vyb4yjGlGvEMlnsWy7rUglQ1c8IYQ2YWWCdt/CPrAu55z70tFfAKeFNMe0XMmMV9Rz /x+87a1EmR21GeZmbhXd5QMkf3FomJ+tmVuex1tGqZKJX13mvnbxBl/JPADUWhwqwtNM sAdw== 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=Mj8Kd2iaxdzZLtP+lkn5ZFqD1Z3Svx/w2u5MGhXQFl4=; b=Bc+g8kMDyLS1Y9VOjy/IzKpw9y1dhJhUCGNzB5hDWFdvC6eeaHXxHJEkmQxsBTSJGM KxNbUGEzxLlVCO8Z4wxIJFDS7I8MP8YnTi4RFI68x0u0knYooXJ83J6OymOb5gcKkzmZ i3iSGvW0OfoIrTyma9eAb6F1NdpaKf5fwzMhuI8JQhJ6aSfvT5B35KSPZsAzNuy6gVUo SZ8US+LsUTm8bvyESZhTLe1WAW8UTXJhGfssAGKMfPJKYW2fgMvSspSciXDDgnqamxYs wFlbUlQOJ+AvyUkc3MvkILrHUkZwZtruTVyNl50Bugto+suVd2VmwuXlJ2CWt0KjvL/3 t2Wg== X-Gm-Message-State: AOAM531AppofaXAeF9VdhMe8xTu/r794vMlqepmO/QuCPeM2RvOad0Ad ElOCXt3fjdliT30BEolv8KgMk3Abu+b11cpU X-Received: by 2002:a50:fc89:0:b0:41d:83d1:9df3 with SMTP id f9-20020a50fc89000000b0041d83d19df3mr8753484edq.19.1650039365812; Fri, 15 Apr 2022 09:16:05 -0700 (PDT) Received: from anparri (host-79-52-64-69.retail.telecomitalia.it. [79.52.64.69]) by smtp.gmail.com with ESMTPSA id b7-20020a170906708700b006da8440d642sm1847640ejk.113.2022.04.15.09.16.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 09:16:05 -0700 (PDT) Date: Fri, 15 Apr 2022 18:16:02 +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: <20220415161602.GB47428@anparri> References: <20220413204742.5539-1-parri.andrea@gmail.com> <20220413204742.5539-5-parri.andrea@gmail.com> <20220415065041.GC2961@anparri> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > 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... > > The extra protection might be obtained by just zero'ing the header (i.e., the > bytes up to the 16 Kbyte data array). I don't have a strong preference either > way, so up to you. A main reason behind this RFC is that I don't have either. IIUC, you're suggesting something like (the compiled only): diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c index 092cadc2c866d..200f12c432863 100644 --- a/net/vmw_vsock/hyperv_transport.c +++ b/net/vmw_vsock/hyperv_transport.c @@ -234,7 +234,8 @@ static int __hvs_send_data(struct vmbus_channel *chan, { hdr->pkt_type = 1; hdr->data_size = to_write; - return vmbus_sendpacket(chan, hdr, sizeof(*hdr) + to_write, + return vmbus_sendpacket(chan, hdr, + offsetof(struct hvs_send_buf, data) + to_write, 0, VM_PKT_DATA_INBAND, 0); } @@ -658,6 +659,7 @@ static ssize_t hvs_stream_enqueue(struct vsock_sock *vsk, struct msghdr *msg, send_buf = kmalloc(sizeof(*send_buf), GFP_KERNEL); if (!send_buf) return -ENOMEM; + memset(send_buf, 0, offsetof(struct hvs_send_buf, data)); /* Reader(s) could be draining data from the channel as we write. * Maximize bandwidth, by iterating until the channel is found to be -- Let me queue this for further testing/review... Thanks, Andrea