From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4CF8741C2A; Tue, 7 Feb 2023 06:39:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 37B3A42BAC; Tue, 7 Feb 2023 06:39:01 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id D39A140ED9 for ; Tue, 7 Feb 2023 06:38:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675748340; x=1707284340; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=KDoPgzAvl5k1G8ucq4sKBAdy8rMY4X7qtWeiHxB1B8k=; b=CWsHBkLMgcsKieJvCQAQN09Sm9yWFeerIEPDLieQkG55wKljNjTBnZ2L WcfdzrAx7q8+FiIng2Nx0KruK/37mZ6xP4eejZ8/9xtiOGnIyjGXLbNzD HXEAeNAoMaZx3vYD+Ur1iGBN6yx/H5N35IrcRCTXwxDQVhcGgV5DdMjQv mCfPw9ySjecLtPLJFa4ELPrEO5tMreuP08YEatPAk3JS5ih0sJVR2CwE9 3B9Cr+u2lCBncfg9TmnFDKibPm9VZRnHESaNaCp1hfH8ln9fTIbmSmT/7 f+KBV1VyfYyXVWp1nU7/ToD77v+94CW50ImjwACDdDa0EnH0CissAcP0K A==; X-IronPort-AV: E=McAfee;i="6500,9779,10613"; a="356779190" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="356779190" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2023 21:38:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10613"; a="668668626" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="668668626" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga007.fm.intel.com with ESMTP; 06 Feb 2023 21:38:59 -0800 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 6 Feb 2023 21:38:59 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 6 Feb 2023 21:38:58 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Mon, 6 Feb 2023 21:38:58 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Mon, 6 Feb 2023 21:38:58 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OTzZu4z7kaZCB8w+u/SNnSB9dGVK6zKeWIWS9nQ98Vji4mrVA29SXcMCT/zEvW0AM+lmiPS1d1FdeFcMwjXmYu3MxSv4ux+raQP+1cLTL1apcKduMdiYA8ZGuhjSnK+hQK4JfaUtW+opV7FCSoqPhRJT/pbpUk6Nfzg6OLXwUl2sxusdebXldGvFNOhpK3nINAeXRVR5ob3bKO1sryU7ykYs8U8WkvtkKyI6PQG1Ut3hHlm/+eW6swomLcvIEqm6/gtCg/+e0QRrn1SWiOKNiVhcHspkfGpCYzFiBd2hebPN/whAYUffIbGrHgQOy9ZoFPevucSqZS/TuPkZ0XIoEA== 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=/q/tXFzJSrxENzWD1kdsaEXYAJ5N5lQUa92fz9CkW+0=; b=E97H9hSGAyvxdM2q/vGXw9kz7Su5/J39evPjS2GcEdOR1Fs4J6Sh4mayvcYD6RTfgVEeZYBkPUmPjB5ECaoE/mTS/QKa/siiQOFrh0KnVDiNUD3uVJGyklGjTAkKYn9C1QwUGTOx/L34xNCD9BFQFIJyyftTkuarbXxB/Uo/bK2d8AkzqrYS+hx+7k6HYt9hfDByq7DKHsaja94Tbf8K3u+Cz/MNId28V6Hy2N7ONUpZO92JmZHXdtH0IZXIdVHUueWfNyiYKU2PVZLujYdPxz+xcBEqbvWdU3ob/uP19ImmsCDb0Q4qLUfX0BGhT8BzLSzTJvlimbFppFqcJwbA0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SN6PR11MB3504.namprd11.prod.outlook.com (2603:10b6:805:d0::17) by PH8PR11MB8014.namprd11.prod.outlook.com (2603:10b6:510:23a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.35; Tue, 7 Feb 2023 05:38:55 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::c8f8:a3e1:5b23:a9c3]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::c8f8:a3e1:5b23:a9c3%5]) with mapi id 15.20.6064.032; Tue, 7 Feb 2023 05:38:55 +0000 From: "Xia, Chenbo" To: Maxime Coquelin , "dev@dpdk.org" , "david.marchand@redhat.com" CC: "Coquelin, Maxime" , "stable@dpdk.org" Subject: RE: [PATCH v2 2/2] vhost: fix possible FD leaks on truncation Thread-Topic: [PATCH v2 2/2] vhost: fix possible FD leaks on truncation Thread-Index: AQHZMnA8X9z/bbZ/EkmhNzlMps1DQq7DCATw Date: Tue, 7 Feb 2023 05:38:55 +0000 Message-ID: References: <20230127165540.37863-1-maxime.coquelin@redhat.com> <20230127165540.37863-4-maxime.coquelin@redhat.com> In-Reply-To: <20230127165540.37863-4-maxime.coquelin@redhat.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SN6PR11MB3504:EE_|PH8PR11MB8014:EE_ x-ms-office365-filtering-correlation-id: 1851d5bc-291c-4c5d-8da4-08db08cd9a41 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 7ZPSPvMTrVbBWImlIkaVv1scanaAto9w5wFbJeNLRwo+ogwaHPJW/Ldz618GiakRrtkNiMkJefM+ZX8p7XPh7a6FMRaHDtPeSLWhTA+mADleDkOaXiAkVSO0P7sgpjhrnGSDqWofTt5XOhEX1N4fIA5GY01JyrwXlsRuOjg1Dm77iLrK1ESxrfMTeHA4ajtxtPx0I8J/RpOLSh+STbZfloJG8+GVxKvYx2i2CNJXXqNGqSwqESG+hJ5ZLr56AQT76Gcmxoglu2llobxdgnvh8QxUr8UnHCJsGxww8XTkfUgdtRcZqn1j6qwAljakxsBcXfuvZ3x54L+YonsEOGXJiJi7oBBiAuaZbvMq78Xd2ojZlM+E77065yaYzxQwiEAklyg3Mdcj8MDv3fVl9bEnkH1k1Y8CyeJvvUQM/HShG+YO047h92mgoQe1HM2Qub/JnaJBvIyc+hTOG2AWYLp8z1jRzZwdK2VksjBi+PoUbD+F6h0axs3FR1kbF3pPzAPIrQyPOg/MiEtM6N/jrQL/keFF9boluHc5odEA5l+FMS695ca/LTa7k9lR7PzwicpDW95+V5vcieXnpTcvKUd/NilEzlfyx6PxOs0L1zxl45Th0YAtmy3VaPKXclZc4DwgfrkKztOxF+fJ+Dh4jt/MTETiczg7hqbCXwBSzjlkvE3z/d9ivAbzzkHwhAfuqVwCoAAnLIRGcxWgnuW8GhBEww== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB3504.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(366004)(136003)(376002)(396003)(346002)(39860400002)(451199018)(55016003)(83380400001)(478600001)(71200400001)(7696005)(53546011)(26005)(6506007)(186003)(9686003)(38070700005)(33656002)(86362001)(38100700002)(82960400001)(122000001)(66446008)(8936002)(5660300002)(52536014)(66946007)(66476007)(64756008)(66556008)(41300700001)(2906002)(316002)(76116006)(110136005)(54906003)(8676002)(4326008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Ocv3QRCxfReGofZnYdLvMUw5HcPtwFe06xwyIUmBhmOqku6nTVKPbFrmVO56?= =?us-ascii?Q?7yjRt8Pq0R3eLowjmttPrX9voixQfhC2P/BGKPCZa7RZ1QCgndzhfO1dgi8k?= =?us-ascii?Q?qeWfokW0CNrr2SZWna92ATfJxzsq6Y9FRhhuXcRdXehBZeY0ui41MwwYmndm?= =?us-ascii?Q?gWyyY+91EzeY6WtzWdrCBackFB8wbyqfcABC0OypT08y5CNz0JkNTgKfb/bg?= =?us-ascii?Q?l4cgBHTpOMQHr+l/rX0IJzPCT+fzvGpv3qnokaoUpCfNX9beA1CjMEGXkeJW?= =?us-ascii?Q?fwgYgRUF5szXCh/xX04ZGYv+46dYx7ob52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ebEntcUtn2RYKDn0ukVhHGeAaxCOTWIJmCUJjngNgEP/xlIXKep?= =?us-ascii?Q?YbCzz1qgocBXrwm+PLgQtfpn8aldI4dTv39r49dlu+uiJPbJfs+CVrW+N1Qg?= =?us-ascii?Q?xjmphnlXgU5aX+WZTrWUse9XXBj6seDXaglzP8zve9ceZKI1n4pIOUWCWrCr?= =?us-ascii?Q?1g6TA/E2f6lF1OFp5XV1XIE6YxeyI9EbI4Lq5wCnc6Lj7+q3OZIQeoT7N4ie?= =?us-ascii?Q?SBgXq1Sb91a9TqQO3I1HXfvRQRjVzBtq3yv8isK81VjzLpBQGchM7JzOYYOt?= =?us-ascii?Q?v3athrqdKY9Ml9lkkNgsZMGmg6tVaL/1Qm+4KGy7XQbnXPFj7qwEM1DgvNSo?= =?us-ascii?Q?hIJf5CQMDbybYgYK1z/WfLmNOQRvtQlkEMOZZoRl?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB3504.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1851d5bc-291c-4c5d-8da4-08db08cd9a41 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Feb 2023 05:38:55.2049 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 7WX/3MmlDz9E0MDB803ozLAeMOipifOY1ZoskvNt/GGPYyK+s6W8klSq+LzONOBBTbKVFSl8DXbeU3EGlF8l5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR11MB8014 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > -----Original Message----- > From: Maxime Coquelin > Sent: Saturday, January 28, 2023 12:56 AM > To: dev@dpdk.org; david.marchand@redhat.com; Xia, Chenbo > > Cc: Coquelin, Maxime ; stable@dpdk.org > Subject: [PATCH v2 2/2] vhost: fix possible FD leaks on truncation >=20 > This patch fixes possible FDs leaks when truncation happens > on either the message buffer or its control data. Indeed, > by returning early, it did not let a chance to retrieve the > FDs passed as ancillary data, and so caused a potential FDs > leak. >=20 > This patch fixes this by extracting the FDs from the > ancillary data as long as recvmsg() call succeeded. It also > improves the logs to differentiate between MSG_TRUNC and > MSG_CTRUNC. >=20 > Fixes: bf472259dde6 ("vhost: fix possible denial of service by leaking > FDs") > Cc: stable@dpdk.org >=20 > Signed-off-by: Maxime Coquelin > --- > lib/vhost/socket.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) >=20 > diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c > index 863a6f6d52..669c322e12 100644 > --- a/lib/vhost/socket.c > +++ b/lib/vhost/socket.c > @@ -129,10 +129,12 @@ read_fd_message(char *ifname, int sockfd, char *buf= , > int buflen, int *fds, int m > return ret; > } >=20 > - if (msgh.msg_flags & (MSG_TRUNC | MSG_CTRUNC)) { > + if (msgh.msg_flags & MSG_TRUNC) > VHOST_LOG_CONFIG(ifname, ERR, "truncated msg (fd %d)\n", > sockfd); > - return -1; > - } > + > + /* MSG_CTRUNC may be caused by LSM misconfiguration */ > + if (msgh.msg_flags & MSG_CTRUNC) > + VHOST_LOG_CONFIG(ifname, ERR, "truncated control data > (fd %d)\n", sockfd); >=20 > for (cmsg =3D CMSG_FIRSTHDR(&msgh); cmsg !=3D NULL; > cmsg =3D CMSG_NXTHDR(&msgh, cmsg)) { > -- > 2.39.1 Reviewed-by: Chenbo Xia =20