From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id D6D0D3858D28 for ; Mon, 8 Apr 2024 17:55:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D6D0D3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D6D0D3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::429 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712598935; cv=none; b=pDkFKa3yj6EHDHi+cqZxqiJzMXd7KjoZfRULD0kiuDOew2durypA+fK/FVVEwMF5C1U0OE6KMexp3IFo0HdRBuWrZVOGnrdtEaBUDe8I3TSSyIC137LswPt4H0TPCJ/V7dSoxBt+xQszV9lGPsxTJyFrTGUyupo+PHPI0gnZUk4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712598935; c=relaxed/simple; bh=0+1wGU+IJwcolqvAh/uSYTeW/b62YlmtWqAM1OHhlNY=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=HUpSkYpVeQsBu5ckiwWlwYhV5FhO4K7zXD//02Z0CSOhyZV/tQKZUCwhUNpMEQLO0+5XX6sc3UT/540oZe+VBIbOoKx/qZ+CtfD6KLh5ZgWxt0JkjCIH7joqEUl8y6fodYdDBRmSk4VHcS+JdclCDiJbvV079rBQrGtEmQiPGKg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6ed627829e6so598146b3a.1 for ; Mon, 08 Apr 2024 10:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712598933; x=1713203733; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=YSldVxGbrpjwlHo5vg3l7oCaY7TuRfJzYBWN4uov3ws=; b=exlrB7SzN9jV8EI53kVDJjBMbtTxlvQddnE/EiFZxQpxcxhX9DOyj5zbbnuNEu3NNI Y69sDvh2/yhYX/jzLdlGMUmBi0UpL8f4ggZ0nzWwioeL6HWwuIaBy48nEhNal5EDHjJp NvjTNRr7D1ZGbpjHsfRr/L2tF1HdUaSvg9VYx+CqmLda/8FEcS/U8Z0nKOfjf6a0conH R8KdKp12ar1YkJ9WWXmyI5NH1BAuhc3/h2ENfhPBDMuyx6HCQWdn57BH0iYPuT2ulAjH SEi9Y4o702T5Xo1VoYVbXOmwqDlKU6VP+nJtxh1dQbJWvpG7FB51IZ4zkl2J2jihp/AD FwVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712598933; x=1713203733; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YSldVxGbrpjwlHo5vg3l7oCaY7TuRfJzYBWN4uov3ws=; b=kzFSlWUwmxJ2W/0E/oa0IX0xcSLMD155Uht43k3AlhuHUuHSH2urtLzekqizTEqhBZ pPa6dYDqXToMVjskociigIRBkY39I4Y5uMAm2vhxVbMnklOJVu/ejorRDOzG0B9HMZEq fE8nsRX5oid51nVyO7kCF+Qm7/ND2srvpUFqaJ1KSIuDDLpVEBI9FjKuntIHZBymXZjm dgXEc6yO/S0G9x338EfN3lT/KJxoV/54v000VG28HbDcWuUqQ363Itmm7fTOq6QXOdSI fVC9dX4A4TSwEtYc11U2isbpFg1goyi35tfroEJr1+Zb13e+LP0hNMh4ueOCU2ttBz1x Uh+w== X-Gm-Message-State: AOJu0YwHeFPjQK2qbHUyacqob/R0l5FMhdDcT8r6hbVTXbYdVTrXEa84 1OI+dBWxESdDiTN3BEvwE7l2TJOR+qxx0ZjPk/kYXpvpHrEpH8mnPY/Fz7gf/gz/2Z62V08EDj+ i X-Google-Smtp-Source: AGHT+IHmoek3068jO7OMdxQibDmifRMAYwgnmOgITK9K5WqubyH8hPHT34xh3fydOJc1pYJfAXnc1g== X-Received: by 2002:a05:6a00:8618:b0:6ed:1c7:8c65 with SMTP id hg24-20020a056a00861800b006ed01c78c65mr10205195pfb.10.1712598932694; Mon, 08 Apr 2024 10:55:32 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c0:3e7e:c5ca:dd5b:a5af:8027? ([2804:1b3:a7c0:3e7e:c5ca:dd5b:a5af:8027]) by smtp.gmail.com with ESMTPSA id l23-20020a635717000000b005cd835182c5sm6822027pgb.79.2024.04.08.10.55.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Apr 2024 10:55:32 -0700 (PDT) Message-ID: <44d263ca-7d4a-4315-abdf-005f43912709@linaro.org> Date: Mon, 8 Apr 2024 14:55:29 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] elf: Check objname before calling fatal_error To: "H.J. Lu" Cc: libc-alpha@sourceware.org References: <20240408160609.1264205-1-hjl.tools@gmail.com> Content-Language: en-US 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=-12.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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 08/04/24 14:39, H.J. Lu wrote: > On Mon, Apr 8, 2024 at 10:18 AM Adhemerval Zanella Netto > wrote: >> >> >> >> On 08/04/24 13:58, H.J. Lu wrote: >>> On Mon, Apr 8, 2024 at 9:47 AM Adhemerval Zanella Netto >>> wrote: >>>> >>>> >>>> >>>> On 08/04/24 13:06, H.J. Lu wrote: >>>>> _dl_signal_error may be called with objname == NULL. _dl_exception_create >>>>> checks objname == NULL. But fatal_error doesn't. Check objname before >>>>> calling fatal_error. This fixes BZ #31596. >>>> >>>> Do we have a reproducer for this? The one from BZ#31596 does seems to trigger >>>> it. >>> >>> We don't. But it may happen in theory. >> >> Why not add the test on fatal_error instead? Because if we are adding >> possible check for argument where we are not sure that it might trigger, >> it is clear to me to add where the issue might happen (besides that our >> policy is to avoid adding fixes without proper reproducers). > > void > _dl_signal_exception (int errcode, struct dl_exception *exception, > const char *occasion) > { > struct rtld_catch *lcatch = get_catch (); > if (lcatch != NULL) > { > *lcatch->exception = *exception; > *lcatch->errcode = errcode; > > /* We do not restore the signal mask because none was saved. */ > __longjmp (lcatch->env[0].__jmpbuf, 1); > } > else > fatal_error (errcode, exception->objname, occasion, exception->errstring); > } > > Will exception->objname ever be NULL? >From the Florian example [1], most of failures where _dl_signal_error is called with NULL are for malloc failure or any other error. Maybe another option would to actually pass the objname in such cases. [1] https://patchwork.sourceware.org/project/glibc/patch/877ch7vmab.fsf@oldenburg.str.redhat.com/ > >> Also, I think we should close the BZ#31596 as a notabug because the >> reproducer does not actually trigger an issue and it is misleading >> that this is a glibc issue. >> >>> >>>>> --- >>>>> elf/dl-catch.c | 6 +++++- >>>>> 1 file changed, 5 insertions(+), 1 deletion(-) >>>>> >>>>> diff --git a/elf/dl-catch.c b/elf/dl-catch.c >>>>> index 2109516dba..8ef7a4c706 100644 >>>>> --- a/elf/dl-catch.c >>>>> +++ b/elf/dl-catch.c >>>>> @@ -126,7 +126,11 @@ _dl_signal_error (int errcode, const char *objname, const char *occasion, >>>>> __longjmp (lcatch->env[0].__jmpbuf, 1); >>>>> } >>>>> else >>>>> - fatal_error (errcode, objname, occasion, errstring); >>>>> + { >>>>> + if (objname == NULL) >>>>> + objname = ""; >>>>> + fatal_error (errcode, objname, occasion, errstring); >>>>> + } >>>>> } >>>>> rtld_hidden_def (_dl_signal_error) >>>>> >> >> > >