Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp29400lfe; Fri, 15 Apr 2022 17:56:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTaXvt/VXqqk3W4b0RCwdvPB3OL3vdmgZZuG7qwP+wPGEJV6u/0TcmPRCAOC2CnCo8a/8o X-Received: by 2002:a17:90a:d3d3:b0:1bf:2e8d:3175 with SMTP id d19-20020a17090ad3d300b001bf2e8d3175mr1560609pjw.2.1650070571916; Fri, 15 Apr 2022 17:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650070571; cv=none; d=google.com; s=arc-20160816; b=KCcwVJdwRLwOmuU0Dip4fW7Pez7E5QH9hmYxI8760aC4GN/vnFhqHkVYnkSPza/L6D XlW98ewhZfFlH7snc79KUFHGLKc/LFArQD0V0W3AOQj7TJn+45ix04OgREN3pTGBtoO8 r1LPqaCrx+N+ZOU6/R5NnxEoO9Y77hHnwxJtAOCEzUv3bsbV1gylh0Gd22cxsO10ADtH 8VVB5/8HTWdjNNOMAyMx1u5gae5iItt+Jc13PCwOp4W7rNdPkHdCLpJf+Wf0nFOjFvIq j2Lungy4k9cgnHHqJRxprR+yGGGpwNE7fmv8HNU9Si6d74EzHQnmYmjQvzogMHGSeqGR cM+g== 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=5H0NkTvkK9p/s/zFBLeQhRPlAabxLu86mDFZRjaQsXc=; b=LN0W1vLQbix9PIQLzUYGm8a30eDVhJSFH5XeW40g52EImWgCcf4+zMuiKWaoyNX5Wz o9Nobc6dYiJj/6QEMWdKGc17kcHYt+BGJvey70e627miTwi7PHFjeNSXu6X37BN4AGyE jLfYjRo6d83ztvCWHBtxQ19CECX7DcVniu3YFQGjEyYW/HLROjjfey87aGoyXBaWCqj9 LXPR0dt4dE2HE7opKLe+B5Z/r7qoSQqr1cCIa9xlqx8JMXZNm+w4jAWqwFbrEJGsaK+Z pWUAwoqmrnNhrjph3oDofNsPQ+AlqKiGJOgYtMHVr78w/LpOeHkQSTujnK72X+51BlJz +0rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iyFOa4B+; 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 q2-20020a17090aa00200b001c6ad6e9221si5934342pjp.35.2022.04.15.17.56.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 17:56:11 -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=iyFOa4B+; 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 0B2291168D0; Fri, 15 Apr 2022 17:42:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350570AbiDOGoN (ORCPT + 99 others); Fri, 15 Apr 2022 02:44:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350562AbiDOGoM (ORCPT ); Fri, 15 Apr 2022 02:44:12 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 270F9AFAE4; Thu, 14 Apr 2022 23:41:44 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id 11so3927524edw.0; Thu, 14 Apr 2022 23:41:44 -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=5H0NkTvkK9p/s/zFBLeQhRPlAabxLu86mDFZRjaQsXc=; b=iyFOa4B+WwNsN+h+lDNBD7iDxm1raLPy02+uAnAc+XNZRX1w70gpAZqtygmAFeXjSg 1GUSmiurrP71xGOpLq2V4+8hSIuCzS5F96z6jeOIkzrISvWEEudwsgm6RzwwlnXcPG9a qF7a2xTHOx8a5GiJsY9lEWF+Uho6ZA7vaNxdHeBlI/Wi9LjDuddeBUTS0lm0eGkImDje Y7lTz1NSrxwSn3xQtTvCQRVjxClQi+Dz2ezWPmHqsU5nI68lMFWm74KyKRimhArp1eDN 1y8GQ2Z09zw3xJSYv4or3YzrTl19q7VEvrFUNdkgSWq3/gFIAakmfJp2mOKtJhlto7m3 0BhA== 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=5H0NkTvkK9p/s/zFBLeQhRPlAabxLu86mDFZRjaQsXc=; b=Xm4y6PmYs+lspXFpVj8vE/WicT+iORkJhz34bEFRFNKJzgRf5HwmDN/8qqT9Sg4W6K GFgTy9bQQQnB7HzvC22OHQtk5PqsSeras7//nCs4DqU4UN2rjfsiMFP2pMjk6tswO3sG esBog/yYnpXDrLLj4beSAAGjkiCCTDbkFGYrVKHSDA1bQTZFcwfAtBjHWcGM/gvbG+TY Efa/Sj1FUru6MauK6uIi32QLN/f1HJCIUvfo1EBdZ5MSDLIafZMeNBpaDYA5CNzC7m4A I2lQvmbRPpoxCygRlrFpS/TBV928uL1Fi4fmQNybRpyBj8ia0u0V5mmRKptEKcEj4Wdl Mkkg== X-Gm-Message-State: AOAM532tVHZPtPBd5HHRO78VFPdJyOuMum4Me8jvg+U4M+vEKk/1HX1f iYSnbWxI5ZkWmDfyK9hcoOOSv7truu+0EKB/ X-Received: by 2002:a05:6402:1385:b0:413:2bc6:4400 with SMTP id b5-20020a056402138500b004132bc64400mr6918217edv.94.1650004902841; Thu, 14 Apr 2022 23:41:42 -0700 (PDT) Received: from anparri (host-79-52-64-69.retail.telecomitalia.it. [79.52.64.69]) by smtp.gmail.com with ESMTPSA id j23-20020a1709064b5700b006e87ae0c111sm1362808ejv.123.2022.04.14.23.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 23:41:41 -0700 (PDT) Date: Fri, 15 Apr 2022 08:41:33 +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 1/6] hv_sock: Check hv_pkt_iter_first_raw()'s return value Message-ID: <20220415064133.GA2961@anparri> References: <20220413204742.5539-1-parri.andrea@gmail.com> <20220413204742.5539-2-parri.andrea@gmail.com> 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 On Fri, Apr 15, 2022 at 03:33:23AM +0000, Michael Kelley (LINUX) wrote: > From: Andrea Parri (Microsoft) Sent: Wednesday, April 13, 2022 1:48 PM > > > > The function returns NULL if the ring buffer has no enough space > > available for a packet descriptor. The ring buffer's write_index > > The first sentence wording is a bit scrambled. I think you mean the > ring buffer doesn't contain enough readable bytes to constitute a > packet descriptor. Indeed, replaced with your working. > > is in memory which is shared with the Hyper-V host, its value is > > thus subject to being changed at any time. > > This second sentence is true, but I'm not making the connection > with the code change below. Evidently, there is some previous > check made to ensure that enough bytes are available to be > received when hvs_stream_dequeue() is called, so we assumed that > NULL could never be returned? I looked but didn't find such a check, > so maybe I didn't look carefully enough. But now we are assuming > that Hyper-V might have invalidated that previous check by > subsequently changing the write_index in a bogus way? So now, NULL > could be returned when previously we assumed it couldn't. I think you're looking for hvs_stream_has_data(). (Previous checks apart, hvs_stream_dequeue() will "dereference" the pointer so...) Thanks, Andrea