Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp940548iob; Thu, 28 Apr 2022 14:26:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9uAUInapoe5G6uN6FGttuj3K6ongp76ibQtjatzo/7rs5T2Cyx8Ir5P6bYISPuDXBjQCh X-Received: by 2002:ac2:4a78:0:b0:472:2106:4b94 with SMTP id q24-20020ac24a78000000b0047221064b94mr9740060lfp.632.1651181165726; Thu, 28 Apr 2022 14:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651181165; cv=none; d=google.com; s=arc-20160816; b=anFjiDcrwEo2V/8SfV2ZBwP2y85H2eE0d4tSXX23XAZSukFSQtQQTjSLEuEe3XdAvb aA0C3olBs2QxqbzpRX0zgSRvQ+yDi5dCXvWLtGgsj8FGROPBCfIiaa2VITsFBuAIOqjA dalcuq9dzWj6d8Jdhv9YV5wDF0ysXoO89+U9mYFQ/TlvuxypZ1GExjUXxT2gjvUNitJd dBBNCvVd6AwT3udFVysBUSa+WgRPTPjP3r0/vrYq0zyO36r0EKzjIm9ZmMTs7YkON7yl TyDk+JMCfSuY6fD+LlUikoWwRW6m1lmuRfJ5Z9bGsmSV8XjG4r6KaFCIpgFX/tkveNqJ 5jkQ== 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=OLVq3YVrw0f+ZEDGMSmFsrt8DbPbYF06BGjNOYtkZJfvo87XHQTZu10MUa07NgyB+f gnpjjI+1WTFmrZbY9go1JoIz4LWYHNcdniDSNRSbFdk+9rOrWYGAqUmV1/hKIXjUK/oP azru3LJRjiCQH85lWpSKEo6tF2LGfh7wBbCmElwkdw1kWfsbtaU/YCBJWA+TkCgJq33e UkDDxVN7a9MMqvR3rAGcqYLam/M1uuLg4KP+BQnmjp3RR4T3jTUHm0X3ZXOq5jULE2wL jdHCHIUjK1GKYzevWIac8Gl2FzhM7jsLYbQrIBBUXGwzExeAlyPLfhGl9Sfihnfndm3I Z/0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PstODrS9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c1-20020a056512104100b00471f866b3d9si5313598lfb.607.2022.04.28.14.25.38; Thu, 28 Apr 2022 14:26:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PstODrS9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236035AbiD1Oyu (ORCPT + 99 others); Thu, 28 Apr 2022 10:54:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234686AbiD1Oyo (ORCPT ); Thu, 28 Apr 2022 10:54:44 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A0E75C853; Thu, 28 Apr 2022 07:51:29 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id l18so10048174ejc.7; Thu, 28 Apr 2022 07:51:29 -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=PstODrS9isMX6NHMixerP3v6KE5/4KrHAUXQKcTvx5lkKrEVb/g2ukG4fHldglpVun rTVT9xe6GxBlc8KDvz5SLHuiKFZ5bSevL7Zh6fdIY6j3GXCI0t8ivIZvE9tyttg055jh KHDGYaypWpdMQeFXAwLFi0jmHUsfBcEfE4perTsJq8OmRO6XBsS+nDAapDQkfCoUtSIK QoiEF0ErqgmotE7DKu02YgEH6BUouVqQQCSHZCuXnhhj6T4RORamSymNyqBzB4PtmdbB ECVPm9y+KBogeetoaQWScoJQfPDuZrBTlE7awUW4wMbkRsYa2NhvSHp95eUOfFkaufnf ykkw== 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=xS92vSnMt3ioYAju0bCHCdMfdXf8mb4rgzXw0EFTuuazspBAbgi1AeTd6VRv3ZD6YL 0wWe4XA6UduViyOQIWgvmI5HscSaQ4W6CqpZH5aTQbkyJqaj6TV6bJ6a3ncWhqKE4Ho3 /jGYXx07jbvBT/Ujgz1CmxSOO4Ewe96yDzPHNZYwjqePmXtyWkuRjZXO++d9VFigSSJX MHO+nNCqb15XtxYIDL958B71C3yL1+kRWbdfGEKB3DTs3J6CxAQNcRgZaFOfpFTXCVYI f3DCqG64EwB1yoXhKQvTwrsWjomXX7PMogAWSM09VdTqLwAhA1Hj7PcFE6uBcJI6tO47 ZRpg== X-Gm-Message-State: AOAM532U6Jl+ue0tHayeQdRy4hPEQdYSdsWP4SRdGamI8wuqnvb1xVnt /uI7oFamcJdNNZ6q1C8l8o0= X-Received: by 2002:a17:906:1ec3:b0:6cf:d118:59e2 with SMTP id m3-20020a1709061ec300b006cfd11859e2mr32140363ejj.767.1651157487582; Thu, 28 Apr 2022 07:51:27 -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 x18-20020a170906b09200b006e8baac3a09sm61616ejy.157.2022.04.28.07.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Apr 2022 07:51:27 -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 hyperv-next v2 1/5] hv_sock: Check hv_pkt_iter_first_raw()'s return value Date: Thu, 28 Apr 2022 16:51:03 +0200 Message-Id: <20220428145107.7878-2-parri.andrea@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220428145107.7878-1-parri.andrea@gmail.com> References: <20220428145107.7878-1-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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