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 0FA3941C2A for ; 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 0554F42B71; 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 088CA40ED9 for ; Tue, 7 Feb 2023 06:38:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675748339; x=1707284339; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=vn1Qn3imzD55MDdWjDkwIz5JVtiNo5OyyWMvi1Aq0OU=; b=b7RBYRgVY8lzMfyece344F5uBlKGZ2d/ljtPBXF0g3tkw0HRW/vOb6Cf jUV/XN8cd6st4VyQxRLS/R46whrfwI1ggDgB9ECW9/UGLjluAIw0F3olf R59kitw+KowHgLK3MJp4Ai22sTmtNlCHcVec1aGAVnZZvxYh58CpZFikl KiYM4WNgjkKYvpUkXknFAB7W08TlBQ7cW4PyMtp0h1K/BhhwvLKiQTWG2 7WprByOVI3Ts+mwJ1aKkFljkYn5Dy4n6f7qsNuQDAEQCRBYlKkzKiw5Ql SSRAmWLLf4o8KUl0qQekD7f6RJejThEL1xgX1PxNN98GYrnchjE6dH0Bv w==; X-IronPort-AV: E=McAfee;i="6500,9779,10613"; a="356779187" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="356779187" 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:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10613"; a="668668623" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="668668623" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga007.fm.intel.com with ESMTP; 06 Feb 2023 21:38:58 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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:57 -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:57 -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:56 -0800 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+46dYx7ob52btrVD+6vrxrZTVy62EoGfgdzqT?= =?us-ascii?Q?SHJRwkrI0N9NP9uTApQo/lUEcAlsyVXaSd9VlhewhOqkNSbpEoaB/oC4LquL?= =?us-ascii?Q?Opt6uSw4QESbM51favgTK3QLEfvBif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jmphnlXgU5aX+WZTrWUse9XXBj6seDXaglzP8zve9ceZKI1n4pIOUWCWrCr?= =?us-ascii?Q?1g6TA/E2f6lF1OFp5XV1XIE6YxeyI9EbI4Lq5wCnc6Lj7+q3OZIQeoT7N4ie?= =?us-ascii?Q?SBgXq1Sb91a9TqQO3I1HXfvRQRjVzBtq3yv8isK81VjzLpBQGchM7JzOYYOt?= =?us-ascii?Q?v3athrqdKY9Ml9lkkNgsZMGmg6tVaL/1Qm+4KGy7XQbnXPFj7qwEM1DgvNSo?= =?us-ascii?Q?hIJf5CQMDbybYgYK1z/WfLmNOQRvtQlkEMOZZoRl?= arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KQIHp3TwkaMf6cc0tf+Qo49ws/C8aIC7SsCLwy3V1j2HwixkJki35DLX07b1C97rpnP5BGy+BqZnNK2XHDnS0U02GU2TGHNuIIoSsO2Sz59Z3Gv5I0SA7mRVR9Ptc4gl91we87Ek2TuceDTWH4+6e+0vzKFkgNnSjrEg4NBNekLPDYCYus+j0b6UnRbliiY0Z8QRuwvY+uuWShcSX+lB+wXokiNnBEj/bAS8WFPH0aEDxsk4t+4GeSzazRvNuzYFc/2sjvLGdE0Q1IpYZCHIBzYGLsr9L7qaN8VH5lSjlZ9LhIgAkZIVtPhfExApl0AQo0NPf1krJctdzYr6gCnpCg== 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=8NSgUmzVhqXZDLn5zJh7v3FCcXTOzJS77Big2pW5iwQ=; b=aKxHuNxJcDDSvOD9nYEYfEv/OkbVXM6P2C/20XyTURrKkczzwR9J0Pk/5LGyC/JAi+T7DC6xMQb9B/x5C2r7wH4IAN3TlBZ6Plg8X/M0FPtfjcA6odo6O8T+XhbXtCibdz9iEbd2/xQx49oaVhA74MP9eL3TGVTusKgBwuwtagc19+hI+8vbAtnkGuFLkgB386uctAecjbhS4hwD8CK2V0DByM226goQq98koGloIfqNAnMNH4RfZlMMuJ8LbMzWp01NeQoWAmuEBchfyDoA6MzaC5VwhVA15vbe7imn08eZGbztiTyi9TTGvVBv8HVH+zcrJno+jVfVEUIwnbMT7w== 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 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-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 > > 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. > > 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. > > Fixes: bf472259dde6 ("vhost: fix possible denial of service by leaking > FDs") > Cc: stable@dpdk.org > > Signed-off-by: Maxime Coquelin > --- > lib/vhost/socket.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > 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; > } > > - 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); > > for (cmsg =3D CMSG_FIRSTHDR(&msgh); cmsg !=3D NULL; > cmsg =3D CMSG_NXTHDR(&msgh, cmsg)) { > -- > 2.39.1 Reviewed-by: Chenbo Xia