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 4C8BA46A63 for ; Thu, 26 Jun 2025 14:09:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 47240400D6; Thu, 26 Jun 2025 14:09:17 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061.outbound.protection.outlook.com [40.107.237.61]) by mails.dpdk.org (Postfix) with ESMTP id C687B400D6 for ; Thu, 26 Jun 2025 14:09:15 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hjLy63lQBNMoCvEKC6CA6u7MqxmI/P7fjX0tOmYIANXbrXd2TJUd8Qg7qlGka3OiDwVTN8jdCeSeZy2gdIeS/GptWkT0PKnaxv4gCZSc/Rac5BpVG+rd/8xueVljAlOTlQjmUZ91EqgfbSXrW+MbYv7VfkQtArO8y3rJ6NUlejP5LO/OOz1zOtao3K4hJ2mSuiLj5NM0CGUsElpksPkYRykgC/jHzYqRIeRPggFRMBXiez31WwByxDdZnNfWC7+c0Cksd8ZzxMdwGnir0rKJOUYzZS+72Zve2j5MKXp5f2TPZCck4NvD8Fvcz2iYjW177FC0UamPbTD1yoJJ5eI7/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=zUC/VD569C0Nhw8IDHS5/6aYeVJzvlWsFu/JeronpsA=; b=HCDW95srdsApfVRtqY50g5eYVZL9gpdTcdDYCUqaSV48yLjDfwwCSz3/JvY1hlGaTFuUy/tdKLCuRQWXmii/ZhW9Ga3DvPMYIag2m52BkulPp2X1zjFRfL4fl3A1BH0krZcSCFiFkiYNGt2k/m3iTsgdeIfiYQGymNRPH6c+DpqvCrujKk3lm+MZA4c8QlgKGkcL2v6hkZq0uF2pxHBa1eFHog7uuTabWeyXVRzkGEIzy1pg5s5fqVs4uf5Cq0gKL7sJUt1WtL+htP+xI2E42fBgYgypeE/RXFZv281PNF6Q6rHmgow7uHDR2zCo1O6BmwaupGZUsFkEoxmDxutDBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=h-partners.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 (0) 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=zUC/VD569C0Nhw8IDHS5/6aYeVJzvlWsFu/JeronpsA=; b=KS4y6QF26nD9Uqid0WK/f7W8xakxWAGk25vesu3a64nWVgNPyhLIcxkOULukcwovgYU1T2aBzAEqDSoOjovyqRD39cUsh9mcG039k1rfmIJdUJP/64zUQVyX5yFOWPmEMus/cqmaa+I3rX27wUBHoaQZS2QeGqpMHYywCLJ5ymlgNPDAZKpYczrRc3RoCfZvBtntV5OP4AQ1QdV9NHvB9vVnEcPYpydcA/w444hPPRvTguc3wP3hv+wRF46V09j+T5Qtb8lZ5PTLCC5y/9+Fp8dxF7ScAnoCT3dkMwx9/omAWLyk46TGSu8kFPub2aOhaB4+qZGS81rbit9Dlf1WNQ== Received: from DM6PR08CA0029.namprd08.prod.outlook.com (2603:10b6:5:80::42) by IA1PR12MB8493.namprd12.prod.outlook.com (2603:10b6:208:447::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8857.35; Thu, 26 Jun 2025 12:09:11 +0000 Received: from DS2PEPF00003448.namprd04.prod.outlook.com (2603:10b6:5:80:cafe::da) by DM6PR08CA0029.outlook.office365.com (2603:10b6:5:80::42) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8880.20 via Frontend Transport; Thu, 26 Jun 2025 12:09:11 +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 DS2PEPF00003448.mail.protection.outlook.com (10.167.17.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.14 via Frontend Transport; Thu, 26 Jun 2025 12:09:09 +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.1544.4; Thu, 26 Jun 2025 05:08:45 -0700 Received: from nvidia.com (10.126.230.35) 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.1544.14; Thu, 26 Jun 2025 05:08:43 -0700 From: Xueming Li To: Rui Ferreira CC: Xueming Li , Konstantin Ananyev , Thomas Monjalon , "dpdk stable" Subject: patch 'eal/linux: unregister alarm callback before free' has been queued to stable release 23.11.5 Date: Thu, 26 Jun 2025 20:01:35 +0800 Message-ID: <20250626120145.27369-76-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250626120145.27369-1-xuemingl@nvidia.com> References: <20250626120145.27369-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003448:EE_|IA1PR12MB8493:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c4a56c1-19a4-4d4a-efb0-08ddb4aa41d6 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026|7053199007|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?xF6kHYXCLVYSg9FsMvwi8pq6qlb5klvCs5qW06l+ICmmBlx1Tgu7xFIoSE58?= =?us-ascii?Q?ekFsQ+7vMCXF6HwOabx6fim8j8JaSurfxmesdz3aQBvn6eUPQAbq54jzQEoR?= =?us-ascii?Q?ex7ss5vwGCdsv0KacLClVC55FmwjfRCNivZOhU2/5l/a0f3C43/7D1bOcEdS?= =?us-ascii?Q?+5J+/EdM4ysY1HyTISHrT6eTuw1OEaZ8Vlwqta7rIHpcy+L0pxmzv6wbot7U?= =?us-ascii?Q?jxoaFez3E71m/zkQ7AtRQHas9SCrZ4jX5se4p2am3NqXuQgjjy+8drZxa5a9?= =?us-ascii?Q?ptKUnWahByCpsYNYMaTWzpCrBqSXGQI7lNSNuLgr6atqCyUCED9o3hLyoxDc?= =?us-ascii?Q?LdF5KBapWXWg1+2hR/DK8VigCLFfM9+c5eg9k5IePi47a3sfv0W7IRYZMbSS?= =?us-ascii?Q?XNGsMvpKhPXQ48D0tek2NmRZu+Af97ls/fSMs+MY4HLipKpomRT/rikXMEw6?= =?us-ascii?Q?pNUG1q4zJ8lFHRF02VJ6s82Slz4ab/6I/djxVBfgupoZVJo2qp5esN0jilzU?= =?us-ascii?Q?OP9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7NLtH?= =?us-ascii?Q?eaOPkAwym9xQatOf1l6Es0W0fPumJQvgbSCOXplYBFDWW3MXTpIDw42nySEa?= =?us-ascii?Q?Kjld9KVPj7tgUXkNUWnifgJ4MTojFKeG+sB7Ty8LE43KlMrBYvx/9a0KBw?= =?us-ascii?Q?=3D=3D?= 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:(13230040)(1800799024)(36860700013)(376014)(82310400026)(7053199007)(13003099007); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2025 12:09:09.6999 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c4a56c1-19a4-4d4a-efb0-08ddb4aa41d6 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: DS2PEPF00003448.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8493 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 23.11.5 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/28/25. 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=23.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=57bb5ce25eaf5ed693a387b152b476c68e16c041 Thanks. Xueming Li --- >From 57bb5ce25eaf5ed693a387b152b476c68e16c041 Mon Sep 17 00:00:00 2001 From: Rui Ferreira Date: Fri, 30 May 2025 09:18:43 +0100 Subject: [PATCH] eal/linux: unregister alarm callback before free Cc: Xueming Li [ upstream commit d84bf0d9aeb474d89a412b6af8e947b16bfcb895 ] This was flagged by Address sanitizer as a use after free. The intr_handle ptr is shared between the main thread and the interrupt thread. The interrupt thread can dereference the ptr after free (from the alarm callback). free is called when the main thread cleans up. The interrupt thread never terminates (eal_intr_thread_main) so use rte_intr_callback_unregister_sync during cleanup to ensure the callback is removed before freeing the ptr. To be more defensive clear out the pointer and registration variable if we can unregister. rte_intr_callback_unregister_sync may (optionally) use traces so the alarm cleanup must happen before eal_trace_fini to avoid accessing freed memory. Bugzilla ID: 1683 Fixes: 90b13ab8d4f7 ("alarm: remove direct access to interrupt handle") Signed-off-by: Rui Ferreira Acked-by: Konstantin Ananyev Signed-off-by: Thomas Monjalon --- .mailmap | 1 + lib/eal/linux/eal.c | 2 +- lib/eal/linux/eal_alarm.c | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.mailmap b/.mailmap index b4e75a6046..b1e5e00cb7 100644 --- a/.mailmap +++ b/.mailmap @@ -1255,6 +1255,7 @@ Rosen Xu Roy Franz Roy Pledge Roy Shterman +Rui Ferreira Ruifeng Wang Rushil Gupta Ryan E Hall diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 57da058cec..b3b69a090a 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1371,10 +1371,10 @@ rte_eal_cleanup(void) #endif rte_mp_channel_cleanup(); eal_bus_cleanup(); + rte_eal_alarm_cleanup(); rte_trace_save(); eal_trace_fini(); eal_mp_dev_hotplug_cleanup(); - rte_eal_alarm_cleanup(); /* after this point, any DPDK pointers will become dangling */ rte_eal_memory_detach(); rte_eal_malloc_heap_cleanup(); diff --git a/lib/eal/linux/eal_alarm.c b/lib/eal/linux/eal_alarm.c index 766ba2c251..8f98726a57 100644 --- a/lib/eal/linux/eal_alarm.c +++ b/lib/eal/linux/eal_alarm.c @@ -56,7 +56,14 @@ static void eal_alarm_callback(void *arg); void rte_eal_alarm_cleanup(void) { - rte_intr_instance_free(intr_handle); + /* unregister callback using intr_handle in interrupt thread */ + int ret = rte_intr_callback_unregister_sync(intr_handle, + eal_alarm_callback, (void *)-1); + if (ret >= 0) { + rte_intr_instance_free(intr_handle); + intr_handle = NULL; + handler_registered = 0; + } } int -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-06-26 19:59:20.562834711 +0800 +++ 0075-eal-linux-unregister-alarm-callback-before-free.patch 2025-06-26 19:59:17.498418039 +0800 @@ -1 +1 @@ -From d84bf0d9aeb474d89a412b6af8e947b16bfcb895 Mon Sep 17 00:00:00 2001 +From 57bb5ce25eaf5ed693a387b152b476c68e16c041 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit d84bf0d9aeb474d89a412b6af8e947b16bfcb895 ] @@ -24 +26,0 @@ -Cc: stable@dpdk.org @@ -36 +38 @@ -index fb90483bee..9135f06efc 100644 +index b4e75a6046..b1e5e00cb7 100644 @@ -39 +41 @@ -@@ -1339,6 +1339,7 @@ Rosen Xu +@@ -1255,6 +1255,7 @@ Rosen Xu @@ -45 +46,0 @@ - Rupesh Chiluka @@ -46,0 +48 @@ + Ryan E Hall @@ -48 +50 @@ -index 20f777b8b0..de90ab3b86 100644 +index 57da058cec..b3b69a090a 100644 @@ -51 +53 @@ -@@ -1328,10 +1328,10 @@ rte_eal_cleanup(void) +@@ -1371,10 +1371,10 @@ rte_eal_cleanup(void) @@ -64 +66 @@ -index b216a007a3..eb6a21d4f0 100644 +index 766ba2c251..8f98726a57 100644 @@ -67 +69 @@ -@@ -57,7 +57,14 @@ static void eal_alarm_callback(void *arg); +@@ -56,7 +56,14 @@ static void eal_alarm_callback(void *arg);