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 760CF4301E for ; Thu, 10 Aug 2023 01:55:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 703C540DD8; Thu, 10 Aug 2023 01:55:08 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2082.outbound.protection.outlook.com [40.107.100.82]) by mails.dpdk.org (Postfix) with ESMTP id C45CF406B6 for ; Thu, 10 Aug 2023 01:55:07 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iD6DUBvofrfGODHQYEnW7vEhPwXRjAVmJXPOsZFaqQVIyxJpSgr0e+tcW0AgxvcY5bSl6I7s1ptnu9QO8mZLMNUPdOtqihclI19TrWz4CJ3E6rzR4/WCzX4AszkO9pmg4pkVu8qN0H/VX5+uJO5rRAauenYp3xcArTCLQZwRzzo9wB0Fb39z5BdUEd7N9XNxR3hWMzusG181256mRJ06EoK9VrS2Bfj+ogQJpuKmTq98gcRO4Wc54TwoxcqIXvrEClN6iqtB2t0HUXQTLkqf6+2rhX/REEDQ+9Vwz2ZJ/Lo6HumEOYjM3hyFg1ttu4cMPvS11ODY05pCxyrszyzAPQ== 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=6wf2ZL4Bsrow0J93ea3jjxpb0k8HmDZMqmu/nVBcnoc=; b=Pvsbp2EfLliyxMgJiJ4vu4rOw+VrRQbT31YbuDtOkeKMpcV1cdyWD9091z8WdIt0i81eOAKgzdNDNAfxmKVwJpr+bQ3LuxaqYWzBp7FDJdWRG3zxR0PviVoLYxIegFsSM4qxDcbzy8vyHcJdnCvX7XvDPMXuvNWfpOra6JmcVbXrzn/diQZb4j3UtbtH2pEV/6QUlWt+TRVXnGBpWqcZ0FKwOsJ9LjnnAUtBf0QNGSiGJ55UOdJG8TQMzKblSt/Ex41hPWAjVK96UZ150r2Qfh37UWz4DYsZRH8sKOpxtKwQR/DyHWBRb8yZZSdAbBbX06uXpnOTgHIjarZ6Yq/NUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=huawei.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=6wf2ZL4Bsrow0J93ea3jjxpb0k8HmDZMqmu/nVBcnoc=; b=VhDA25uMZ95HyJ460mWnmieYzSFQmoYhgsWgie73bVs5QdERW7URfD+6BPJEV1q5WUMDXiR89THFFGG4rs3cSDO6My1lE9Y1Sd4n1kdomwwhyHNsLjPfVchg26FszG+3K8wlGdhAC2p/M9FWVH38i90GWifCuM7rDV+iTxok2f6QUPl6dZqpH0GU+mwhnHuc9xq/jBYYx9p35kLGYHK6rHFSn5nv4/MwcaVf4RdWWRhkKzKBEXwfjncxFOR8HaekgWn5ti1j68Qu5FXMOQWNxww0dt3i1RxBWkUR8g84C0LLcTaHhS7GITlZvXXmz+h4bhT4UQM3gL2kAZ7IzdscWg== Received: from SA1P222CA0099.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:35e::13) by LV3PR12MB9258.namprd12.prod.outlook.com (2603:10b6:408:1bb::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Wed, 9 Aug 2023 23:55:06 +0000 Received: from SA2PEPF000015C9.namprd03.prod.outlook.com (2603:10b6:806:35e:cafe::43) by SA1P222CA0099.outlook.office365.com (2603:10b6:806:35e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.28 via Frontend Transport; Wed, 9 Aug 2023 23:55:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF000015C9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.20 via Frontend Transport; Wed, 9 Aug 2023 23:55:04 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 9 Aug 2023 16:54:48 -0700 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; Wed, 9 Aug 2023 16:54:46 -0700 From: Xueming Li To: Viacheslav Ovsiienko CC: Chengwen Feng , Anatoly Burakov , dpdk stable Subject: patch 'ipc: fix file descriptor leakage with unhandled messages' has been queued to stable release 22.11.3 Date: Thu, 10 Aug 2023 07:48:15 +0800 Message-ID: <20230809234930.32424-54-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230809234930.32424-1-xuemingl@nvidia.com> References: <20230625063544.11183-1-xuemingl@nvidia.com> <20230809234930.32424-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: SA2PEPF000015C9:EE_|LV3PR12MB9258:EE_ X-MS-Office365-Filtering-Correlation-Id: 5169305f-f4d1-4f31-1dca-08db99340da4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DJoCIlaHwr5fnbOdxBPvbsPVQE4YKunNWrDydV2rrVeanya6XGAcF8rycnRWTL9ncIC/S2DeluvZAgsarwhYeLTSQdY1jnM6Uze+tX3MPDgmssJ6Plgt3acQSKrt0NhpGve8WtQQ8QzqlNtnIpOUTgramole9s4plFhadFYHVFKj2824dpFPs5jez9MLkbz+KiJG4XDkorsycZQUjIkvDi99kS6WaxS7xqmfvhTmlPQTn5ohCzTKgAjJ8Lkdu11CCjTbOe+NeVeb7S7gilnqNVpMLm3Y0Xjpg55S02vtffMZUhJhB4COJqeLCpX9tdkvm2G4NiRFXkVcF5+sGh7g2Wfaco21jVA8rXYLf0HcSlLeMo7fCaybtAE+4VJld7QVh3KKFb1kWMrJfIze6mBjENQZLaeQ9mJQDbb1L2Uv7yX2eOJdu+tTDfBjQBuX8k5B9RaKKoIMKteILRkzJmwJgAgBmTdNx3fk/OzthyXbLeDnozAGMz4ubhd43rYCEe23fwsvTI/o0Uy9DjYNxZa8Xbfyllbjt4mTYoLR3/h+dM9futCAaC8FLu0ITqde2FlTSmdXR+F0Vn8HhYUng/lpYIz7/AbTGdWUud7j0OqceNzO8TihqzEMPdoWpo4frYUUKSzG931I/qu4Fy3sBU2QGD1ldgMM9nGUfBq61TaZwRMedRLnu3z8M46S+BDjtIks5s/1/gexPOUThG7fajzkAGsvEcjge1jKZBhJo7IuRmGCRwi3zC+V3aPIDMgowN0vsXqdTa54yyhTsXPZDXgBeg== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(396003)(136003)(39860400002)(376002)(82310400008)(186006)(1800799006)(451199021)(46966006)(40470700004)(36840700001)(40460700003)(55016003)(40480700001)(37006003)(26005)(54906003)(70206006)(70586007)(336012)(53546011)(16526019)(6286002)(1076003)(478600001)(6666004)(36756003)(36860700001)(83380400001)(426003)(2616005)(47076005)(41300700001)(15650500001)(316002)(6636002)(4326008)(966005)(7696005)(2906002)(86362001)(82740400003)(6862004)(8676002)(5660300002)(356005)(7636003)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2023 23:55:04.7859 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5169305f-f4d1-4f31-1dca-08db99340da4 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015C9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9258 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.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/11/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=90aa091a205084082bebb14b41801b901f9ffe4d Thanks. Xueming Li --- >From 90aa091a205084082bebb14b41801b901f9ffe4d Mon Sep 17 00:00:00 2001 From: Viacheslav Ovsiienko Date: Wed, 28 Jun 2023 15:19:38 +0300 Subject: [PATCH] ipc: fix file descriptor leakage with unhandled messages Cc: Xueming Li [ upstream commit a64a4564705d18d20d20cfa16c79e795b7bf0f1e ] The sendmsg()/recvmsg() API is used to establish communication between the DPDK processes. The API supposes inter-process file descriptors sending and conversion, the recipient sees the resulting descriptors in the received message - the operating systems creates ones in the right context. The message receiving is performed by EAL in the dedicated thread and it might happen the message is received by EAL and not handled by addressed PMD or application due to some reasons (timeouts, race condition, etc). EAL just dropped unhandled messages causing the file descriptor leakage if these ones were presented in the message. The patch closes the descriptors (if any) in unhandled messages. Fixes: 783b6e54971d ("eal: add synchronous multi-process communication") Signed-off-by: Viacheslav Ovsiienko Acked-by: Chengwen Feng Acked-by: Anatoly Burakov --- lib/eal/common/eal_common_proc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c index 1fc1d6c53b..9676dd73c5 100644 --- a/lib/eal/common/eal_common_proc.c +++ b/lib/eal/common/eal_common_proc.c @@ -321,6 +321,15 @@ retry: return msglen; } +static void +cleanup_msg_fds(const struct rte_mp_msg *msg) +{ + int i; + + for (i = 0; i < msg->num_fds; i++) + close(msg->fds[i]); +} + static void process_msg(struct mp_msg_internal *m, struct sockaddr_un *s) { @@ -349,8 +358,10 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un *s) else if (pending_req->type == REQUEST_TYPE_ASYNC) req = async_reply_handle_thread_unsafe( pending_req); - } else + } else { RTE_LOG(ERR, EAL, "Drop mp reply: %s\n", msg->name); + cleanup_msg_fds(msg); + } pthread_mutex_unlock(&pending_requests.lock); if (req != NULL) @@ -380,6 +391,7 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un *s) RTE_LOG(ERR, EAL, "Cannot find action: %s\n", msg->name); } + cleanup_msg_fds(msg); } else if (action(msg, s->sun_path) < 0) { RTE_LOG(ERR, EAL, "Fail to handle message: %s\n", msg->name); } -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-08-09 21:51:19.565073500 +0800 +++ 0053-ipc-fix-file-descriptor-leakage-with-unhandled-messa.patch 2023-08-09 21:51:18.194352000 +0800 @@ -1 +1 @@ -From a64a4564705d18d20d20cfa16c79e795b7bf0f1e Mon Sep 17 00:00:00 2001 +From 90aa091a205084082bebb14b41801b901f9ffe4d Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit a64a4564705d18d20d20cfa16c79e795b7bf0f1e ] @@ -21 +23,0 @@ -Cc: stable@dpdk.org @@ -31 +33 @@ -index 7a038e0a3c..02d4599d67 100644 +index 1fc1d6c53b..9676dd73c5 100644