From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22636 invoked from network); 16 Feb 2022 21:03:08 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 16 Feb 2022 21:03:08 -0000 Received: (qmail 13522 invoked by uid 550); 16 Feb 2022 21:03:06 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 13446 invoked from network); 16 Feb 2022 21:03:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645045373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BdysEKEAnYn1WcEpAT4daDO5eZ94Z3a7WjMsSw8rUsA=; b=NEm/zyh20sYmGh7Jo0336e5Z3XVWGhIYRdLaKGNQY5fH9gYbVuu4+DlaWdxtBBl1vtF8bp B0cKhOWRajlM1n1f/PylD8Mu+eK8mF4fo3/alNK7tgaW0IdhnwBpM+MDbTKbQc+RQHUukL NTGdP7jGUNFr+VIVYWh1So2CbMVDWFQ= X-MC-Unique: AF0hFdPyNda7qSBR_-Az-A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=BdysEKEAnYn1WcEpAT4daDO5eZ94Z3a7WjMsSw8rUsA=; b=TeikoQRocVbZA9e+qLWIAgyUM6BP+mGUYX27qvGD4Ciu86EWW59m1sOt3yQucJcUNs QxTJxHbOp9TrQJYffWIIkj5MmCTfamDGpem49N3xNU/1Xt9qiIDvw09/AKr6sGOvZcs7 /Dflmti+OcEne0/lUSUexlbf3XgDmOVGpqvrqnWkvqraHJn3j8lqIK6UmJfLHrqzo7wf x8Qi3VMApQpSPaZtvfWB2AA+6jfAvZBjXYBksiaDa0GZD8DBVXalD0fqV/EWZDohQaj9 HCKa2D5rbr7Er4Vi8NdBn3C1EoyqTBhWBpjBpw+DWzRAi+aX1AlrJmMwpnDACkrD+Lh6 P8Tw== X-Gm-Message-State: AOAM53165SmXRiRCoSmJ4qRr7TN/XhMePaLT+vivkTgsroGHCepk1e0t aKMqM7XmcgY7PVvhGBDTWJ/72ILuzmqsS81OPcgbtpQzLKyGUwKLkXA4LQ2QX8M0DQV3XNGbUxJ VoYRbEeOXw1d5YQiO6A== X-Received: by 2002:a02:19c7:0:b0:314:5a39:3f55 with SMTP id b190-20020a0219c7000000b003145a393f55mr2800163jab.290.1645045371641; Wed, 16 Feb 2022 13:02:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwO5EI20RyegvWmqRuwCdjPobJwGCc1J+V9qnOQnwc0Qwlc3N1BIFmTmvb1Lko3Q8DlaA1J2w== X-Received: by 2002:a02:19c7:0:b0:314:5a39:3f55 with SMTP id b190-20020a0219c7000000b003145a393f55mr2800150jab.290.1645045371417; Wed, 16 Feb 2022 13:02:51 -0800 (PST) Message-ID: <4481efb2-88d5-6b42-215d-6d7d96713274@redhat.com> Date: Wed, 16 Feb 2022 16:02:49 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 To: Florian Weimer Cc: musl@lists.openwall.com, Markus Wichmann References: <20220216194020.GA16437@voyager> <75d1d0f9-950b-6bb1-0ed5-f1d28df0cef8@redhat.com> <87wnhuy19i.fsf@oldenburg.str.redhat.com> From: Carlos O'Donell Organization: Red Hat In-Reply-To: <87wnhuy19i.fsf@oldenburg.str.redhat.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=carlos@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [musl] Is errno signal-safe? On 2/16/22 16:01, Florian Weimer wrote: > * Carlos O'Donell: > >> On 2/16/22 14:40, Markus Wichmann wrote: >>> Hi all, >>> >>> today I had a flash of inspiration while staring at some code: errno is >>> a global variable, right? OK, it is thread-local, but still a global >>> variable in the context of one thread. And looking at a global variable >>> while it may (or may not) be modified in a signal handler is not safe to >>> do. >> >> It is required that errno, if changed, must be restored by the signal >> handler before exit (though note that for glibc the underlying lazy >> TLS allocation implementation makes errno AS-unsafe for first use in a >> signal handler because calloc is used to allocate the storage). > > glibc uses initial-exec TLS under the hood for storing the int variable, > so the variable access itself async-signal-safe (whether it goes > directly to errno@GLIBC_PRIVATE or via __errno_location, it doesn't > matter). Thanks. I'd forgotten about that quirk. Every *other* use of non-initial-exec TLS is still AS-unsafe. -- Cheers, Carlos.