From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc30.google.com (mail-oo1-xc30.google.com [IPv6:2607:f8b0:4864:20::c30]) by sourceware.org (Postfix) with ESMTPS id 7CCE73858D28 for ; Tue, 1 Aug 2023 13:57:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7CCE73858D28 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-oo1-xc30.google.com with SMTP id 006d021491bc7-56c4c4e822eso3599716eaf.3 for ; Tue, 01 Aug 2023 06:57:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690898231; x=1691503031; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=ZfrvivNJ8Tg9PnC4MQ27+gVQS1BqFeSQWimkARnuJc4=; b=IHi/Y34OvxrXtMJdXAUc+9UWNxC6b7FER/6XwyyB3gfWOAA03+ZnVg6OFT+QQk17Oh sDQDqSDfxTN0ekYu27BDY6W1vPIuA+cadlmiNknsyF6itWQKi9wtz3FD+4ngUVdsyArC rCbRD4PUX3kyXBr33DiQRfp/vZ+XlpX+ZCmwSKq7DX3cEOrT5yEvpEFQUcvVVLV6zUxP bD4myWwBT28tEWcTOu8EEBqWXUzBAZ6xTknjjYJAHgS9zObUqwFGsOEwRawatXDYMt1l Tf7lOIkUwp33UZaKB2ZPtPfrFhurSCCCy7lKwtsVZm8pPg8G/JaCINUd1qL1gtjBOkcp hOqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690898231; x=1691503031; h=content-transfer-encoding:in-reply-to:organization:from:references :cc: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=ZfrvivNJ8Tg9PnC4MQ27+gVQS1BqFeSQWimkARnuJc4=; b=Dt2gNMWAGibeJqZVgT2TNhmBBtycW41mAWnnPf0B+oW1xyb12sKyLGM7q8aCGhcEfw qX6zIvuV7E64M991dol7CBJv+zIpCdbb7JhJmnjcLHUDInmkRWe1uwQ1h3J609cU22pb lJ7THC6ogKAyfFxQVca1yEL7dvvrzkcUnqAEdja71Aibqm0M8F3wwYUzBwu8sr1V7gHp 62+56rrCjraaogsN6qI6sy8DL+2HqwrwBIDkTeab+UDHBCOD+QmwVez6EP022nOOo5jz xJ+toM47/ZIfuznPA1lupMab4T/Wt5YDm1NWVp+g8YRRC07hHuSNDosIvGy6r9PFNaHl ZPIA== X-Gm-Message-State: ABy/qLYmg3oGw8qi+PucoVJkbL6CFXxkUCTEoJic/VybkJ0WsZsWT/Fv /QVsbvj9iz+mxraQL2H2u+IqAg== X-Google-Smtp-Source: APBJJlG4aweN3olgj/hzYSvsGrdyGlWkX6ju4I2LueBPLyhvgHX2Aj4mrB1rIoKxhWcxq3Wcajdk5w== X-Received: by 2002:a4a:2a54:0:b0:56c:a273:7d99 with SMTP id x20-20020a4a2a54000000b0056ca2737d99mr6826100oox.5.1690898231551; Tue, 01 Aug 2023 06:57:11 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c1:440b:a49a:e567:9a27:3db8? ([2804:1b3:a7c1:440b:a49a:e567:9a27:3db8]) by smtp.gmail.com with ESMTPSA id y21-20020a4ad655000000b0056cf10cc844sm500807oos.9.2023.08.01.06.57.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Aug 2023 06:57:11 -0700 (PDT) Message-ID: <3adbb9a8-b815-2d14-6128-e669d5da0436@linaro.org> Date: Tue, 1 Aug 2023 10:57:08 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH 2/2] stdlib: Make abort AS-safe (BZ 26275) Content-Language: en-US To: Florian Weimer , Adhemerval Zanella via Libc-alpha Cc: Carlos O'Donell References: <20230731171900.4065501-1-adhemerval.zanella@linaro.org> <20230731171900.4065501-3-adhemerval.zanella@linaro.org> <875y5z5fsl.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <875y5z5fsl.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 01/08/23 05:26, Florian Weimer wrote: > * Adhemerval Zanella via Libc-alpha: > >> +void >> +__abort_lock_lock (void) >> +{ >> + __libc_lock_lock (lock); >> +} > > I think __abort_lock_lock and __abort_lock_unlock should take a signal > mask argument, so that they are more like a async-signal-safe mutex. That was my first approach, but I changed it due __spawnix usage. The lock is really only required on clone call, so we can release it after clone returns. However we need to only umask signals after the execve call in helper process. We can move the abort unlock later, it should be ok as well (it would add a slight more latency on highly multithead programs that spawns a lot of thread and try to abort(), but it should be ok). > >> +/* Cause an abnormal program termination with core-dump. */ >> +_Noreturn void >> +abort (void) >> +{ >> + raise (SIGABRT); >> + >> + /* There is a SIGABRT handler installed and it returned, or SIGABRT was >> + blocked or ignored. In this case use a AS-safe lock to prevent sigaction >> + to change the signal disposition, reinstall the handle to abort the >> + process, and raise the signal again. */ >> + internal_signal_block_all (NULL); >> + __libc_lock_lock (lock); > > This could call __abort_lock_lock. Ack.