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; From patchwork Wed Apr 13 20:47:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Parri X-Patchwork-Id: 12812617 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 830D7C433EF for ; Wed, 13 Apr 2022 20:48:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238112AbiDMUu1 (ORCPT ); Wed, 13 Apr 2022 16:50:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237733AbiDMUuZ (ORCPT ); Wed, 13 Apr 2022 16:50:25 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5FFA6833E; Wed, 13 Apr 2022 13:48:02 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id ks6so6396270ejb.1; Wed, 13 Apr 2022 13:48:02 -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=0WClfb203Z7+sOEjY+pzv7SOHPdMw2tVtOYL5Bkvekc=; b=IXpwKWIHgJ7QrxvwE3OTVk6mKZmgIKBtApsiNbEpR3RrekkTW1Uu+Vy9NX5hFGuJ7H Cw4l9L6rKfda1hCdvprZzw1J0zFCHnbM/geMlbpp00GAWCGo8wDTr/saHZpXBKFmm579 Da6w84pcIc+d3AuwmlApNRdkH6ux6FQA4sCVLlW45UvKe81VB5koovPH190kg3FxW5zw 9XzAIzbXesRzCmkTc1rNsk2dV3h0+tLNPh/KrGjLX8qQ59vICgaTwf6wy3lj4DawTv3k B2bhA7MrFiG6UD3JiRlaroF063j/dXepRPRlg6IFNKV/0B5iAL0Oza2Lpm22zVwA8s94 VT1w== 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=0WClfb203Z7+sOEjY+pzv7SOHPdMw2tVtOYL5Bkvekc=; b=uLSQuCJuOKJNxh8Uldp9qrdsC5+d5Wcv65RC8hEXDmnnZGUPhGEzo3NNsJBs8jiAsB 3NiTRfvLjNuG0LbItweOPH6yhcQpIap4wzXsvpyauAvYacVpHFgVzSgY1Qn8fn1NiMNO L9wrS3Sn+RaRDNjgWMNkaOPL1TwZDvMq7xW1grXWKeIcbz8G+/CtVMe5D1J2usc3yqYM rvp4qgURPRwR+/hx+RTMgtLnlobXjRkQsMldHexkN1AIAf9X1RF8Kwf3SYk5pqpI5VX2 KDhWZjuOnOEVmxiMPcg9R6j1o7UbIxdslK+IHmPiplfZnSw+4tMtu8H/AaZoZBZJpxoD uN1Q== X-Gm-Message-State: AOAM531BfTzx3tjalLJ8VB4ne8E7nj84Ud52I8bPYGEzWffDNaFhnHeH wqCeNB54k9BkLOEbiXnkzD8= X-Google-Smtp-Source: ABdhPJzhcXO4zZamZsgKX1Vpx1RWEUhhodALT7jl+k8BMClVpEQmXKtXkB5gsXKkyAz+XCgpjtPEdg== X-Received: by 2002:a17:906:1604:b0:6e8:7c02:c5a with SMTP id m4-20020a170906160400b006e87c020c5amr17992636ejd.690.1649882881173; Wed, 13 Apr 2022 13:48:01 -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.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 13:48:00 -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 2/6] hv_sock: Copy packets sent by Hyper-V out of the ring buffer Date: Wed, 13 Apr 2022 22:47:38 +0200 Message-Id: <20220413204742.5539-3-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 Pointers to VMbus packets sent by Hyper-V are used by the hv_sock driver within the gues VM. Hyper-V can send packets with erroneous values or modify packet fields after they are processed by the guest. To defend against these scenarios, copy the incoming packet after validating its length and offset fields using hv_pkt_iter_{first,next}(). In this way, the packet can no longer be modified by the host. Signed-off-by: Andrea Parri (Microsoft) --- net/vmw_vsock/hyperv_transport.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c index 943352530936e..8c37d07017fc4 100644 --- a/net/vmw_vsock/hyperv_transport.c +++ b/net/vmw_vsock/hyperv_transport.c @@ -78,6 +78,9 @@ struct hvs_send_buf { ALIGN((payload_len), 8) + \ VMBUS_PKT_TRAILER_SIZE) +/* Upper bound on the size of a VMbus packet for hv_sock */ +#define HVS_MAX_PKT_SIZE HVS_PKT_LEN(HVS_MTU_SIZE) + union hvs_service_id { guid_t srv_id; @@ -378,6 +381,8 @@ static void hvs_open_connection(struct vmbus_channel *chan) rcvbuf = ALIGN(rcvbuf, HV_HYP_PAGE_SIZE); } + chan->max_pkt_size = HVS_MAX_PKT_SIZE; + ret = vmbus_open(chan, sndbuf, rcvbuf, NULL, 0, hvs_channel_cb, conn_from_host ? new : sk); if (ret != 0) { @@ -602,7 +607,7 @@ static ssize_t hvs_stream_dequeue(struct vsock_sock *vsk, struct msghdr *msg, return -EOPNOTSUPP; if (need_refill) { - hvs->recv_desc = hv_pkt_iter_first_raw(hvs->chan); + hvs->recv_desc = hv_pkt_iter_first(hvs->chan); if (!hvs->recv_desc) return -ENOBUFS; ret = hvs_update_recv_data(hvs); @@ -618,7 +623,7 @@ static ssize_t hvs_stream_dequeue(struct vsock_sock *vsk, struct msghdr *msg, hvs->recv_data_len -= to_read; if (hvs->recv_data_len == 0) { - hvs->recv_desc = hv_pkt_iter_next_raw(hvs->chan, hvs->recv_desc); + hvs->recv_desc = hv_pkt_iter_next(hvs->chan, hvs->recv_desc); if (hvs->recv_desc) { ret = hvs_update_recv_data(hvs); if (ret) From patchwork Wed Apr 13 20:47:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Parri X-Patchwork-Id: 12812618 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 C07EDC433EF for ; Wed, 13 Apr 2022 20:48:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238710AbiDMUuj (ORCPT ); Wed, 13 Apr 2022 16:50:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236542AbiDMUu1 (ORCPT ); Wed, 13 Apr 2022 16:50:27 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DF0F6BDFD; Wed, 13 Apr 2022 13:48:05 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id c6so3878660edn.8; Wed, 13 Apr 2022 13:48:04 -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=uX50zrEMcunrp6nLIwZJ5dpGlndEZgBupE5oS9UHVBw=; b=TWL9gpNoJEn+V3lGRa+0fR4At7GciihC0gb78RaA0RoWmfVHi1tXmtW7DcBqBe9yqq 2SPKbI4tntfHK1tyGMLHSLJ9NUROyqCAqhElxEB0yaPxLgIIFiX2wYSau4QvlQ6RONXB ak8Z3+Wzuh7XnctzCH/+a8XI9SnGfTbXK9Y7KLZ5sgw7MNRQnq6Gnqag8Y3vkGajf39r PG6QavaDM9GuvYU583HpozI7yM9CRr9/bobeXKdnzs8cS/v0PB9XjDZ3lVa45VCIkj8j NQoKQrDYbxhldh7E016l71JTlH4p1VVvvARJMcxDniOFRu9t1ojZnrL2TWEI3asYszM7 DJdw== 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=uX50zrEMcunrp6nLIwZJ5dpGlndEZgBupE5oS9UHVBw=; b=JDpIXmdvklZaqpLJsTSKxZ561cx1mRhqUiwT2yaRgFIbUpLOAIRmGIvLMbZKhiZCoH lCPVdKcaaAimdFQjkTbohtDmyDIa/XcOLaWMr9aLfVgc8rZnSLMPvr9bJGRDwuEyNL3z CU42YO5aZhQVgviXLd09UX7+YVH9LZ/tX3L0i5WqIf7PcGhlxZafN+iXF1OVdJCeGkQr cH/wJe6TCNhjjQzW/iGbJT6AYkZLEtd1ibbpTZl6QjxPZFxgdpIp9sKNE14sFcShup9H oLeGlPSkJLTcN4fhgyF0CoxaBM9cUzp2WOIHUqs9pt6GXG6PaaevFPfZUduKV3FGfwCp FGdA== X-Gm-Message-State: AOAM531WduXZzYFVTaQoIrovyKiRKb2C08MVZL9OSYsL/ZQOBIOGVDRS eXM7xYU1ZL+vplZGhS9FXnQ= X-Google-Smtp-Source: ABdhPJySzy/JUA65EoxoFNi6q8hH2CXbLx6rEKSP9cs/VZa0h3yJrQW+MvpCp6+9if/E6dpx2eMtCg== X-Received: by 2002:a05:6402:d62:b0:41d:79e6:1617 with SMTP id ec34-20020a0564020d6200b0041d79e61617mr18485763edb.378.1649882883512; Wed, 13 Apr 2022 13:48:03 -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.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 13:48:02 -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 3/6] hv_sock: Add validation for untrusted Hyper-V values Date: Wed, 13 Apr 2022 22:47:39 +0200 Message-Id: <20220413204742.5539-4-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 For additional robustness in the face of Hyper-V errors or malicious behavior, validate all values that originate from packets that Hyper-V has sent to the guest in the host-to-guest ring buffer. Ensure that invalid values cannot cause data being copied out of the bounds of the source buffer in hvs_stream_dequeue(). Signed-off-by: Andrea Parri (Microsoft) --- include/linux/hyperv.h | 5 +++++ net/vmw_vsock/hyperv_transport.c | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index fe2e0179ed51e..55478a6810b60 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -1663,6 +1663,11 @@ static inline u32 hv_pkt_datalen(const struct vmpacket_descriptor *desc) return (desc->len8 << 3) - (desc->offset8 << 3); } +/* Get packet length associated with descriptor */ +static inline u32 hv_pkt_len(const struct vmpacket_descriptor *desc) +{ + return desc->len8 << 3; +} struct vmpacket_descriptor * hv_pkt_iter_first_raw(struct vmbus_channel *channel); diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c index 8c37d07017fc4..092cadc2c866d 100644 --- a/net/vmw_vsock/hyperv_transport.c +++ b/net/vmw_vsock/hyperv_transport.c @@ -577,12 +577,19 @@ static bool hvs_dgram_allow(u32 cid, u32 port) static int hvs_update_recv_data(struct hvsock *hvs) { struct hvs_recv_buf *recv_buf; - u32 payload_len; + u32 pkt_len, payload_len; + + pkt_len = hv_pkt_len(hvs->recv_desc); + + /* Ensure the packet is big enough to read its header */ + if (pkt_len < HVS_HEADER_LEN) + return -EIO; recv_buf = (struct hvs_recv_buf *)(hvs->recv_desc + 1); payload_len = recv_buf->hdr.data_size; - if (payload_len > HVS_MTU_SIZE) + /* Ensure the packet is big enough to read its payload */ + if (payload_len > pkt_len - HVS_HEADER_LEN || payload_len > HVS_MTU_SIZE) return -EIO; if (payload_len == 0) From patchwork Wed Apr 13 20:47:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Parri X-Patchwork-Id: 12812619 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 78667C4332F for ; Wed, 13 Apr 2022 20:48:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238742AbiDMUuk (ORCPT ); Wed, 13 Apr 2022 16:50:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237733AbiDMUui (ORCPT ); Wed, 13 Apr 2022 16:50:38 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBAA471EE9; Wed, 13 Apr 2022 13:48:07 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id b15so3897619edn.4; Wed, 13 Apr 2022 13:48:07 -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=f1sb4UJO60vFzMQ7jSbq55RolpNBURxLc/zOFDSJzng=; b=RZHBRZwdWQj4k166dR00upgLdsBBe5YQG0YMmIxueE8ZdGl7slEHuajU9J58ek4IU4 aUo8x9QIOO//Ygo7SvIOrbz2eHEOg1wWzUVnYA1kVNmrPhIw5mV8oIPkoSVF5/fiqR3c 4UrFripKq7coAIlwM6QqMxcV7r1q/QTGGmoOK2S1DP+VGtnAS+YYADLhV1O9wzrEypVm GKnATg8rr+EucS48uRGjkyVm3NWZ9XlAZhMm5SeA+baTyxmNzXSIq6WV3Xy02e6M3UBN H3Jfm6/1somOLOl3mrdGFjrriz//+hoPyf4Jy5ueG3yZvSdQaDzKpsUA7t+bvJcKhzKO KHng== 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=f1sb4UJO60vFzMQ7jSbq55RolpNBURxLc/zOFDSJzng=; b=ND9ZZvN0I764QE7ofq3vj3B+oLKAfpQXzF/kPl6BE9T0lPa4Lfs5d2U+dXm8W3QcqT v+/aYeZP4UESDbFuf2XJEnZKN8ed3wKdhxcjnR+luKFc7TM+ZJDzpPWuClRqNpLZ17kh TVZk36nRLFop3UVkjuGf+UWE5MFm6oODmATvvUMmswwRNGPjxrn3oQd9XAzXLDOA5+p9 l9pXThV7pI+Sbwf5YzAdNhp6jMjCmhDokU5wlMIrcEpOoSinki2/GhAJrA78zA23TvOW m4DCC93gH5rXWo3Hqs3Yq8MxDc5lojy+yeBiEqDOlL56E4BCuXklcwN2888a1xF00eU8 wu+Q== X-Gm-Message-State: AOAM530GZX+MN0/3/De+FQ8F5/oAwcc1SPozEYc43mmlMFjACtuP2xmu gwDUzTS+lgpdWl/4gERo4jM= X-Google-Smtp-Source: ABdhPJxZ9PWnW1BIcct9QDxfoPrYL/4Isc8Lg5OgyZOPAZr2NRGisB65l3qSSHAgI4rVCfM1ObtBAg== X-Received: by 2002:a05:6402:1112:b0:413:3d99:f2d7 with SMTP id u18-20020a056402111200b004133d99f2d7mr45665365edv.23.1649882886236; Wed, 13 Apr 2022 13:48:06 -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.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 13:48:05 -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 4/6] hv_sock: Initialize send_buf in hvs_stream_enqueue() Date: Wed, 13 Apr 2022 22:47:40 +0200 Message-Id: <20220413204742.5539-5-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 So that padding or uninitialized bytes can't leak guest memory contents. Signed-off-by: Andrea Parri (Microsoft) --- net/vmw_vsock/hyperv_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c index 092cadc2c866d..72ce00928c8e7 100644 --- a/net/vmw_vsock/hyperv_transport.c +++ b/net/vmw_vsock/hyperv_transport.c @@ -655,7 +655,7 @@ static ssize_t hvs_stream_enqueue(struct vsock_sock *vsk, struct msghdr *msg, BUILD_BUG_ON(sizeof(*send_buf) != HV_HYP_PAGE_SIZE); - send_buf = kmalloc(sizeof(*send_buf), GFP_KERNEL); + send_buf = kzalloc(sizeof(*send_buf), GFP_KERNEL); if (!send_buf) return -ENOMEM; From patchwork Wed Apr 13 20:47:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Parri X-Patchwork-Id: 12812621 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 6A31EC433FE for ; Wed, 13 Apr 2022 20:48:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238694AbiDMUu5 (ORCPT ); Wed, 13 Apr 2022 16:50:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237637AbiDMUui (ORCPT ); Wed, 13 Apr 2022 16:50:38 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 530D87664C; Wed, 13 Apr 2022 13:48:10 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id r13so6364938ejd.5; Wed, 13 Apr 2022 13:48:10 -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=ERngG/+UkX04UrTeyi1yRhI11saChXCJ4vIv5MaGog8=; b=TLhjxCHZNdk3pY77Gef51LCa+6ZR8fEoPlSLGxjBCvnCWZmjnqZKTvfNLy94sqP3pX X7C/QWHfSIwPBTmKgpcxbZLp3UUCezCGIbz4vPFKo7u8vPjELC5DRMchF4ZSg7/B768U /5u7JmSh09QNZ+/TF+8KQgwlvv3YjHDwgIN20IWYqdB3MiKTVsK6OrQ8ivjb0IpJtY83 rkAyFYbLpSeUZvThk44Py2+o0LWHCcz3SP8xXbIsl6qGM0AkKkNoVTbTI/6c7Poqok5M lXK7AWllhfC9RxFaT7LYP+xB7U+TXsQkktDyIffO0GPvlCgokuKxgwOy+PWCPKNREaOB GM3w== 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=ERngG/+UkX04UrTeyi1yRhI11saChXCJ4vIv5MaGog8=; b=3HLrUxZPKnFOvS7zmT6FDEbze4VOc6vW/J5hTTn8b6cP3i4Sm4j1qRXa8IqwHQWABr eMDwGlnUKKxlXUYuVBDwAfpTUKTMmpZsqZ7j++bMWburCvc3jk8YzyyRLbMEHV37awmY j/CcyNfhjaz1g0adUwwLkkJxgCW6Vcr9x4ZbPtYFyg3XS78RrpHsdSFAkR1pW03hJGLi RN8bIjEKVDTywnGUmIFGrPxxt90oM87hlI/QhT7MYBp82FnbydJpPMvJMguCcFNTdxqp 7Z8KESNhAwMmfwDL1se3BUnub+YW92ZlKvZwTo4h4LpUUHSnn2vGlVb4MjHXHuIpspRf hgMg== X-Gm-Message-State: AOAM532OVhw91uX9GVRvSyJ/n70TBkfra1TFJwRuXg4yRpciKpbIMnVa 45Ec0zmhq28mt5dUUP77aDE= X-Google-Smtp-Source: ABdhPJzGPZHll4Do/+ggPuEu9rE4IzOA7R2SMrNiSYNqGF80JAmYhYMXTGAHWAY5oKo/eWNvYRU3lA== X-Received: by 2002:a17:906:c092:b0:6ce:1018:9f4e with SMTP id f18-20020a170906c09200b006ce10189f4emr40702210ejz.430.1649882888829; Wed, 13 Apr 2022 13:48:08 -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.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 13:48:08 -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 5/6] Drivers: hv: vmbus: Accept hv_sock offers in isolated guests Date: Wed, 13 Apr 2022 22:47:41 +0200 Message-Id: <20220413204742.5539-6-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-State: RFC So that isolated guests can communicate with the host via hv_sock channels. Signed-off-by: Andrea Parri (Microsoft) --- drivers/hv/channel_mgmt.c | 9 +++++++-- include/linux/hyperv.h | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 67be81208a2d9..83d7ab90b7305 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -976,17 +976,22 @@ find_primary_channel_by_offer(const struct vmbus_channel_offer_channel *offer) return channel; } -static bool vmbus_is_valid_device(const guid_t *guid) +static bool vmbus_is_valid_offer(const struct vmbus_channel_offer_channel *offer) { + const guid_t *guid = &offer->offer.if_type; u16 i; if (!hv_is_isolation_supported()) return true; + if (is_hvsock_offer(offer)) + return true; + for (i = 0; i < ARRAY_SIZE(vmbus_devs); i++) { if (guid_equal(guid, &vmbus_devs[i].guid)) return vmbus_devs[i].allowed_in_isolated; } + return false; } @@ -1004,7 +1009,7 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr) trace_vmbus_onoffer(offer); - if (!vmbus_is_valid_device(&offer->offer.if_type)) { + if (!vmbus_is_valid_offer(offer)) { pr_err_ratelimited("Invalid offer %d from the host supporting isolation\n", offer->child_relid); atomic_dec(&vmbus_connection.offer_in_progress); diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 55478a6810b60..1112c5cf894e6 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -1044,10 +1044,14 @@ struct vmbus_channel { u64 vmbus_next_request_id(struct vmbus_channel *channel, u64 rqst_addr); u64 vmbus_request_addr(struct vmbus_channel *channel, u64 trans_id); +static inline bool is_hvsock_offer(const struct vmbus_channel_offer_channel *o) +{ + return !!(o->offer.chn_flags & VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER); +} + static inline bool is_hvsock_channel(const struct vmbus_channel *c) { - return !!(c->offermsg.offer.chn_flags & - VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER); + return is_hvsock_offer(&c->offermsg); } static inline bool is_sub_channel(const struct vmbus_channel *c) From patchwork Wed Apr 13 20:47:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Parri X-Patchwork-Id: 12812620 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 CB0B1C433F5 for ; Wed, 13 Apr 2022 20:48:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238693AbiDMUuo (ORCPT ); Wed, 13 Apr 2022 16:50:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238729AbiDMUuk (ORCPT ); Wed, 13 Apr 2022 16:50:40 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E33E983B1D; Wed, 13 Apr 2022 13:48:13 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id bg10so6377349ejb.4; Wed, 13 Apr 2022 13:48:13 -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=+zgbrTLpNU3XbVpcZAEA03NRL/Qn9JM6rnRzwV0uwFE=; b=jmorgWFE3Zkh2E6vy9kyEQFLtT5S6q5gSJdf23Pix4smxSFMp3p3vZam5vSEdmF9r8 YqDFp7QzrJZ8RDxpJHB9XXeL89mMBXZOpcotPUPqAHPVYyvhiukswiS9Ee25tY2kibgA dekV6K1YfdMQDu0emncIBrqqOYSyZjwelSTDYcO/JxmBX+g+AkEyc4ltLHi06tTrw2hD vpd5CcHNMcVohRzCrpZKlaSHW0TmzaFhpKtX7N8qnJvFpwaNXFhNLY4YOmzmpVgmZjva 7wKTKEUN9Qbd2glEqtm1c86SUDxyFEcWejRYQlXGhUxBrprTmv9lT45xQCk7Tbi8DaIV XaSA== 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=+zgbrTLpNU3XbVpcZAEA03NRL/Qn9JM6rnRzwV0uwFE=; b=55fPZ+FAr0cD6LAJlEj1AOhIJX7voDRqgPdDMYU0guomNujCDw4ib3aUSy1I/XONrM gvpedYlFhr/V/bzg68JykaOQgmQns1aU0JhahXYlp9l8CC8V9mudfr8GwkooWomb2RWF yNyiGX3YJVG/VvLLhRlbVKYbF9kQqRpZYDubTXAZtNVpgOakndIkdLgjgBfE5XRd6lif Y7+xO65xtWpBDMnxTMoiTK9rZg4sIZ3GDSJ0M5lsg0ihWVZ7YFDc0wa/h6tfJMXyVkgW Y0qvLXnHI3O1tEikk0Pnbc5L4+y83LxidiPBN/3exuhy7V6PSVD/aD2JQgNqhckjKHV0 b5FQ== X-Gm-Message-State: AOAM531iCH37eFxlvlgcZF9DXgBUDcL0+8JABtUJEx+0w7e2Pojjx3YN OEmckr/l1BWiAT+5jBJ6zId64AUvhE6/0hh9 X-Google-Smtp-Source: ABdhPJyu9eKM4t589+KiDfysMd52ZbJVG8i+76iicT//pZfSwCoJGqTSTngOFI83dkHofzdn+iOA+A== X-Received: by 2002:a17:907:9493:b0:6e0:59f5:6705 with SMTP id dm19-20020a170907949300b006e059f56705mr41913922ejc.289.1649882892317; Wed, 13 Apr 2022 13:48:12 -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.48.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 13:48:11 -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 6/6] Drivers: hv: vmbus: Refactor the ring-buffer iterator functions Date: Wed, 13 Apr 2022 22:47:42 +0200 Message-Id: <20220413204742.5539-7-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-State: RFC With no users of hv_pkt_iter_next_raw() and no "external" users of hv_pkt_iter_first_raw(), the iterator functions can be refactored and simplified to remove some indirection/code. Signed-off-by: Andrea Parri (Microsoft) --- drivers/hv/ring_buffer.c | 11 +++++------ include/linux/hyperv.h | 35 ++++------------------------------- 2 files changed, 9 insertions(+), 37 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index 3d215d9dec433..c9357dae2a2c8 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -421,7 +421,7 @@ int hv_ringbuffer_read(struct vmbus_channel *channel, memcpy(buffer, (const char *)desc + offset, packetlen); /* Advance ring index to next packet descriptor */ - __hv_pkt_iter_next(channel, desc, true); + __hv_pkt_iter_next(channel, desc); /* Notify host of update */ hv_pkt_iter_close(channel); @@ -459,7 +459,8 @@ static u32 hv_pkt_iter_avail(const struct hv_ring_buffer_info *rbi) /* * Get first vmbus packet without copying it out of the ring buffer */ -struct vmpacket_descriptor *hv_pkt_iter_first_raw(struct vmbus_channel *channel) +static struct vmpacket_descriptor * +hv_pkt_iter_first_raw(struct vmbus_channel *channel) { struct hv_ring_buffer_info *rbi = &channel->inbound; @@ -470,7 +471,6 @@ struct vmpacket_descriptor *hv_pkt_iter_first_raw(struct vmbus_channel *channel) return (struct vmpacket_descriptor *)(hv_get_ring_buffer(rbi) + rbi->priv_read_index); } -EXPORT_SYMBOL_GPL(hv_pkt_iter_first_raw); /* * Get first vmbus packet from ring buffer after read_index @@ -534,8 +534,7 @@ EXPORT_SYMBOL_GPL(hv_pkt_iter_first); */ struct vmpacket_descriptor * __hv_pkt_iter_next(struct vmbus_channel *channel, - const struct vmpacket_descriptor *desc, - bool copy) + const struct vmpacket_descriptor *desc) { struct hv_ring_buffer_info *rbi = &channel->inbound; u32 packetlen = desc->len8 << 3; @@ -548,7 +547,7 @@ __hv_pkt_iter_next(struct vmbus_channel *channel, rbi->priv_read_index -= dsize; /* more data? */ - return copy ? hv_pkt_iter_first(channel) : hv_pkt_iter_first_raw(channel); + return hv_pkt_iter_first(channel); } EXPORT_SYMBOL_GPL(__hv_pkt_iter_next); diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 1112c5cf894e6..370adc9971d3e 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -1673,55 +1673,28 @@ static inline u32 hv_pkt_len(const struct vmpacket_descriptor *desc) return desc->len8 << 3; } -struct vmpacket_descriptor * -hv_pkt_iter_first_raw(struct vmbus_channel *channel); - struct vmpacket_descriptor * hv_pkt_iter_first(struct vmbus_channel *channel); struct vmpacket_descriptor * __hv_pkt_iter_next(struct vmbus_channel *channel, - const struct vmpacket_descriptor *pkt, - bool copy); + const struct vmpacket_descriptor *pkt); void hv_pkt_iter_close(struct vmbus_channel *channel); static inline struct vmpacket_descriptor * -hv_pkt_iter_next_pkt(struct vmbus_channel *channel, - const struct vmpacket_descriptor *pkt, - bool copy) +hv_pkt_iter_next(struct vmbus_channel *channel, + const struct vmpacket_descriptor *pkt) { struct vmpacket_descriptor *nxt; - nxt = __hv_pkt_iter_next(channel, pkt, copy); + nxt = __hv_pkt_iter_next(channel, pkt); if (!nxt) hv_pkt_iter_close(channel); return nxt; } -/* - * Get next packet descriptor without copying it out of the ring buffer - * If at end of list, return NULL and update host. - */ -static inline struct vmpacket_descriptor * -hv_pkt_iter_next_raw(struct vmbus_channel *channel, - const struct vmpacket_descriptor *pkt) -{ - return hv_pkt_iter_next_pkt(channel, pkt, false); -} - -/* - * Get next packet descriptor from iterator - * If at end of list, return NULL and update host. - */ -static inline struct vmpacket_descriptor * -hv_pkt_iter_next(struct vmbus_channel *channel, - const struct vmpacket_descriptor *pkt) -{ - return hv_pkt_iter_next_pkt(channel, pkt, true); -} - #define foreach_vmbus_pkt(pkt, channel) \ for (pkt = hv_pkt_iter_first(channel); pkt; \ pkt = hv_pkt_iter_next(channel, pkt))