From patchwork Thu Jan 6 06:47:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Raphael Norwitz X-Patchwork-Id: 12705165 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 90BB7C433FE for ; Thu, 6 Jan 2022 06:59:42 +0000 (UTC) Received: from localhost ([::1]:53774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5MkP-0007Mz-Mj for qemu-devel@archiver.kernel.org; Thu, 06 Jan 2022 01:59:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5MYh-0001HA-1S for qemu-devel@nongnu.org; Thu, 06 Jan 2022 01:47:38 -0500 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]:22680) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5MYc-0003TU-T4 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 01:47:33 -0500 Received: from pps.filterd (m0127837.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 205N5d7i019176; Wed, 5 Jan 2022 22:47:25 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : content-type : content-id : content-transfer-encoding : mime-version; s=proofpoint20171006; bh=RDK4ZRwt0SKhzgZpZmio5GwTX9vjVbizSaPKr/pCvq4=; b=xEDoaB62222BmAR2AtLIHXVTnb8CY5lVdSaFVTtZFNIMIZg2v5ofnXzUvpEHlAz+9i5O UPPWEO2HMEUcD4hjjjRMKIpBzzMT5QiAScqclvrsKeeOafDSKRfyp4gkDZQPslmbn1vs +bYJ68OxdP5XrHIiNmn+3ueYL1mf4PcLG9YcS3vsoMa+2zqaDBWK1Jc8w7a5lJajEvPK ggymx/7HLokfrESM9GZH0Yp7PH2YWB5L4LZF5LMhfFCJbWKVwx4c/Me2gDSVUSO72J9s J+5o2Umn956sIMWrgbtPA6oF6f3DHnB4JDD1qcE5DnaYsqhGe7kpzO6Oqpxnn7BSi+LS /A== Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2046.outbound.protection.outlook.com [104.47.74.46]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3ddmq00jfg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jan 2022 22:47:25 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eblkq/X6gSuSZOyif/PE+8ivV6fA+MRFIdx3JM0xXnRvRgDwzePD1VKB7/nZv8Rebkm1Va656FKrDitUhW6PNG11c9N0V76zu3cd2cIDikQhFbR7p/5m5HPCYAkyNjHsrwFtE+dsSuNNI03R5r07V6yTxW4tNfXZlcfL5JtIZoXE8pEtElsvT31WY9xT4wYxsSlRLGAoOnHCxsiTEHVDj11NmYmM96DqjAh6c0P9xGgkvqGjwtBGNBWM77+qDR8JNro5s7q91tGQNOZEbZXj88S72rW+CqoohxhQjvq98bFocu9oZBrYMZZYRreGEZmrf2OAfnc7kaEFp/Ox4/TU5w== 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=RDK4ZRwt0SKhzgZpZmio5GwTX9vjVbizSaPKr/pCvq4=; b=eNeGMgbJThBgMOTt2IdT20mduJk4L5x7K9SijOFzso0cUpn3HCnQ71dzLrQI3ti8VhHQtxXnMNiX/qPhQKbUlStBV7x2bLwpqB0RDX6ezGcILoyveoPxdYf7Vlk5pU48Gyc9yl4zd2lPwnOn8KMVuG5nmESRIDwyKW6ffQ+Qsi60cYlv/7oUQSouE1M4utvp8IzTpUyKpKVCvcH6DgmBi2egAw5wB5v0G+bzTCaDlG9SOXnBxaHubkA+lXkE2M/nrjZ1BYCBLcGOQV0pK+y+knMYAeHpcCHkCy4Hcn782VGaH9OuDlWhq9OmrPufZHjI7e54UG7tZNdnlBSB8W7/3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from BL3PR02MB7938.namprd02.prod.outlook.com (2603:10b6:208:355::20) by BL0PR02MB6530.namprd02.prod.outlook.com (2603:10b6:208:1c1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.7; Thu, 6 Jan 2022 06:47:24 +0000 Received: from BL3PR02MB7938.namprd02.prod.outlook.com ([fe80::3c2f:b2dd:a0b5:74da]) by BL3PR02MB7938.namprd02.prod.outlook.com ([fe80::3c2f:b2dd:a0b5:74da%6]) with mapi id 15.20.4867.009; Thu, 6 Jan 2022 06:47:24 +0000 From: Raphael Norwitz To: "stefanha@redhat.com" , "marcandre.lureau@redhat.com" , "mst@redhat.com" , "david@redhat.com" Subject: [PATCH v2 0/5] Clean up error handling in libvhost-user memory mapping Thread-Topic: [PATCH v2 0/5] Clean up error handling in libvhost-user memory mapping Thread-Index: AQHYAslCTexIUVU8PEm04h1374z/dA== Date: Thu, 6 Jan 2022 06:47:24 +0000 Message-ID: <20220106064717.7477-1-raphael.norwitz@nutanix.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.20.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 43f45ab2-7770-40b4-b192-08d9d0e0655c x-ms-traffictypediagnostic: BL0PR02MB6530:EE_ x-microsoft-antispam-prvs: x-proofpoint-crosstenant: true x-ms-oob-tlc-oobclassifiers: OLM:6790; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: tSWsGRp90iTaIS/gN225iVNESBPOf6A+otaB/I0KYxMduFxcz3sUQ6IKuUSlCPALVGO/jFgfV9BNskQLj2tH6i7HCUW8VyE/5ETkaHm5vJ5abHqhDQtU54TVyCZM0aX13XGB3S5j+O/cCCfqiY3ITf5u2CVzRVG5gmXtk6BKla5mu8788rZDdZcMY8s/gdAZugan5ZFC6q63vj+UoL7pttH35zzCULsYmHiHRkMC2VCFtAjpDajLztTprxjKoq5bgmDAL6gGjJRyN0EOG958YTkCyOzzsSe4z2XvXVPOaa4chrFy1Mos14EqRNuXIKttn6BZHsxkdsxiJ3kYfchwQCPWr/KyY9NsgQQxR8PFUhLT3KI2RW5Spkg5+2ZsoCKv7wd24xPFCEhGfw7dg5mENbxtJ7e2JJjU1svHRmjqgIWgpZnZ5NSztAHngXEtbfa69+1kFjy2BTy7tdXQksMcjGDfH4lS+cjWlPA38Lqtu+Tg6K6yhJLU4buGqgPxT/X6E/rMeHouHgBvYf0R0WDQ85dLJtQA4Hld2d/CMrq+S8QNeB/G4Tf0snH5QvYWRKPKdcuKMfDBOoY2jLw0/tI/gKCEL8dhoO3IVNyE3Eikd0EKMertxKAcF/XmeRFJeAoZS1DM5Ic802JDOqM+3jb8DdxX92Gmf8fSeMup+QEWeLcNIgkdo+FEqtPc71rMVpR60PsqQhyFWm4Nnz5UJwOBKXmwTNZ5BqtX0fahuKe6PUU3qeRwwV5vPOmvTZGIZznOhHP9h7u/L0S+spiqRHkzYX/lNKRu3T3LYoxgAjfqxie0noc+lGs2QNvT72zIKphz+tqzUmRFfqrOMRMGC+s01Q== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL3PR02MB7938.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6506007)(508600001)(66446008)(4326008)(76116006)(186003)(2906002)(966005)(316002)(122000001)(6512007)(66476007)(71200400001)(66556008)(66946007)(5660300002)(91956017)(64756008)(54906003)(6486002)(38070700005)(110136005)(44832011)(36756003)(83380400001)(1076003)(2616005)(38100700002)(86362001)(107886003)(8676002)(26005)(8936002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?3sGW5+PDMcrC0ceTt100Zz+vuRBj?= =?utf-8?q?utT5V2HChvXEOEaFP0aIH8dwIeqLl2J2jU4OL+qGAZMcD99wPo4jT5qh3HCafEyn9?= =?utf-8?q?wzCWhZdeDNdaSPBNmn7UUwgmyFU2p7L/QkTLwcHk8AeDXAyeQtS6JvQcjz4gwmyZa?= =?utf-8?q?6a/5wHsWCVqNAPf7KEm5fpB/DW5+5OJf76uB7SJC0ds50BM5yGxfUChzYtc79jFiw?= =?utf-8?q?5JxMkrz3ya6Z2eGV/TD6FYES43dQPA1EwPG7M4xKpRgYirkhXufek/q0Qzks2R07n?= =?utf-8?q?su4iFd0+smxrtwJ7jyAL4Jnd1eIOvR6JTxB04YzjgtO0kP27QLCWHPS96m8Q/azwQ?= =?utf-8?q?oYuTi7lF6LwU7DZqF8UpqJy4i+WVWnKVWjLusOFkYqazMMUafPeQqFXRlGQtpErFK?= =?utf-8?q?TCAL1Ci1bVENeIKA5cTuapwwB0JyD73ktr/Kys56yMGwM8kLbZoMxPSzDeXfzmdGZ?= =?utf-8?q?MUSxrArSBeKm07mSouZOxVWeBcx1DIvqGftP9g+3P/tAwmuLayK6q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8?q?PjPLz1evBgI+vEt0txS2HOCdqIP9hu3Fq6L1+WTAuH+EEZ/49j/xdNbJ9dHQ5ZSzk?= =?utf-8?q?r7WTkBQ+l4ZZtLLU9xPSZuVaLrA0auJk0N9KkiESlhPM8J/6gy6nUKBqDiCXmYuBu?= =?utf-8?q?VGGe3zhMwJF/ZBJbPcXBIcPhlV42Lbuw7xy3qcY0r0ch3Z/IiLqjADCBvo7JQJaKc?= =?utf-8?q?Sb9clixmQgWkm2ZCWdiCc1TOAlfTCJJLcSUxgOzH/6wxAScjVXqt5s=3D?= Content-ID: <85CB53B1FF3C8A4E888F37A724E7451B@namprd02.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BL3PR02MB7938.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 43f45ab2-7770-40b4-b192-08d9d0e0655c X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jan 2022 06:47:24.0680 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: YhTWmFmnIs1MzI3riFyYb10/y7yhGTzlxEO5wvZ7lSP8XTbHRmf0aWB7kVwFDpHhb/kF0otUwzP+q4TjUpnAp7ip6SIgjoYei6UOcwHpePY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR02MB6530 X-Proofpoint-GUID: jivIxkcDWXMV-X1jsnIZGnC_THVj0SI3 X-Proofpoint-ORIG-GUID: jivIxkcDWXMV-X1jsnIZGnC_THVj0SI3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-06_02,2022-01-04_01,2021-12-02_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.151.68; envelope-from=raphael.norwitz@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "raphael.s.norwitz@gmail.com" , "qemu-devel@nongnu.org" , Raphael Norwitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Hey Stefan, Marc-Andre, MST, David - As promised here is a series cleaning up error handling in the libvhost-user memory mapping path. Most of these cleanups are straightforward and have been discussed on the mailing list in threads [1] and [2]. [1] https://lore.kernel.org/qemu-devel/20211018143319.GA11006@raphael-debian-dev/ [2] https://lore.kernel.org/qemu-devel/9391f500-70be-26cf-bcfc-591d3ee84d4e@redhat.com/ Changes since V1: * Checks for a single fd vu_add_mem_reg and vu_rem_mem_reg return false instead of true. * Check for over-running max ram slots in vu_add_mem_reg returns false instead of true. * vu_rem_mem_reg unmaps all matching regions. * Decriment iterator variable when looping through regions in vu_rem_mem_reg to ensure matching regions aren’t missed. Thanks, Raphael David Hildenbrand (1): libvhost-user: Simplify VHOST_USER_REM_MEM_REG Raphael Norwitz (4): libvhost-user: Add vu_rem_mem_reg input validation libvhost-user: Add vu_add_mem_reg input validation libvhost-user: prevent over-running max RAM slots libvhost-user: handle removal of identical regions subprojects/libvhost-user/libvhost-user.c | 51 +++++++++++++++-------- 1 file changed, 34 insertions(+), 17 deletions(-) Reviewed-by: Stefan Hajnoczi