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 4D86446211 for ; Thu, 13 Feb 2025 10:59:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 326A840287; Thu, 13 Feb 2025 10:59:51 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 0456840287 for ; Thu, 13 Feb 2025 10:59:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739440788; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HnAs2+iMcXGKSUjoYdmzq6BkLem9plHfDxZlDG0BD2s=; b=KcEhITz/Gwv7e5J2pUEHmWtfTrz5oK63I8YM406Bqol5yKEirKjdPZYaY6j3uNGKxVjeKs NHibwAaWxTGPDUbbjtd5hVI9WZ2J++8UFRQ0st9wDaDz5WLgLaKbKUzCXhUm4xVN0opTGp fGF77CFh8MJ89Hm072hCvB8Ps9gCni0= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-639-SdimslCxM46R1ryUkkVJeg-1; Thu, 13 Feb 2025 04:59:47 -0500 X-MC-Unique: SdimslCxM46R1ryUkkVJeg-1 X-Mimecast-MFC-AGG-ID: SdimslCxM46R1ryUkkVJeg Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 366D61800373; Thu, 13 Feb 2025 09:59:46 +0000 (UTC) Received: from rh.Home (unknown [10.45.224.21]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7F0BD1800365; Thu, 13 Feb 2025 09:59:44 +0000 (UTC) From: Kevin Traynor To: Robin Jarry Cc: Stephen Hemminger , dpdk stable Subject: patch 'log: fix double free on cleanup' has been queued to stable release 24.11.2 Date: Thu, 13 Feb 2025 09:57:28 +0000 Message-ID: <20250213095933.362078-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: xHwZ0c1d6f3G0N8JQA5mmnsoRPmh8lBoe2qZQdTT4J4_1739440786 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 24.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 02/17/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://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/53bc170b2ac01ebfd8867bff3217a37900a9a005 Thanks. Kevin --- >From 53bc170b2ac01ebfd8867bff3217a37900a9a005 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Fri, 29 Nov 2024 17:10:14 +0100 Subject: [PATCH] log: fix double free on cleanup [ upstream commit ba9fb2795b9f751836c0949c0c531da7af52a4f2 ] Fix the following crash when closing a log file after rte_eal_cleanup(): double free or corruption (!prev) Thread 1 "grout" received signal SIGABRT, Aborted. __pthread_kill_implementation (threadid=, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44 ... #10 _IO_new_fclose (fp=0xb63090) at iofclose.c:74 #11 0x000000000049c04e in dpdk_fini () at ../main/dpdk.c:204 #12 0x0000000000402ab8 in main (...) at ../main/main.c:217 (gdb) up 11 #11 0x000000000049c04e in dpdk_fini () at ../main/dpdk.c:204 202 rte_eal_cleanup(); 203 if (log_stream != NULL) 204 fclose(log_stream); When the application has passed a custom file via rte_openlog_stream() DPDK should not call fclose() on it. Add an internal is_internal_file field to track whether the file has been allocated by DPDK (syslog or journald) to determine if it should be closed or not. Fixes: 985130369be3 ("log: rework syslog handling") Signed-off-by: Robin Jarry Reviewed-by: Stephen Hemminger --- lib/log/log.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/log/log.c b/lib/log/log.c index eb087d601e..e1c18a8e53 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -39,4 +39,5 @@ static struct rte_logs { uint32_t level; /**< Log level. */ FILE *file; /**< Output file set by rte_openlog_stream, or NULL. */ + bool is_internal_file; log_print_t print_func; size_t dynamic_types_len; @@ -81,6 +82,9 @@ int rte_openlog_stream(FILE *f) { + if (rte_logs.is_internal_file && rte_logs.file != NULL) + fclose(rte_logs.file); rte_logs.file = f; rte_logs.print_func = vfprintf; + rte_logs.is_internal_file = false; return 0; } @@ -521,4 +525,5 @@ eal_log_init(const char *id) if (logf) { rte_openlog_stream(logf); + rte_logs.is_internal_file = true; } else { bool is_terminal = isatty(fileno(stderr)); @@ -551,10 +556,7 @@ void rte_eal_log_cleanup(void) { - FILE *log_stream = rte_logs.file; - - /* don't close stderr on the application */ - if (log_stream != NULL) - fclose(log_stream); - + if (rte_logs.is_internal_file && rte_logs.file != NULL) + fclose(rte_logs.file); rte_logs.file = NULL; + rte_logs.is_internal_file = false; } -- 2.48.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-02-12 17:29:34.775525635 +0000 +++ 0001-log-fix-double-free-on-cleanup.patch 2025-02-12 17:29:34.106944474 +0000 @@ -1 +1 @@ -From ba9fb2795b9f751836c0949c0c531da7af52a4f2 Mon Sep 17 00:00:00 2001 +From 53bc170b2ac01ebfd8867bff3217a37900a9a005 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit ba9fb2795b9f751836c0949c0c531da7af52a4f2 ] + @@ -31 +32,0 @@ -Cc: stable@dpdk.org