Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1027343pxb; Fri, 15 Apr 2022 18:49:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwu3qjUVivY7pWKU1xnUwBo5aRYv6y6ZRZ03T1gX+3oHfsrrgemhf1bcikEIwhU/ANWKept X-Received: by 2002:a17:903:40c5:b0:158:b603:ab10 with SMTP id t5-20020a17090340c500b00158b603ab10mr1457375pld.124.1650073796804; Fri, 15 Apr 2022 18:49:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1650073796; cv=pass; d=google.com; s=arc-20160816; b=CFKxFcNsyS/XrepYLtnaWNWhv+BueUJXOF7RFhes/v4hWExCoUKWKDJYMX9WHtPZil Y0/OZwcVI0YDGp91v2a2kJERz+bmVjaznUVw+Nhj2PjpRy6X1HmOGOJaA5B+rYwds2bF 7oMGAaZFSNBsy7E9yHe5p6Z/v0sc8CLpzlFi3yIx9+xGjUjyDuxMZmI232Z3zb/M+Zb+ hjr6BmpVsST1AEJtjtrX69b7Et1k4c+h/dzI6eMHDcm0txXHdiVa4JehA9Rz1zB6hwxe +pFpGTeZNAmG02XwGrA9K9Kca7S4Xvo/fcOngRGhoH3I2MRwQ6U51dJGrlAh3AfGra4G /w3g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :msip_labels:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=oE+0kcG0nFf4Cp8FAxuuPilphi0A3yjSQGaZKt4gk8s=; b=GRYcRVeT18QfnfhXWHd2u0EFtnB5o+pSOTb/H45ItY8Phwiue1BAWgo58iuGFCoMce UZcPCZ6xy9ZDB0Ljhx1WS04/BIs9JC6vVSMKwVpAXAnYdsaEoLQYPcOxRoUrPBB2UpNe zmMn5WCQqvgct9pAJ65KYevhbcnKffkGqYDqAnQDonR5h28LuNFTIp0Z7deaTDcnJbXh g0NZ/SDYimusnf0QZuHud8R4VV2LxAzK5zc6Qb3gdJxhIYvlW00iR0rZdr9Ir8h88NAQ BkE7FICS3FZgM6ECkveLxTmsXWQ8R4iK236HWh7pTt/+EGSGecN08MKEdCjj6NdcXbK4 71Nw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=doFpP7dT; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w7-20020a056a0014c700b0050a44f4ff30si2832629pfu.338.2022.04.15.18.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 18:49:56 -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=@microsoft.com header.s=selector2 header.b=doFpP7dT; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6909818B789; Fri, 15 Apr 2022 18:12:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349254AbiDODxW (ORCPT + 99 others); Thu, 14 Apr 2022 23:53:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349272AbiDODv4 (ORCPT ); Thu, 14 Apr 2022 23:51:56 -0400 Received: from na01-obe.outbound.protection.outlook.com (mail-cusazon11020016.outbound.protection.outlook.com [52.101.61.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C517A10D8; Thu, 14 Apr 2022 20:49:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W0PkqUUY0/z2YJyXCgJlgW9bDt9GHsfujBjYP+VIIhIKBZg39gJCN3wYRCNpjh1DkoOocgRvVtCk9933d5FiTfiPHbrNTv+GPB/yZbF7hoIwrTCJAsJGxNZ6q7g7Xu1PrVf95hAD3ncGAUQkdkPFk+gv8aDeXS8bN+ASmgr8H7omdm68ie041goBbKmcP7U0OPUE4SqXIBOAtQqBzGbXkz4Qfh40mNJQmLpNt5Jz3Md2WE+MFU38rhHqeDmKX7GUtQs8juoVzl4IJIRy25XhgtN4tAARe8WwhrlQrg/dRAiYFGC6CI0arTBiLl6k54uYEg7nslCTQKIVHlsOegxrvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oE+0kcG0nFf4Cp8FAxuuPilphi0A3yjSQGaZKt4gk8s=; b=YFHM2FrLTFgrgnudsvxbpKkbs5JY2n8RCFc0axbqrtLeCGH2o3Gzdpo3m9fa4uV8KDIMKTnrCgUEj3JQDfYatwNy81iF+yMqevUnoXE8Q0ERb9OJvyGN53/kNQIBc6Y4xGvDxHxCj7SwlfC+dQQMTKJgsb9d5mFtrLzQ/jH/rM3Hw7i3SC3tfbj838V2DdLqgucOa8TCQ8UozHApfY2PlC97Pt789B3axdYgiSpAzM8LucHhRgJqvBI5Q8DsW1xDneWACaxLX5wyZQ+W/3a/ed22BvLqUeqpqU0tfy+fqVtnfiLgCfH9dDo9tRdrEl83eCOMy8Eq8PxKB6jKMkkaXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oE+0kcG0nFf4Cp8FAxuuPilphi0A3yjSQGaZKt4gk8s=; b=doFpP7dTn1tXHEXP/G2A7c90RkgUNeyFYzExvEmkUEp2CAQXjYhLN5r2YaLQ1hjq5MyfBe2FacYZk7Kwv0cB6ZVkmoScanqB1fZjLxnAT+FCWG98DfZlCCR4vuEy1EgaCO/CIj023kKz3FR8MBHjBCyJyrHE3jIEynSfeS4JDds= Received: from PH0PR21MB3025.namprd21.prod.outlook.com (2603:10b6:510:d2::21) by BL1PR21MB3256.namprd21.prod.outlook.com (2603:10b6:208:398::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.6; Fri, 15 Apr 2022 03:33:31 +0000 Received: from PH0PR21MB3025.namprd21.prod.outlook.com ([fe80::ac09:6e1b:de72:2b2f]) by PH0PR21MB3025.namprd21.prod.outlook.com ([fe80::ac09:6e1b:de72:2b2f%9]) with mapi id 15.20.5186.009; Fri, 15 Apr 2022 03:33:31 +0000 From: "Michael Kelley (LINUX)" To: "Andrea Parri (Microsoft)" , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , 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" Subject: RE: [RFC PATCH 2/6] hv_sock: Copy packets sent by Hyper-V out of the ring buffer Thread-Topic: [RFC PATCH 2/6] hv_sock: Copy packets sent by Hyper-V out of the ring buffer Thread-Index: AQHYT3fHt6IPwxyLaEamUw9BuXqN2azvm6mA Date: Fri, 15 Apr 2022 03:33:31 +0000 Message-ID: References: <20220413204742.5539-1-parri.andrea@gmail.com> <20220413204742.5539-3-parri.andrea@gmail.com> In-Reply-To: <20220413204742.5539-3-parri.andrea@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=b8dd29c2-f8ef-44cf-8da9-9362ec2aa95a;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2022-04-14T16:32:57Z;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9cd38c6e-be81-43e9-58e5-08da1e90b67a x-ms-traffictypediagnostic: BL1PR21MB3256:EE_ x-ms-exchange-atpmessageproperties: SA|SL x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: kads88r0HXV2YbL28pGaNEAwjdoRXXU5ajNcXRjuQHJSBAqLZ7Qo3brVTRJVxke+r5W9bnijPXcV5RKy7vnsBelNsX6RiaWu42ubGuyg+Mq0W7YxFxP7Ruum2p1TbvBFkRVGrWUzs12tJzi3uQUiBwopPwGSfRY016OGfC49gRSHN0cOZttHGDopv36ZEScOe8/QPTQDFzguHNIPGnBZXJasjoHgKXkr9tzebB+FqTwt4+V2ARErNreav6MLkboMSFe6c+cf88nRERgQyZFzNAC3EsDgkiKVMkpc7Dqf9KNlL6fRXC5vTQW8FNHw282l0wqpXhM23u+MDoXEXsCIzEAFQsP8mXNQt328JvbU8noZjy2qHQxcHfTu3MSySyXNpGaws2kqBWa5s9AxrvyWpNAEc+RmeJ452RvYGxAY228rIWRbACIuN4oshRE1cxT3je3cUhfOo+B6fR0bmyQzxYB66srFu6rUnfRkoM0Xh/sLH+JUt2qNhMI1aaJHy2dFxvu7r4d8A0FkkGw2o5aTTMB4d7a6JAjJuiQbto0S2076t0AIVvl7W48bp192J3otIdlMSCCWT1FreWp0fBt14Oz4UTxchWyCz1xvjnaGou19AFkkSQgQjZFM56MDHFkCNJw0NwhMsHM9nSZ2v1tFfhaQm02MXrIPCFLsaFm/ssW1A68Laq2VhzevQwvGIJZ5keXvPxU44kJU2BAOASoHLJQyn2HM7SilCAKzNeDduavRBuudEO/515zC+KF9JBcJV9kRkFL/iHxNQ5aByGEXYg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR21MB3025.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(451199009)(508600001)(921005)(55016003)(82950400001)(82960400001)(38100700002)(38070700005)(10290500003)(66476007)(7696005)(122000001)(6506007)(316002)(66556008)(66946007)(54906003)(110136005)(71200400001)(76116006)(4326008)(66446008)(64756008)(8676002)(86362001)(52536014)(8990500004)(83380400001)(33656002)(7416002)(5660300002)(8936002)(2906002)(186003)(9686003)(26005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us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jMqkN9o2HA/mE=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR21MB3025.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9cd38c6e-be81-43e9-58e5-08da1e90b67a X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Apr 2022 03:33:31.1691 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: n4l5Wudax8u/pfqvewKVC2dhFwWRhdy4x4AzJGTmykGgXIqN1WEthxuEeaP1NZktCSKN0C9z0wP88Vv05bm91hJ9YmSPQX4OmeeJetKGzSI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR21MB3256 X-Spam-Status: No, score=-2.0 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,T_SCC_BODY_TEXT_LINE 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 From: Andrea Parri (Microsoft) Sent: Wednesday, Ap= ril 13, 2022 1:48 PM >=20 > 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 s/gues/guest/ > 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. >=20 > Signed-off-by: Andrea Parri (Microsoft) > --- > net/vmw_vsock/hyperv_transport.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) >=20 > diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_tran= sport.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) >=20 > +/* 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; >=20 > @@ -378,6 +381,8 @@ static void hvs_open_connection(struct vmbus_channel = *chan) > rcvbuf =3D ALIGN(rcvbuf, HV_HYP_PAGE_SIZE); > } >=20 > + chan->max_pkt_size =3D HVS_MAX_PKT_SIZE; > + > ret =3D vmbus_open(chan, sndbuf, rcvbuf, NULL, 0, hvs_channel_cb, > conn_from_host ? new : sk); > if (ret !=3D 0) { > @@ -602,7 +607,7 @@ static ssize_t hvs_stream_dequeue(struct vsock_sock *= vsk, > struct msghdr *msg, > return -EOPNOTSUPP; >=20 > if (need_refill) { > - hvs->recv_desc =3D hv_pkt_iter_first_raw(hvs->chan); > + hvs->recv_desc =3D hv_pkt_iter_first(hvs->chan); > if (!hvs->recv_desc) > return -ENOBUFS; > ret =3D hvs_update_recv_data(hvs); > @@ -618,7 +623,7 @@ static ssize_t hvs_stream_dequeue(struct vsock_sock *= vsk, > struct msghdr *msg, >=20 > hvs->recv_data_len -=3D to_read; > if (hvs->recv_data_len =3D=3D 0) { > - hvs->recv_desc =3D hv_pkt_iter_next_raw(hvs->chan, hvs->recv_desc); > + hvs->recv_desc =3D hv_pkt_iter_next(hvs->chan, hvs->recv_desc); > if (hvs->recv_desc) { > ret =3D hvs_update_recv_data(hvs); > if (ret) > -- > 2.25.1