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 F2A3F41D8D for ; Mon, 27 Feb 2023 08:10:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB5BB40ED6; Mon, 27 Feb 2023 08:10:56 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2058.outbound.protection.outlook.com [40.107.243.58]) by mails.dpdk.org (Postfix) with ESMTP id 7E66340A7D for ; Mon, 27 Feb 2023 08:10:55 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Io8K7Lt8C77F/zFhechxIerz/QrjqRXwDWXJl6CzpPFIX7IRNP8iUS+nwtO2voEVVKlIK3ucjvTUhQjdKVbh05mgtULB0a2NYWVu+Y8NGdUlO5dlWyI9nZSa0qlXLcFdKGt3CZfogK61FWib61sjUhMnobyzS7bYQAG6CuvPwrcCpeGX10C6nykS9RfMSN03sE8Ff5l2/zLqMqPUiVtz6O4DvrLwZrJZogDzIwz+R3sQPrDdGv5JesjGhzwtZYqyc4mxwUsalV/sQ2oP6vGDpkojZAfeKpamwGsIFE98AQBc1cLxRlaJp72PfQuGqXsZvjgFEiFwjmzVgfX40ocxDw== 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=FdR/ZyoUfjq8jGGdIrP4n8pQIUnSHesEc8iQbGdZugU=; b=L4h/SW8xVyh4kyU2POI8G+rPn7QHazQMwAIS38tbodXaOfNeEtvPuDZikQisUdXK7TVaRnRRJzBB6rkhDgvbymYTdwAA4ap+fFOArKjHCHzMPBnn33D+SLxq4ZD1C97xVzaNeEb8fh6asj9Jix3qyqh5I8binGj2BvMetOeywfhxi3DY9XZ6yqhqvdSQbtxMtZl9y9tO4qckmCypnD1zRfLgbwxWLn2IRY7zI8vlEF5lmwDWf2htvX87n+a84/brRWVL6Pg2Kfoj50WMcidFwZHorEDFL17cn5j6ll04yEjcuct4hDMyPcXyY/NE9HikRZXewbNOh8MrV6sjzzy1NA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FdR/ZyoUfjq8jGGdIrP4n8pQIUnSHesEc8iQbGdZugU=; b=grN477+pWNRmPgNVsRQMUFgQEwhvNE3M1eBE0GyI79de+6Vqdu2kU8upP/fY9SOjx33kdK8bVDDcPl3YXwUE45LlQ77Fmys2PYnHWFRbU0ylbCMe4B9QNUCo8nJNfMVxDuYLWdhq3hbnSfwXwlNEXv0SB6MCrdvhwuT9Bx0NnnhsJuKvASi73IzIzAPjIGHJ9mPc3AZou4J73Vw3I7PrSNaISh7OfGpPJHxOkJkt8/o2VJa1AbiQtoKJqOKpO0LOmzXpWz3iTECLMXxh1FaFXhf5uaDwnOF+u5r1LrhA4yaRLXaIGRQ7LuQW3q+IkT5XtlLguQ/VEEHCMy/od+Uo6A== Received: from MN2PR20CA0052.namprd20.prod.outlook.com (2603:10b6:208:235::21) by SJ2PR12MB8737.namprd12.prod.outlook.com (2603:10b6:a03:545::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.28; Mon, 27 Feb 2023 07:10:53 +0000 Received: from BL02EPF00010206.namprd05.prod.outlook.com (2603:10b6:208:235:cafe::2e) by MN2PR20CA0052.outlook.office365.com (2603:10b6:208:235::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.28 via Frontend Transport; Mon, 27 Feb 2023 07:10:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BL02EPF00010206.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.12 via Frontend Transport; Mon, 27 Feb 2023 07:10:52 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sun, 26 Feb 2023 23:10:31 -0800 Received: from nvidia.com (10.126.230.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 26 Feb 2023 23:10:28 -0800 From: Xueming Li To: Maxime Coquelin CC: David Marchand , Chenbo Xia , dpdk stable Subject: patch 'vhost: fix possible FD leaks on truncation' has been queued to stable release 22.11.2 Date: Mon, 27 Feb 2023 14:59:54 +0800 Message-ID: <20230227070107.15664-86-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227070107.15664-1-xuemingl@nvidia.com> References: <20230227062349.13764-1-xuemingl@nvidia.com> <20230227070107.15664-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00010206:EE_|SJ2PR12MB8737:EE_ X-MS-Office365-Filtering-Correlation-Id: 56da5647-40aa-413c-aadd-08db1891c362 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xQisPGVa/AaDJP7PPibVgAdojJn7A9rtI2SMs9Thy65GI/fpjaa0nujP2aurwQjUEOaS9qmT+skEvFgcXC1jUO5+UUSSb9tWowkx60lrLhg+7+rdBHBhgj0AXgtf/rCYWSI4AplGGGBv4SElYxzh/nUqEPi+bEgv1x2IHX+eeMW/WeF62YpAqbReEDLjRDSbIfxB1hunk+M48LxuwNgiz53WuyqPbbTluYUKB6xV5rq0/hXp+6j3auSHu8YCk1S+qSYl2RiTweARudvTV2h7ay0wO55fHtce3anZPuzTi/k/eEJ4+jXwDC3GX+FZejNAls/yzT8E/urQmgQ24mOWje90qmb0SmW2voDSvYBi/c/9ovedt41IOjkSbrDvzcfULKQ756O7gpNGi6wN7Sh4zgro4grnxGvBeuBSAyL+ZDFdSEHXHJ5iGzhWGNb3Y2NEBPFDgw5zD1qlRMi41aQP2uiIIX1WsNRhGcdAuPKREX2sE9CZITX1L1gHorjvdHfK52JdStxtdZOGGcKMAzTvP+RydS8uc6EV28XV5I+829wPx0jWu8KLqcBVl0nYxtJFHCAupt+cg6n3H0Z9QxrkPErRrQ5Of7aSAsviIlWeMNftMLFIyNA+b4sxxNrGNUUpOWxDw02EeWJO7C8sq+9szLwC6lU3gqie7sKVtvdtIi7TOotajQHP0HK+w6ssZlPX7m8FImbLIBTVrt0f0fBeXkQUCcL7CPlEH3HCQHfXLNDk0S0dJcK18J1EJo5ynAKhkj/DHu+ASF/IL+Gos7jeQGFKZInDvR3BOHuIe3nB0cw= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199018)(36840700001)(46966006)(40470700004)(2616005)(966005)(316002)(36756003)(82310400005)(86362001)(54906003)(16526019)(40460700003)(6286002)(186003)(2906002)(8676002)(36860700001)(5660300002)(4326008)(6916009)(8936002)(70586007)(70206006)(41300700001)(1076003)(426003)(47076005)(478600001)(53546011)(6666004)(26005)(336012)(55016003)(40480700001)(7696005)(7636003)(356005)(82740400003)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2023 07:10:52.8373 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 56da5647-40aa-413c-aadd-08db1891c362 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00010206.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8737 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 Hi, FYI, your patch has been queued to stable release 22.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 03/01/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=78d828c2475d7cb1e6492688d62a5949ad67288e Thanks. Xueming Li --- >From 78d828c2475d7cb1e6492688d62a5949ad67288e Mon Sep 17 00:00:00 2001 From: Maxime Coquelin Date: Tue, 7 Feb 2023 17:22:40 +0100 Subject: [PATCH] vhost: fix possible FD leaks on truncation Cc: Xueming Li [ upstream commit 218daf1664561eca787369c13e1a9ea5cdaad2a8 ] 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") Signed-off-by: Maxime Coquelin Reviewed-by: David Marchand Reviewed-by: Chenbo Xia --- 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 = CMSG_FIRSTHDR(&msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(&msgh, cmsg)) { -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-02-27 14:08:43.685852700 +0800 +++ 0087-vhost-fix-possible-FD-leaks-on-truncation.patch 2023-02-27 14:08:40.809237000 +0800 @@ -1 +1 @@ -From 218daf1664561eca787369c13e1a9ea5cdaad2a8 Mon Sep 17 00:00:00 2001 +From 78d828c2475d7cb1e6492688d62a5949ad67288e Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 218daf1664561eca787369c13e1a9ea5cdaad2a8 ] @@ -18 +20,0 @@ -Cc: stable@dpdk.org