Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp963217pxb; Fri, 22 Apr 2022 15:26:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyajJH+HAdUbqEiZVMgo3R1Yl2mCb8xYzi+vOXC7yHOdvIG8LLV/8s+5VqebgpefKYIhP0b X-Received: by 2002:a17:902:9307:b0:154:78ba:ed40 with SMTP id bc7-20020a170902930700b0015478baed40mr6888555plb.92.1650666373309; Fri, 22 Apr 2022 15:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650666373; cv=none; d=google.com; s=arc-20160816; b=UmBBBH8X3T2+IE5Po1FCpkWF64wVKO4zqaxML5f3dXdGfy8axkrch6vhBfJdO9IkcM eQPFWT3Vtr/19ReJ8TatL/0YI5T26o6N4kGEWDOtuC6Q3wzR0cAtQYuhB1gpnDD3bo3X HeOnjCX2We8wtUWL+QJhQBMgq9cbM1RArzr1Z1C52s3h26VwdiAHW5bjzHg5SP/ZccEr 9psb2a+lAmiP0ak+vPGpr/zVc6amB+1IjX1d7yPgJHJIsejuU32x/JLosBSJS+oW19It nBjdV4b2uxeXIwaX5Ae9NabP+ejMDLeMS+SS0qzl9RuliZq8TvqTziSH88a7nyH9sCAr jGYg== 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=9X5WXrysF88Ouj/slnEAN9ILrlD7gwjjZO9fEL4BbEQ=; b=Q1L48dh5v2TDQWb++rk++f8WdPddd2MaBq2YGB53P03z5UtYxsbFOCkOb7z3ZJS9S6 Dwe5ge9KzWz/MObCpsBXuwsSgFzQe5oEE7pT+mJh3vXFlvaFI7VreXH9zOf6N+m2/V8p zBvRt9yBmDXuMnDcVk3lTmlkdN7XU8PVH94id2Os0paPe1Hqnl2UryjjPPoZJ1C3cde4 FJkZPWTO46UUQfLET7X/5i18EnZCsJ1tt/zNcTbA4xUDpDS1yWem9TAvvytd9aqmrgeL WEFYcQE18sg1RAywaLWASiRg7rWPBi3OS8A96itMYtNrnf6l3jePnT++pb8d7UBth/ib HM5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GTSRfaAY; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s8-20020a637708000000b0039daaf67c60si9978402pgc.478.2022.04.22.15.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 15:26:13 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GTSRfaAY; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 457D23DEA0B; Fri, 22 Apr 2022 13:31:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387721AbiDUNx7 (ORCPT + 99 others); Thu, 21 Apr 2022 09:53:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387635AbiDUNx4 (ORCPT ); Thu, 21 Apr 2022 09:53:56 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2D3E113FAE for ; Thu, 21 Apr 2022 06:51:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650549065; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9X5WXrysF88Ouj/slnEAN9ILrlD7gwjjZO9fEL4BbEQ=; b=GTSRfaAYaznYDSI/X9hE5BSC/oHMz9Mb02073TIcuR9Kk+ZHZ396fbTW+h1qW+BXJE+h1+ QOk7JvSD0z0aLKEq1lvlJhq+9dzHjMoyGNHlkAru5thKNOL8YzOOKQJtHeqaqc4deDRwjs ogyr/tkr6PWKMoqyeHWbe6FRgYFYTyY= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-489-o3C5JAX8MUKiF57CETMuVg-1; Thu, 21 Apr 2022 09:51:04 -0400 X-MC-Unique: o3C5JAX8MUKiF57CETMuVg-1 Received: by mail-ej1-f69.google.com with SMTP id mp18-20020a1709071b1200b006e7f314ecb3so2528015ejc.23 for ; Thu, 21 Apr 2022 06:51:04 -0700 (PDT) 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=9X5WXrysF88Ouj/slnEAN9ILrlD7gwjjZO9fEL4BbEQ=; b=cAIqeRqZ7xqFQnuXwZGsbsfHBKGKjPrmTPe8fornM1xoCvKdGDHbDKBjUyJ+6eQaO5 WPor7/62LW7cF32NZDwizJfvSf/mu/k8aOC0mj/9L7tZsJMvsqxwUkEuNiUzZgMkUK5S 1H7bXIjZs0Nc8dY00uZV/RagVeXdNM7l7WwqH4iI2JLKPBTBJQjUMnFxhVJw5d9/w+Nz u3Q8g35p7jlBzFtILv9yyxv8Pl8nC77o0q87gCpfjDUV6K+ktSG9HJNqn8TE1IAIJ4Ce GO/YlROXPQ6D+0IjN3PvpIgo73f1KIUamXCX74xeq9V7mN1iP6Wus84bcWPD+etTbUvx UMzA== X-Gm-Message-State: AOAM532m47SjMZVyk+QBi2wSF20TBmb/TTrYnTcIJCz5Eee2zGGIUL1y MLOR9bI+WOiAbjMGsNpKDXdopy3DkagPVCo2DHhZKVQDrTJFrSaLC/StHVOgZn3Qehf+lkXADWX HcZe852M3fw7I/e4dFO2KjO5I X-Received: by 2002:a05:6402:26cd:b0:423:b43d:8b09 with SMTP id x13-20020a05640226cd00b00423b43d8b09mr28005746edd.400.1650549062687; Thu, 21 Apr 2022 06:51:02 -0700 (PDT) X-Received: by 2002:a05:6402:26cd:b0:423:b43d:8b09 with SMTP id x13-20020a05640226cd00b00423b43d8b09mr28005722edd.400.1650549062455; Thu, 21 Apr 2022 06:51:02 -0700 (PDT) Received: from sgarzare-redhat ([217.171.75.76]) by smtp.gmail.com with ESMTPSA id d7-20020a170906174700b006e80a7e3111sm8096281eje.17.2022.04.21.06.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 06:51:01 -0700 (PDT) Date: Thu, 21 Apr 2022 15:50:57 +0200 From: Stefano Garzarella To: "Andrea Parri (Microsoft)" Cc: KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Michael Kelley , 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: [PATCH 1/5] hv_sock: Check hv_pkt_iter_first_raw()'s return value Message-ID: <20220421135057.57whrntjdv25jqpl@sgarzare-redhat> References: <20220420200720.434717-1-parri.andrea@gmail.com> <20220420200720.434717-2-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20220420200720.434717-2-parri.andrea@gmail.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 Wed, Apr 20, 2022 at 10:07:16PM +0200, Andrea Parri (Microsoft) wrote: >The function returns NULL if the ring buffer doesn't contain enough >readable bytes to constitute a packet descriptor. The ring buffer's >write_index is in memory which is shared with the Hyper-V host, an >erroneous or malicious host could thus change its value and overturn >the result of hvs_stream_has_data(). > >Signed-off-by: Andrea Parri (Microsoft) >--- > net/vmw_vsock/hyperv_transport.c | 2 ++ > 1 file changed, 2 insertions(+) > >diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c >index e111e13b66604..943352530936e 100644 >--- a/net/vmw_vsock/hyperv_transport.c >+++ b/net/vmw_vsock/hyperv_transport.c >@@ -603,6 +603,8 @@ static ssize_t hvs_stream_dequeue(struct vsock_sock *vsk, struct msghdr *msg, > > if (need_refill) { > hvs->recv_desc = hv_pkt_iter_first_raw(hvs->chan); >+ if (!hvs->recv_desc) >+ return -ENOBUFS; > ret = hvs_update_recv_data(hvs); > if (ret) > return ret; >-- >2.25.1 > Reviewed-by: Stefano Garzarella