From patchwork Wed Apr 13 20:47:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Parri X-Patchwork-Id: 12812616 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 312E7C4332F for ; Wed, 13 Apr 2022 20:48:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237621AbiDMUuX (ORCPT ); Wed, 13 Apr 2022 16:50:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236542AbiDMUuW (ORCPT ); Wed, 13 Apr 2022 16:50:22 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D111050470; Wed, 13 Apr 2022 13:47:59 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id i27so6337859ejd.9; Wed, 13 Apr 2022 13:47: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=oxLePFx8Fq+seNMfUwSyI5u63bTK2hgBeAnss7OXaN0=; b=P6SkBP367S2Wp+x5uEk/qbytSNXaoctYO0Fs/wz777P5X/JWy1eSevGHT/qeATov3u mKxhtC+RJDsdTgpXDVjgh+wUCPfPVw+YrN4QM5rnvYUCNmHsY2HMq8ZmoVuliY/qcKl1 tK4zq2HmlV4iHpftiMzSo0PPXn3M7lr1XiivqQC81tkhskpZsr6MCcYUkTJHBuwErMom Z/yf+7opoG/GVSw34U0wgUGc0DShk6J2LtMTqieywmJZ1ghu1vv5yxE7cbNArPgQohqC 9UZ+oPW2yQh8lPAua5tj3zJKHK1PzB5bf9rzaufmJh+wD4ffS85kZIsxz7AYlzp5PzXn iZ5Q== 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=oxLePFx8Fq+seNMfUwSyI5u63bTK2hgBeAnss7OXaN0=; b=RSFuv/fyKOgGDZMiVUEDVVUOEO9mrGO7vgOv6fyh6Wjyx6n2mBCnsf0GJl0bOAhKbT MNXLuA3CTzAbQMZkHdk3RaAvbY9aIhzg8llIP7XqaB009F8NnnWaMF0aaJQO6VUJQRcl w5e8UcuO58nyl/awKXyYO7jvyKwH6HV4GMcJA+vB/cnWl0Yvb7hUzoIhEKFsECqujTA+ JY1JJVi6i6KUiSbMjZA48zR2iIBJ/WkamgaT0TAkTDOmMo/VCoCpWT/PJGywuLBZQYDi CYE4sbJfo/b6K6Oy1rPA0zDiCPq1GFzKDhQzApegJ4WFW0KHGDc7/ic/lK5ZC2R6HP55 mfRA== X-Gm-Message-State: AOAM532h7of2DJeeMHjS9KWlvEYq5Q7IvkauONrH8dFDt5GkRnH9b5yA xp4cZyAmCRWhFmp6Pns0c4w= X-Google-Smtp-Source: ABdhPJy9KVgC2+Z9Gy9D7Asn3JZZ4Lzh6ZOIFUPmZraohLsVbU/W03klYluTNkoIIzEOiozU5K53dw== X-Received: by 2002:a17:906:c091:b0:6db:62b6:f4cc with SMTP id f17-20020a170906c09100b006db62b6f4ccmr40828985ejz.607.1649882878370; Wed, 13 Apr 2022 13:47:58 -0700 (PDT) Received: from anparri.mshome.net (host-79-52-64-69.retail.telecomitalia.it. [79.52.64.69]) by smtp.gmail.com with ESMTPSA id u6-20020a170906408600b006e87d654270sm5021ejj.44.2022.04.13.13.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 13:47: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: [RFC PATCH 1/6] hv_sock: Check hv_pkt_iter_first_raw()'s return value Date: Wed, 13 Apr 2022 22:47:37 +0200 Message-Id: <20220413204742.5539-2-parri.andrea@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220413204742.5539-1-parri.andrea@gmail.com> References: <20220413204742.5539-1-parri.andrea@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The function returns NULL if the ring buffer has no enough space available for a packet descriptor. The ring buffer's write_index is in memory which is shared with the Hyper-V host, its value is thus subject to being changed at any time. 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;