From patchwork Wed May 13 20:26:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1289705 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=nn7feJbw; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49MmRQ2RzBz9sSm for ; Thu, 14 May 2020 06:26:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2BCB43894E54; Wed, 13 May 2020 20:26:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BCB43894E54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1589401600; bh=Q/0W7UGWnY0vnAdQvOE/EiLwgc17gG31sE1W/f7XGTo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=nn7feJbwp7DkvEQRc3aPPtACImNrRkYWSaLX+GNCOxQ5Bff3UxLB6liKqYLv38Q6C t8iuHRv9jQj4zdUvPN3jMzjp14MB0vgmLhr3BAvVL6FFTEOnrnoFqpHZwJ2wZoIBny EC2PoqwreiVs5FZuRUyzjrfZp3BMmKEs0S5SWDfw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by sourceware.org (Postfix) with ESMTPS id C5560385DC14 for ; Wed, 13 May 2020 20:26:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C5560385DC14 Received: by mail-qt1-x844.google.com with SMTP id i68so997954qtb.5 for ; Wed, 13 May 2020 13:26:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Q/0W7UGWnY0vnAdQvOE/EiLwgc17gG31sE1W/f7XGTo=; b=Suq84pmh+si/xmgVVq1CRETRwTikPjgHXoZuvuMEimkEvibSgZiCwdTSiSY/0Hy4/S /52P2RmYLza23U/JHJh3B4uGKDw0Zumrt+bdzL/BYaNuWgv8MyOmfZR+HCAsFfgVVve7 m2eJ+Vcy3RDIjA4gM9nzS4OdO/vPq04clDeleIuPDx5g/XY//Mgw0oCSMQ/qd51ob0it Ajl8dwCNNi+mEWngc5dIDlNutcH3IR1PXH57YZc9lbzR2zBk4WUov3U58N4XWnOKshWF COdi8udXbwIpzIkulsLCPB3ACLgbYOJuSubyuPM/Y3d2n0unMZdo26oU3ev8gYCDt/71 hjTA== X-Gm-Message-State: AOAM531txwj3lD7kx2QJqFBz/3mtjHn3N3VC2Qj73G7LVkyCqOpNto5i fB5xDT552cUAKAq6SvPmLHEmSiqYsjI= X-Google-Smtp-Source: ABdhPJynh0uTV+GBAiRw3Wgp9FiiT5/1fOeYX/JjYfBkr8kJ0NoM1Klavqla/fK9CyAZoDJhK7nxrw== X-Received: by 2002:ac8:7a71:: with SMTP id w17mr927666qtt.257.1589401595554; Wed, 13 May 2020 13:26:35 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id 62sm806465qkh.113.2020.05.13.13.26.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 13:26:35 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [RFC 0/4] Make strsignal and strerror async-signal-safe Date: Wed, 13 May 2020 17:26:26 -0300 Message-Id: <20200513202630.2123238-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This is an attempt to improve both strsignal and strerror usability and provide the same semantic as direct access to the _sys_{err,sig}list arrays. The patchset is based on the patch to move both _sys_siglist and_sys_errlist to compat symbol. To fully make both symbols asyn-signal-safe it is required to both: 1. Allocate a per-thread bounded buffer and 2. Avoid to try translate the returned message. To setup the per-thread static buffer, two strategies are used: 1. The default one uses a TLS structure, which will be place in the static TLS space. 2. Linux allocates on struct pthread and access it through THREAD_* macros. The default strategy has the disadvantage of increasing libc.so static TLS consumption and thus descreasing the possible surplus used in some scenarios (which might be mitigated by BZ#25051 fix). It is used only on Hurd, where accessing the thread point in single thread case is not straightforward (afaiu, Hurd developers could correct me here). The translation avoidance is more tricky because it is a semantic change and that's why the patchset also add a new strsignal_l symbol. Some systems (bionic) does provide async-signal-safe version of the symbols, other system (FreeBSD) it is configurable. Also, some system also does not translate the messags (bionic and AIX7). I have not added compat symbols on this RFC, however I don't have a strong opinion regarding it. Adhemerval Zanella (4): string: Make strsignal async-signal-safe string: Add strsignal_l string: Make strerror async-signal-safe string: Move strerror_l pointer to tls_internal.h include/string.h | 2 + malloc/thread-freeres.c | 1 + manual/errno.texi | 2 +- manual/signal.texi | 6 +- nptl/descr.h | 5 +- string/Makefile | 2 +- string/Versions | 3 + string/_strerror.c | 80 ++++++------ string/strerror.c | 26 ++-- string/strerror_l.c | 34 +++-- string/string.h | 5 + string/strsignal.c | 119 +++++------------- string/strsignal_l.c | 68 ++++++++++ sysdeps/generic/Makefile | 1 + sysdeps/generic/tls_internal-struct.h | 39 ++++++ sysdeps/generic/tls_internal.c | 3 + sysdeps/generic/tls_internal.h | 32 +++++ sysdeps/mach/_strerror.c | 48 +++++-- sysdeps/mach/strerror_l.c | 24 ++-- sysdeps/unix/sysv/linux/aarch64/libc.abilist | 1 + sysdeps/unix/sysv/linux/alpha/libc.abilist | 1 + sysdeps/unix/sysv/linux/arm/be/libc.abilist | 1 + sysdeps/unix/sysv/linux/arm/le/libc.abilist | 1 + sysdeps/unix/sysv/linux/csky/libc.abilist | 1 + sysdeps/unix/sysv/linux/hppa/libc.abilist | 1 + sysdeps/unix/sysv/linux/i386/libc.abilist | 1 + sysdeps/unix/sysv/linux/ia64/libc.abilist | 1 + .../sysv/linux/m68k/coldfire/libc.abilist | 1 + .../unix/sysv/linux/m68k/m680x0/libc.abilist | 1 + .../sysv/linux/microblaze/be/libc.abilist | 1 + .../sysv/linux/microblaze/le/libc.abilist | 1 + .../sysv/linux/mips/mips32/fpu/libc.abilist | 1 + .../sysv/linux/mips/mips32/nofpu/libc.abilist | 1 + .../sysv/linux/mips/mips64/n32/libc.abilist | 1 + .../sysv/linux/mips/mips64/n64/libc.abilist | 1 + sysdeps/unix/sysv/linux/nios2/libc.abilist | 1 + .../linux/powerpc/powerpc32/fpu/libc.abilist | 1 + .../powerpc/powerpc32/nofpu/libc.abilist | 1 + .../linux/powerpc/powerpc64/be/libc.abilist | 1 + .../linux/powerpc/powerpc64/le/libc.abilist | 1 + .../unix/sysv/linux/riscv/rv64/libc.abilist | 1 + .../unix/sysv/linux/s390/s390-32/libc.abilist | 1 + .../unix/sysv/linux/s390/s390-64/libc.abilist | 1 + sysdeps/unix/sysv/linux/sh/be/libc.abilist | 1 + sysdeps/unix/sysv/linux/sh/le/libc.abilist | 1 + .../sysv/linux/sparc/sparc32/libc.abilist | 1 + .../sysv/linux/sparc/sparc64/libc.abilist | 1 + sysdeps/unix/sysv/linux/tls_internal.c | 1 + sysdeps/unix/sysv/linux/tls_internal.h | 30 +++++ .../unix/sysv/linux/x86_64/64/libc.abilist | 1 + .../unix/sysv/linux/x86_64/x32/libc.abilist | 1 + time/strftime_l.c | 10 +- 52 files changed, 367 insertions(+), 204 deletions(-) create mode 100644 string/strsignal_l.c create mode 100644 sysdeps/generic/tls_internal-struct.h create mode 100644 sysdeps/generic/tls_internal.c create mode 100644 sysdeps/generic/tls_internal.h create mode 100644 sysdeps/unix/sysv/linux/tls_internal.c create mode 100644 sysdeps/unix/sysv/linux/tls_internal.h