From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from forward500a.mail.yandex.net (forward500a.mail.yandex.net [IPv6:2a02:6b8:c0e:500:1:45:d181:d500]) by sourceware.org (Postfix) with ESMTPS id 91DD03858D1E for ; Wed, 29 Mar 2023 14:12:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 91DD03858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=yandex.ru Received: from mail-nwsmtp-smtp-production-main-39.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-39.vla.yp-c.yandex.net [IPv6:2a02:6b8:c0d:31b:0:640:fdf8:0]) by forward500a.mail.yandex.net (Yandex) with ESMTP id BD4E85E4FC; Wed, 29 Mar 2023 17:12:49 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-39.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id mCJxhp2DfuQ0-8Ntcd3Ss; Wed, 29 Mar 2023 17:12:49 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1680099169; bh=K4CMKuh5JbOckXmN2rAOTFzUo4/vTTu6mg6iL7Is+6Q=; h=In-Reply-To:From:Date:References:To:Subject:Message-ID; b=KTS+Migu+i4lmSCxpBIsoH5DYgmZmnKUSL/Z037WNne6pqK1f9B7JtzWZVlabZ4sE By/jCyDyvpCg3BNpmttHEZhbB6Rdg4HozfNYFaEHIPF69RIW+VzT/c7MxBGvOiWkuo Yg1gQv4lp+TnwljAevddr+tLcWCQoj67KltAQBrE= Authentication-Results: mail-nwsmtp-smtp-production-main-39.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Message-ID: Date: Wed, 29 Mar 2023 19:12:47 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH 01/13] elf: strdup() l_name if no realname [BZ #30100] Content-Language: en-US To: Adhemerval Zanella Netto , libc-alpha@sourceware.org References: <20230318165110.3672749-1-stsp2@yandex.ru> <20230318165110.3672749-2-stsp2@yandex.ru> <1da89fa5-e322-7cfa-0e0c-7074a4436a44@linaro.org> From: stsp In-Reply-To: <1da89fa5-e322-7cfa-0e0c-7074a4436a44@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,NICE_REPLY_A,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 List-Id: 29.03.2023 18:54, Adhemerval Zanella Netto пишет: > > On 18/03/23 13:50, Stas Sergeev via Libc-alpha wrote: >> _dl_close_worker() has this code: >> /* This name always is allocated. */ >> free (imap->l_name); >> >> But in that particular case, while indeed being allocated, l_name >> doesn't point to the start of an allocation: >> new = (struct link_map *) calloc (sizeof (*new) + audit_space >> + sizeof (struct link_map *) >> + sizeof (*newname) + libname_len, 1); >> ... >> new->l_symbolic_searchlist.r_list = (struct link_map **) ((char *) (new + 1) >> + audit_space); >> >> new->l_libname = newname >> = (struct libname_list *) (new->l_symbolic_searchlist.r_list + 1); >> newname->name = (char *) memcpy (newname + 1, libname, libname_len); >> ... >> new->l_name = (char *) newname->name + libname_len - 1; >> >> It therefore cannot be freed separately. >> Use strdup("") as a simple fix. > This is not required, the l_name alias to newname->name is only used for > __RTLD_OPENEXEC (used by loader on DT_NEEDED) and these handlers are not > meant to be dlclose. But dlmem() can also use "" as the name if the name is not specified explicitly. Without that patch it crashes. I think you mean its not needed w/o dlmem()? Then its a dlmem-specific patch.