From patchwork Fri Aug 1 12:06:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wielaard X-Patchwork-Id: 117435 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 87FF5385843D for ; Fri, 1 Aug 2025 12:18:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87FF5385843D X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id CFE083858D1E for ; Fri, 1 Aug 2025 12:17:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CFE083858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CFE083858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=45.83.234.184 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1754050651; cv=none; b=R3KEly7tV5oCMzSvIaSIRFEUWeNWvug1nP97agZxBoV/4kFapCDE2/8xgrUyZWjabt7HV6v+KGMmZA1N0Xlf4S8npj2jMGMVyv1igD0A+pyUtWZKiElpLWdeNsQO1/upkH0NqMqrljfV+Jkh7SLiWdtHjXTEFtYQTHWMXddrAvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1754050651; c=relaxed/simple; bh=JNAsl2RInqgNVaDnoOCAsC6Y1OJaxs3LQzk+8s2mEEQ=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=oGE/FLkxT5Rn2Xuv3IH659t5DA+0fOYkAHM5IRHlOGNPlHn6uo6brEAshrR95/smBzjgOOAGc3DbVB2l5AtSDefpIyfl0H06Q3fER557IyMGhGfJHh1ZYthmCg9oS9VWWU/+Hleq2BWkm27OAdwIhX5dowTl3kleP0gxSvjoPA0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CFE083858D1E Received: from r6.localdomain (82-217-174-174.cable.dynamic.v4.ziggo.nl [82.217.174.174]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 7D6FF314136B; Fri, 1 Aug 2025 14:17:29 +0200 (CEST) Received: by r6.localdomain (Postfix, from userid 1000) id 8B1D1340819; Fri, 01 Aug 2025 14:17:28 +0200 (CEST) From: Mark Wielaard To: libc-alpha@sourceware.org Cc: "Andreas K . Huettel" , Davide Cavalca , Florian Weimer Subject: [PATCH release/2.41/master] stdlib: resolve a double lock init issue after fork [BZ #32994] Date: Fri, 1 Aug 2025 14:06:42 +0200 Message-ID: <20250801120642.2170756-1-mark@klomp.org> X-Mailer: git-send-email 2.50.1 MIME-Version: 1.0 X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org From: Davide Cavalca The __abort_fork_reset_child (introduced in d40ac01cbbc66e6d9dbd8e3485605c63b2178251) call resets the lock after the fork. This causes a DRD regression in valgrind (https://bugs.kde.org/show_bug.cgi?id=503668), as it's effectively a double initialization, despite it being actually ok in this case. As suggested in https://sourceware.org/bugzilla/show_bug.cgi?id=32994#c2 we replace it here with a memcpy of another initialized lock instead, which makes valgrind happy. Reviewed-by: Florian Weimer (cherry picked from commit d9a348d0927c7a1aec5caf3df3fcd36956b3eb23) --- NEWS | 1 + stdlib/abort.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 89d0935bebf4..1a58f3e4e456 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,7 @@ The following bugs were resolved with this release: [32981] ports: elf/tst-execstack-prog-static-tunable fails on sparc64-linux-gnu [32987] elf: Fix subprocess status handling for tst-dlopen-sgid + [32994] stdlib: resolve a double lock init issue after fork [33164] iconv -o should not create executable files [33185] Fix double-free after allocation failure in regcomp diff --git a/stdlib/abort.c b/stdlib/abort.c index caa9e6dc0494..904244a2fb5b 100644 --- a/stdlib/abort.c +++ b/stdlib/abort.c @@ -19,6 +19,7 @@ #include #include #include +#include #include /* Try to get a machine dependent instruction which will make the @@ -42,7 +43,10 @@ __libc_rwlock_define_initialized (static, lock); void __abort_fork_reset_child (void) { - __libc_rwlock_init (lock); + /* Reinitialize lock without calling pthread_rwlock_init, to + avoid a valgrind DRD false positive. */ + __libc_rwlock_define_initialized (, reset_lock); + memcpy (&lock, &reset_lock, sizeof (lock)); } void