Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp57863lfe; Fri, 15 Apr 2022 19:22:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQ8tMu0dyfEWamYbcKEViCc32HgVPgKlRakJ7UYnM5ukz5AxiXb355SdN9rQZYbmVfJ/8G X-Received: by 2002:a17:90b:203:b0:1cb:bfe7:106 with SMTP id fy3-20020a17090b020300b001cbbfe70106mr7188103pjb.78.1650075724071; Fri, 15 Apr 2022 19:22:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1650075724; cv=pass; d=google.com; s=arc-20160816; b=oUKz6zb1ISRn3NyvyTddynsbxoll39bDkHzs85Lg+mshJ1YkIMYHsr+fIUnr6tJirR 5K6ce9BrJN+E9uZhj3bQkPxhrqIAhRnZz2HJvh45qDr1BWpAHAA+JabHIA6c4VfI5yW+ Bn8i4Y8TNSMuzRdYTvcxoaPDRycdx17DHAuEMFh+PwvRBV1ezekyjc33XGSFnoLklzyb 5snx7XeaN+gqSi5/+pFMOOcPCLT8OqcAith9a6m5ygRzx1kTGRkA2Ed5XMj8sJwfR9s4 xQNlytWWSh/Hp/Mx6JQbfu21hvr4NQTlzi8+N89brE5TUDHKWh00MRjiqGZxiOeMRR86 7hmQ== 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=Gdns2GV/vxR07Jn8/OPo+E5RFbxofHcuv6+F5KYr6HI=; b=VDIfWcBJMTiYXC/PwIHkK90SIPSSUlcrS1nA+apegS4zc1BU9BOaPaf0s/Cli4G4uC 8N+Eermm6jtxV1izYjURp28J8OayKPCcYb28BPqEprLO42xsEJYFCGrOQ7clRuhpsCm+ 5rAOfHWjPS5NjBKYGqCkYK9Rb3T1wKpYEdl23N5WI87Re6fKa1+b6DB+kguPhOi/wlkQ 9mzNMDDLeuB9hsuHkbuzGgSxpfDfKl76uV/LiqhicUe0ebSe8g0G1W/bMUi0EjlgYfFP zUq4vyAoyqqDOGmanr/3QZtS3Yhk/JCsvtuv2Rk7hlu3lDF7VkK/YmA8DlgHBZl6+m2e rRMg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=Ti1GbGI9; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j9-20020a170903024900b00153b2d165d2si2913456plh.474.2022.04.15.19.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:22:04 -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=@microsoft.com header.s=selector2 header.b=Ti1GbGI9; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); 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=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 8DDC815B85E; Fri, 15 Apr 2022 18:35:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349152AbiDODuR (ORCPT + 99 others); Thu, 14 Apr 2022 23:50:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349149AbiDODuP (ORCPT ); Thu, 14 Apr 2022 23:50:15 -0400 Received: from na01-obe.outbound.protection.outlook.com (mail-cusazon11020022.outbound.protection.outlook.com [52.101.61.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 938BF5AA64; Thu, 14 Apr 2022 20:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bbd/kJ5mtka8g4o5Ey8Dw1R3IkAhPQ4y2RQPNgrlLutI3vkTS774b6fLT3Iori1pEBZrBWLVTMKhfMNBgioNrIRwz82YIWolrSiUMraIuu3hRju6FU4sDWpCUtQP/Y6IzMhfeG1QAf8j+uzPIVtOALQVlW7RHjI4qwdfY46ycigHqOqY6/4ep2FqQ0cgAKN8J0q04S9y8+EQ+jpMu5QigBDxKCjqg4pKGW1GSiRr54cqb1wHH1m/RV7WZV/Pek14u/77lYccWo+dt2j89op3CNBP/sc456HTt0IapQbDJJkS4jZLVsoNKvQgPaP0FSje2QR0r3Ho/5Mi8f9OvD/BPg== 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=Gdns2GV/vxR07Jn8/OPo+E5RFbxofHcuv6+F5KYr6HI=; b=XhICG79WzvpcIZeLgvKcPkUsjfhAoM/UY923t5fZC1xkeWlen+pkf9pvU6aDiT79qRquu3EpWN1RE2KGlZoxFs6oM37iHpbAzVplj6zC9M2BZbaZRYHh8NEU2E2HOHd8oipJWkZj2rqFuIfkaJD0MEsGz5F4iGV0rNz+kpukd7S9jf+5umTSCjUY+FSZ6CfaLPWlrp129IUlT84BIj44ZxCGkBEF92iwPXLKD2a6amYWJSeICCZK4F+F7L1rQtW/E2QQf2s77gNHX/lZbm5YncX5Dr/BLlk80VCiiZw0ZPkYt60ofl3x+JEyEmsMspwEk0FplVQi9jTnlNZUUzx1Vw== 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=Gdns2GV/vxR07Jn8/OPo+E5RFbxofHcuv6+F5KYr6HI=; b=Ti1GbGI9ROxrjGWGRtsVGoU+7r7utFDoVKYA1gT7e+nKrGyW/dQBx1XkntkmLl2pa8OU3qdRUVvqJ3v8/TWrBT6Y2OAHazztnqlTa58TTp/z8/lWeHoOm3clnPI7TamzartuZdi6p8vKho4j8TuJhEClVopbLkwAEXlzwP8VBYw= 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:23 +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:23 +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 1/6] hv_sock: Check hv_pkt_iter_first_raw()'s return value Thread-Topic: [RFC PATCH 1/6] hv_sock: Check hv_pkt_iter_first_raw()'s return value Thread-Index: AQHYT3fFI5IGSfWvX0SxiF7md4+Se6zvlcGQ Date: Fri, 15 Apr 2022 03:33:23 +0000 Message-ID: References: <20220413204742.5539-1-parri.andrea@gmail.com> <20220413204742.5539-2-parri.andrea@gmail.com> In-Reply-To: <20220413204742.5539-2-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=ae6a1b47-1f37-4cf4-91b3-8a2f01cb384e;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:11:49Z;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: 1eaa4941-f10c-48ae-9efe-08da1e90b1e4 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: c+9OjzVMlhr02g7uzdWP7ZJespKC1N6G8F0IeNEnq8OB1SlHszX3o5O2+tdBnpP5sZPH6wI3wYZeUj9ydwVqhfcCu4DAutwaIN9MCCCF3cpOV9Kk8JFaQhIJd0pYhv6nobEGulRbh0RoR2Zr7h47nSZsC49hNDA/O8sM6O95BDtq9ZlIjoE6nik0rLKGi+IHiz3h20RnC0QXxJd1k9icGGIA3jpWAOFCPF5arjVB6oseUMuolYEx0o2XQQyLtU0V9Yp1ak4oso9y+s7748X2uRYEj0e/+sBljSt7Lj058GmjWh3D9sIsazGv3FUdVyrNfxRDUvAiHxeU9Jcx/3gTmy1LcHYKhJNuA+TkPkJ5rH8dj8Ygplj11oEKfTt/qImzCuDP+sSnU0E6Q8+aCLV+Wn69EGXQhz2uNpBgqgnuIYtekNBbUtBsIa6CLfyEEtO1w+v8Ptt5Oh3JsekRtcpxoPeASqkVyVta2sAkgMBAOMtGovWYkc91LPBoncwWyrUR0v8w1L6yTSKWSZqqVLj8X5FWdfDgfR2HZPaL6HjOvTO/I98ti9p7WXk6RM8mhraGSg2cdyS2xGDuL1bwzRnw2H3Y7NzS71CkpFs1UKbSNAJXyjK7TOAoK1rGye+StVa2kJGTV0oLML0v3AzwVS0uxaFLWsWHygutg3ATX+l1ByJyJzJ6gg0xwN6H9tUXjW8svdjnVK+yhCHBqa6FlZWYfQGWiAv9wqKX3hpZMaf6FtKzWe0n8aGfhFr/febq5zi605MevtkYF4VMVl3IPSkidQ== 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 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0KFq8b9jtheu5Zzi540V8tW3KJE0zoOvU?= =?us-ascii?Q?rsT54YFz7rvSd9+mbpmKfPBWXM+2OOk=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: 1eaa4941-f10c-48ae-9efe-08da1e90b1e4 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Apr 2022 03:33:23.4570 (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: m2bEU//ObcVEr0tIqBfFOVeorqBCuN3zi0htQ4tPGjmCckGmJyY6/XZKuYEv7FfiuLR8AEb5ETovO1R7VdUkbYfAMNXNEceOy2DYSd4QV0M= 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 > The function returns NULL if the ring buffer has no enough space > available for a packet descriptor. The ring buffer's write_index The first sentence wording is a bit scrambled. I think you mean the ring buffer doesn't contain enough readable bytes to constitute a packet descriptor. > is in memory which is shared with the Hyper-V host, its value is > thus subject to being changed at any time. This second sentence is true, but I'm not making the connection with the code change below. Evidently, there is some previous check made to ensure that enough bytes are available to be received when hvs_stream_dequeue() is called, so we assumed that NULL could never be returned? I looked but didn't find such a check,=20 so maybe I didn't look carefully enough. But now we are assuming that Hyper-V might have invalidated that previous check by=20 subsequently changing the write_index in a bogus way? So now, NULL could be returned when previously we assumed it couldn't. Michael >=20 > Signed-off-by: Andrea Parri (Microsoft) > --- > net/vmw_vsock/hyperv_transport.c | 2 ++ > 1 file changed, 2 insertions(+) >=20 > diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_tran= sport.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, >=20 > if (need_refill) { > hvs->recv_desc =3D hv_pkt_iter_first_raw(hvs->chan); > + if (!hvs->recv_desc) > + return -ENOBUFS; > ret =3D hvs_update_recv_data(hvs); > if (ret) > return ret; > -- > 2.25.1