From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by sourceware.org (Postfix) with ESMTPS id 0FD9F3858D1E for ; Wed, 29 Mar 2023 14:19:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0FD9F3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-x32d.google.com with SMTP id k14-20020a9d700e000000b0069faa923e7eso8258981otj.10 for ; Wed, 29 Mar 2023 07:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680099580; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=me9BoEQJAuBZMPEPVtCjVEEhLpP1XSzwLBBS2DLzIvc=; b=xBEH070MTZ9dykRk/ZgmRxaQ+S1IM+SslbtV7tX8YpvpyD45SEB5YZ4WZ8N2laVxsd 77ivg4r8NcjRCAnsI0v4esFlt2fDJwG2CFVDT2A9X+JBur3QfGR3k7ieo34Oy9OUEY6+ oF+llDgIhO8ButTwwHvhr82iKzwZvZORB6SKN3ZTFKpE5cWWYU6BZ6ekG7gG0SdaX3B8 rjNrZdXVoQvxSHLUyxX6l7HBbzajzmw95LsI+HVYBD2hxFoydWoN5mDZstz+WNFOQ1af 2c+4c7RZEqLrF9AnJcDKtGVC0u/pqbX/smfYjsE0UH/K5aS719Y5lJgNLodBbY6gDBr0 k6LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680099580; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=me9BoEQJAuBZMPEPVtCjVEEhLpP1XSzwLBBS2DLzIvc=; b=Z71a1jy7vAaFNknq62qlvO6967Ls3pAPJ7dY7/piDh/DMHVxCQ5bEPg48lfYSiSGC4 M0RXztgxW9ymZmOW+r4z03/Qz/6FWHxxEGqSgj4mRaqisgD9V768Hps7MTvHcuwKyYJO fMQ40unHkpxaOkgbvZhVpfvzNerHiFPlCUHSwdtLsuo2wtpwYcjH01+rqXtMIlJDwQoj Sn6mXqWNotijF4ajZxCKiQkcW9rSKcjkIwi8H2SbJJQtk3ZhdaCxtt4TWFwKwxY6B/W6 C4vrbA7BwFVVGmE6I4a1KIDRK5JgiMjEOWJYf9emR28xYRW5+rY1E0FafK201+thRHgG cmmw== X-Gm-Message-State: AO0yUKVT80MV5wHcvrWBb4Bwf+AvZWgTdLjYFqagt+LAZC2oXh/WXcsc XdegSNvLa62ISM8lUU4dhE/jZ7ZSoZXMIBVYjtcusQ== X-Google-Smtp-Source: AK7set/CnWmHwRZ7MSICYBIGY0IRszZlQmeJtAnLfbnnsCa/3AEslzPHERs7jFFV6uiN94dUH0YbOA== X-Received: by 2002:a05:6830:1d89:b0:69f:585:dacf with SMTP id y9-20020a0568301d8900b0069f0585dacfmr9730171oti.17.1680099580258; Wed, 29 Mar 2023 07:19:40 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c1:60f9:1426:1d2d:d6b:1761? ([2804:1b3:a7c1:60f9:1426:1d2d:d6b:1761]) by smtp.gmail.com with ESMTPSA id di7-20020a0568303a0700b00690e21a46e1sm14075862otb.56.2023.03.29.07.19.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Mar 2023 07:19:39 -0700 (PDT) Message-ID: <58e025ba-ae95-bce8-f58e-6c80b4445e45@linaro.org> Date: Wed, 29 Mar 2023 11:19:37 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH 01/13] elf: strdup() l_name if no realname [BZ #30100] Content-Language: en-US To: stsp , 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: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,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: On 29/03/23 11:12, stsp wrote: > > 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()? Yes, I did not take in consideration dlmem inclusion for this. If dlmem breaks this assumption, it is another issue with the interface. > Then its a dlmem-specific patch.