Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4571629ioa; Wed, 27 Apr 2022 06:44:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb+YrNiM2Q/aykXsolJZL6s0hEifsNDlQZzbHPYVkAsE9OcsPXBv01aePiCEDkntzSnt8d X-Received: by 2002:a17:902:7fc9:b0:15b:d408:5b19 with SMTP id t9-20020a1709027fc900b0015bd4085b19mr27955172plb.12.1651067055510; Wed, 27 Apr 2022 06:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651067055; cv=none; d=google.com; s=arc-20160816; b=aWkB3k1zjX09vYhz3wPwwx9X9hH1U0KPh9LTKe077/ibBolXkNPPJI1p4/8dxIFt7/ jQU9r24n8wEFHjhKHWqSQGkwpWYpiOOeyHmkoGMjfwr2uBNmWbkESEi7/lB1RYP8ygXf FpjiexZVPnFK6QaZ7i86Zlh0QU+dNTKLtu/2ibVrcNb/l3t+Y93t2x/DzJy3EKUyuYjz iRV9bHHmZcG5Jo+bXJwvaDuKt3PjRzIp4p6UQ0r5N10+5xCf0W0Enwg4riTNXCrnoACc /ZYJepVWIIsG90KcDOX7HqqF3z9GGPP4PV+Jtcw9IeDHqJG3evJFoaztJm1SE7Q5NMx4 4tLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vuIsff87ALefijT05zxCKdqr80dXhi87dosPw80x4gc=; b=qfVLkT+oDn4NR3mXxfUpMevI1XzFzyqIoEmnnZpfAPqU5LgFHcmh+3SJ7Qd+s0IVfB 2ABVPOoV7uQ8UFblLvKL3c14T9rfnBDle7IF8wD7PegTUwod0rx2OBDDd8v0wLPyhC4w QDYkAVpeao1U5yrSf3OPKtyImEYOKPEs48rRB/zE2k1ohNxCyGSP1grjzMed1Bu4Cd7q IGVyCaNQbIpHJ7Hf7TqRhVl4WaDRjNY/T1q7WT4Udr2hKkYngrh7vZkKNyq/IxBGYh5w P0DADwCI1AiAywaNht7BEkVxyUJ98i/BBkyvtfzaSGqWt6+ap8h98ABhZycRBo9fpVQ7 hXjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=O9p24mrX; 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 pj3-20020a17090b4f4300b001d987943475si1419713pjb.181.2022.04.27.06.44.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 06:44:15 -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=O9p24mrX; 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 ED67231DC3; Wed, 27 Apr 2022 06:16:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235396AbiD0NRB (ORCPT + 99 others); Wed, 27 Apr 2022 09:17:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235386AbiD0NQw (ORCPT ); Wed, 27 Apr 2022 09:16:52 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A6081B8295; Wed, 27 Apr 2022 06:12:59 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id g20so1890388edw.6; Wed, 27 Apr 2022 06:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vuIsff87ALefijT05zxCKdqr80dXhi87dosPw80x4gc=; b=O9p24mrXUv60CAJt3qAcRAqRkDMq78u0XMBuSTRxdiP4HxXCv8JyATpS24r1jjvmMS mhkJbSrPGodE5A89kc9flBzdmXDOt6FuKJrhfZAF+cNBp6eZkg63RftSyPGyhevalBMU /fS2fcrfnbglOmvPbhyazCyJ/Pzn7p8WCUBQTFLEEYkOyOHMhHNDrQ/cCdMzqSZQFd5S SkpuK+GmoqwdOyrdEN4TEc3vgfFvPU/zeIPSiROVQFymvLVdSIq1CNZK1Bf8eecWgrmx hlHaYMUL/D73p8QXMb2qb+kTC1hy5JULCGaGrIb9Ar0R0SjcgWK/HpWLn+I92X5PBFHb MK3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vuIsff87ALefijT05zxCKdqr80dXhi87dosPw80x4gc=; b=ZgAitxG78FFPlns1EFU7Aj30FqWaGwWiqdq2DGYjQHENbtbuhPkzMENAeA0ej28sOo /hb3Z0DBHCK6MsUo3IBJVQWI6AT3ZVy6E2t0CYZFPyjGUiNMS/bsZRzSkt6nxuHoIV0/ KNGaRvU+Q/oHuz8Pq+sk74oXyOOHbS4tVPXR5997KWxhav7nqRgugdRdFqwkk9s/MmlU i7TG1DRDbFNkzHPFUZgyGFJVJ95lq7+48IkXaFeCf416N/9IFrBnsnrI513fyttli0Vw Je2qIDihf1JBVlkB4yAFuaiU8jCOOGsnD+7UFpcqVH6aHB9sffDHS0tmgAbbnz9vxEes s8hg== X-Gm-Message-State: AOAM5324SKFpYn9FCEmAwbBBKuzVSfMTyfWksB93Ime1LBsTXWBIz03B 3j+/LUhsBNq6MaLl8bgaHXc= X-Received: by 2002:a05:6402:3042:b0:426:1906:6daf with SMTP id bs2-20020a056402304200b0042619066dafmr2257326edb.406.1651065177897; Wed, 27 Apr 2022 06:12:57 -0700 (PDT) Received: from anparri.mshome.net (host-79-49-65-106.retail.telecomitalia.it. [79.49.65.106]) by smtp.gmail.com with ESMTPSA id u6-20020a170906124600b006e843964f9asm6668987eja.55.2022.04.27.06.12.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 06:12:57 -0700 (PDT) From: "Andrea Parri (Microsoft)" To: KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Michael Kelley , Stefano Garzarella , David Miller , Jakub Kicinski , Paolo Abeni Cc: linux-hyperv@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Andrea Parri (Microsoft)" Subject: [PATCH v2 1/5] hv_sock: Check hv_pkt_iter_first_raw()'s return value Date: Wed, 27 Apr 2022 15:12:21 +0200 Message-Id: <20220427131225.3785-2-parri.andrea@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220427131225.3785-1-parri.andrea@gmail.com> References: <20220427131225.3785-1-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 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) Reviewed-by: Michael Kelley Reviewed-by: Stefano Garzarella --- 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