From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id qUhrHEeIumrEQxIAWB0awg (envelope-from ) for ; Mon, 28 Sep 2026 11:31:19 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=gwsSvu+d; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=2X/Kj2qK; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=x9fqJ7VU; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=s2ogq8lo; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 702781E06B; Mon, 28 Sep 2026 11:31:19 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=unavailable autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A67D71E01F for ; Mon, 28 Sep 2026 11:31:18 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D60844BAE7F8 for ; Mon, 28 Sep 2026 15:31:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D60844BAE7F8 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=gwsSvu+d; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=2X/Kj2qK; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=x9fqJ7VU; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=s2ogq8lo Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 46CE74B9DB78 for ; Mon, 28 Sep 2026 15:30:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 46CE74B9DB78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 46CE74B9DB78 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790609449; cv=none; b=IW44Goiy8uamus5x0jCjZQRny/TsbgWiDY8MVEH7JAKMDOSOwZirOfDbpkHovyqVhh+Ym/Ouqglc5+cmryO7Ven8uTu0afVdATgMACxEBku1b+CSD1jRYdXVnh78wb/bPEPEnD/E028NTwolw7HhNuO+pbuEOwG9sfjYrYoqZp0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790609449; c=relaxed/simple; bh=6eVyzkC63zsSROwd1dIMPsANeijEAHaQTdXi9kDXO30=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=NSVBhkrjjk2bE890JMQBBeGcK1Cj0YZa9I21OwqXtczdeS1w3wKGbmAqGfWOaQTlDgpBpOQT2sWomlc4KxRQd+hhsa5yLsHcHZlGPwTJ5XjdPb5QA9P8PnTOH3p8uAZCvn7tdJwOxOwVzTIo/WvXNk3tKRn2qhE00MJ30tJsh84= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=gwsSvu+d; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=2X/Kj2qK; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=x9fqJ7VU; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=s2ogq8lo DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 46CE74B9DB78 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id F2E7021BBF; Mon, 28 Sep 2026 15:30:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790609444; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YAGu5LS8Ci6kzp7uEJ3ydeAHERcaSKVZruwwQoPcwQY=; b=gwsSvu+dwzLhYpFcNkKCO2aJytUwRMImfvyEfVvp/0tjs1ZMnF/skG6/UwPFxBpbK7lORM x2tleMC6iZPqkwJ57mUnU3XG83qWllIlcBs+cUS1d5NkiF4UVsq52Lem51SesR+JWcYyeO VS4T9w4z0jwCRHd/V5q+TNtaIhFeno4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790609444; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YAGu5LS8Ci6kzp7uEJ3ydeAHERcaSKVZruwwQoPcwQY=; b=2X/Kj2qKdtAeRHFYi/J3U0BPY5YL84a15vyw0dZbNrYSrMTIrO8MQUV0CHK92QEwlQ/JKu V31F//09lovmdrDA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=x9fqJ7VU; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=s2ogq8lo DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790609440; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YAGu5LS8Ci6kzp7uEJ3ydeAHERcaSKVZruwwQoPcwQY=; b=x9fqJ7VUAG+Vd6NUs3rWA+zB02o2XmWZ+NvNv5OaaUefG6T1hgNehpe3zy/VEybaw0vbnX wAQeP5lWYTfhe+AaL9DQZl6JPvC98xGSSlaKra3mQKmUScv/uBPIOb7o8m24W18YowwkmA 5NPclpAEXZAZYk7/b8Urg3H4waJA8Zc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790609440; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YAGu5LS8Ci6kzp7uEJ3ydeAHERcaSKVZruwwQoPcwQY=; b=s2ogq8lol5GAn/7AQyoTlh7eS362/HLB/sAG5CPcRa+KKX6aDYMZFG1NdXcFAJvqAtTb0b E8UoKrwHhQu/NcCQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B8B35133F3; Mon, 28 Sep 2026 15:30:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id JlrnHh+Iumo/PwAAD6G6ig (envelope-from ); Mon, 28 Sep 2026 15:30:39 +0000 Message-ID: <1fac98af-e3d1-47ba-a0b6-c97344bfe6c9@suse.de> Date: Mon, 28 Sep 2026 17:30:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] [gdb] Detect corrupt link map with zero l_ld and l_addr To: Simon Marchi , gdb-patches@sourceware.org References: <20260927063055.1997027-1-tdevries@suse.de> Content-Language: en-US From: Tom de Vries In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: F2E7021BBF X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_TWO(0.00)[2]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_SOME(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim, suse.de:mid, ld.so:url, imap1.dmz-prg2.suse.org:rdns, imap1.dmz-prg2.suse.org:helo, almalinux.org:url, sourceware.org:url] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 9/28/26 4:54 PM, Simon Marchi wrote: > On 9/27/26 2:30 AM, Tom de Vries wrote: >> On ppc64le-linux (AlmaLinux 9.8), I run into: >> ... >> FAIL: gdb.mi/mi-dlmopen.exp: still-in-use fields were all correct >> ... >> >> While investigating this, I stumbled on this warning emitted during the >> calculation of allow_dlmopen_tests: >> ... >> (gdb) run ^M >> Starting program: allow_dlmopen_tests.x ^M >> [Thread debugging using libthread_db enabled]^M >> Using host libthread_db library "/lib64/libthread_db.so.1".^M >> warning: .dynamic section for "/lib64/ld64.so.2" is not at the expected \ >> address (wrong library or version mismatch?)^M >> dlmopen debug supported.^M >> ... >> >> The warning is mentioned in this glibc commit 88361b408b: >> ... >> elf: Copy l_addr/l_ld when adding ld.so to a new namespace >> >> When add ld.so to a new namespace, we don't actually load ld.so. We >> create a new link map and refers the real one for almost everything. >> Copy l_addr and l_ld from the real ld.so link map to avoid GDB warning: >> >> warning: .dynamic section for ".../elf/ld-linux-x86-64.so.2" is not at \ >> the expected address (wrong library or version mismatch?) >> >> when handling shared library loaded by dlmopen. >> ... >> >> So, AFAICT the setup is: >> - the glibc package is based on v2.34 >> - it contains a backport of commit a93d9e03a3 ("Extend struct r_debug to >> support multiple namespaces [BZ #15971]") >> - it doesn't contain a backport of commit 88361b408b ("elf: Copy l_addr/l_ld >> when adding ld.so to a new namespace") [1] >> - both commits are part of v2.35 >> >> What happens is: >> - when probing for l_addr and l_ld in svr4_solib_ops::read_lm_info, both get >> the value 0 >> - in svr4_solib_ops::lm_addr_check, the 0 value propagates to l_dynaddr, and >> "l_addr = l_dynaddr - dynaddr" then underflows, and things go downhill from >> there, resulting in the warning and eventually the FAIL. >> >> Fix this by detecting the situation in svr4_solib_ops::read_so_list, and >> bailing out with a warning. >> >> Add detection of this and other "corruption" warnings in allow_dlmopen_tests >> to make sure the related test-cases are skipped. >> >> In more detail, before this patch we have: >> ... >> $ gdb -q -batch outputs/gdb.base/dlmopen/dlmopen -ex start -ex next \ >> -ex "pipe info shared | ld64" >> ... >> warning: .dynamic section for "/lib64/ld64.so.2" is not at the expected \ >> address (wrong library or version mismatch?) >> ... >> 0x00007ffff7f80000 0x00007ffff8000000 0 Yes /lib64/ld64.so.2 >> 0x0000000000000160 0xffffffffffff0000 1 Yes /lib64/ld64.so.2 >> ... >> and after: >> ... >> warning: Corrupted shared library entry: zero l_addr and l_ld >> warning: Corrupted shared library entry: zero l_addr and l_ld >> ... >> 0x00007ffff7f80000 0x00007ffff8000000 0 Yes /lib64/ld64.so.2 >> ... >> >> Alternatively, we could prevent the underflow in svr4_solib_ops::lm_addr_check: >> ... >> bool l_addr_updated = false; >> if (l_dynaddr >= dynaddr) >> { >> l_addr = l_dynaddr - dynaddr; >> l_addr_updated = true; >> } >> >> if (l_addr_updated >> && (l_addr & (minpagesize - 1)) == 0 >> && (l_addr & align) == ((l_dynaddr - dynaddr) & align)) >> ... >> but we'd still get an incorrect range: >> ... >> warning: .dynamic section for "/lib64/ld64.so.2" is not at the expected \ >> address (wrong library or version mismatch?) >> ... >> 0x00007ffff7f80000 0x00007ffff8000000 0 Yes /lib64/ld64.so.2 >> 0x0000000000060000 0x0000000000080000 1 Yes /lib64/ld64.so.2 >> ... >> >> FTR, in an earlier attempt I proposed to deal with the FAIL using an >> xfail [2]. And in an another attempt I proposed to deal with it by >> replicating the glibc fix in gdb [3]. >> >> Changed in v2: >> - fixed incorrect footnote reference >> - made comment more precise >> - use "AlmaLinux" consistently >> >> Versions: >> - v1 https://sourceware.org/pipermail/gdb-patches/2026-September/230275.html >> >> Tested on ppc64le-linux and x86_64-linux. >> >> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33662 >> >> [1] https://bugs.almalinux.org/view.php?id=667 >> [2] https://sourceware.org/pipermail/gdb-patches/2026-July/229073.html >> [3] https://sourceware.org/pipermail/gdb-patches/2026-August/229549.html >> --- >> gdb/solib-svr4.c | 23 +++++++++++++++++++++++ >> gdb/testsuite/lib/gdb.exp | 3 +++ >> 2 files changed, 26 insertions(+) >> >> diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c >> index c4af1b11a4d..810b0fae7a3 100644 >> --- a/gdb/solib-svr4.c >> +++ b/gdb/solib-svr4.c >> @@ -1333,6 +1333,29 @@ svr4_solib_ops::read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, >> if (*name == '\0' || match_main (name.get ())) >> continue; >> >> + gdb_byte dummy; >> + if (li->l_addr_inferior == 0 && li->l_ld == 0 >> + && target_read_memory (0, &dummy, 1) != 0) >> + { >> + /* We have l_addr_inferior == 0 and l_ld == 0 (corresponding to link >> + map entries l_addr and l_ld). This can happen with a glibc that: >> + - has commit a93d9e03a3 ("Extend struct r_debug to support >> + multiple namespaces [BZ #15971]"), but >> + - misses commit 88361b408b ("elf: Copy l_addr/l_ld when adding >> + ld.so to a new namespace"). >> + This seems to be the case at least for the AlmaLinux 9.8 BaseOS >> + version, which uses glibc v2.34 and backports only the first >> + commit ( https://bugs.almalinux.org/view.php?id=667 ). >> + Detect this here and bail out. Otherwise, we'll present >> + the user with incorrect info for "info shared". >> + >> + The target_read_memory is there to detect the improbable >> + situation that address 0 is mapped, in which case it might be the >> + address of the dynamic section. */ >> + warning (_("Corrupted shared library entry: zero l_addr and l_ld")); >> + return 0; >> + } > > Returning 0 means we stop reading the shared library list, is that > expected? The known case of this isn't really that the shared library > list is corrupted, just that this entry is incomplete. We could maybe > skip over this entry and keep reading the list, to be able to present > all the loaded shared libraries to the user? > Hi Simon, thanks for the review. I think you're right, using continue instead of return 0 is more appropriate. > Is the warning printed every time the library list is read (like at each > stop)? Does that become annoying for the user? > > In the end maybe we don't care too much about these concerns, because > it's for one specific version of one specific distro, and only when > debugging programs that use multiple namespaces (which are quite rare I > think). > It could be annoying, agreed. I'm treating this though as a corruption that is triggered by one specific version of one specific distro, but might happen otherwise. So I think there is information in how many times the warning triggers. We could keep track for which shared libs the warning triggers, and emit a summary instead. But I don't think it's worth the bother at this point. Thanks, - Tom > Simon