From patchwork Mon Sep 28 18:55:05 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 144809 X-Patchwork-Delegate: fweimer@redhat.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5DFAB4B9DB52 for ; Mon, 28 Sep 2026 18:56:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5DFAB4B9DB52 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=K4s+1230 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-vs2-x2a.google.com (mail-vs2-x2a.google.com [IPv6:2a00:1450:4864:3a::2a]) by sourceware.org (Postfix) with ESMTPS id F147D4BA903A for ; Mon, 28 Sep 2026 18:55:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F147D4BA903A 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 F147D4BA903A Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:3a::2a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621743; cv=none; b=fFZW813b1/qsAfBrvUUt9K9IYQFjdcvvyacOV+0egClKM/GM67xE2/1D3fbEorqEtSL2l4Ad2GRz9tOJ/dETW7z34fDWBfTyCNdL2oDD5gdhqg8j8jbipQvw3bRmrv/fNKY6XWf6vKHsvQKIcivOgPJCzdydUKHgv0B2XVrKBeo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621743; c=relaxed/simple; bh=ceXohGz4kigl9k7yUpyLZKLWP48u74P48j2O7LoKJHE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=irmBJKO7Erc+l23J3FamCdLRxAtgJIVKI86KeVoUEyTaiYCJ/qHcWPyE9USFcF0uOUFw5mtrFXMXF+3xvAr5hFewtI0Kyy2+UddHR2Ubgn7BTyCGGs+vmpN80zDUlftZ7rQ9jNepU+NctqLJl3MTXffdU45TDN4VopZ/CfCr1bk= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=K4s+1230 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F147D4BA903A Received: by mail-vs2-x2a.google.com with SMTP id ada2fe7eead31-7b37ccc2c4bso544900137.2 for ; Mon, 28 Sep 2026 11:55:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1790621742; x=1791226542; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YkCZ/NjQyjCxKjsvwCiOeQi1YQ8lz8q8Q5CQ4hHtAl0=; b=K4s+1230ZtgBM46P1z364GniFGInP/2/AUx6ViFk/oLlQVRLklndOhb7mEg1OfRO9E ftY2174E3w8Ct0Pv9tZwXL6nrfF0N78qXCF/w2dhlh0I0EQGUJXZEnBaSUgahxMZJJJM M5alBjWgUNJ1uo8wRXhdP1KpECzYMEYWeTt/e0xZeDhYevJcZksRL1Q8lktm6R05jgzF Z+M4j8Uwuo8Z0t5FG52SslV5ukCQ2ao9fcNtTA4Jikj6qJehiRivjEQPdYL398f/vMOr Npl0I3MSH+ZzSGZe4Q5buMhnP8Wi9Eb3tUHI90Pzwz9vUtafdWUstIvrogOc4o3GGqVT ucow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790621742; x=1791226542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=YkCZ/NjQyjCxKjsvwCiOeQi1YQ8lz8q8Q5CQ4hHtAl0=; b=FQDZ0HbEru2+NhwHFfZajcYKCQ2yp5mwI495KUUFsFVCbwjVRkzOh8gUypbaRTCaEF T2D7xLnuvkdY1M9GoIzyQdIUYZT04L1G/wK5qlXD725MHRD0xBsf2z4Gca0sAxwuotUl eVCZf5bW/dOGxdY3F0DZlvHyIE2Q+S29CJUOW1EYLmRaCCbzh7dv8mvMJbCHJw7qXeug eR3tnrNESZz0OJ9zgVLzEfQz68IkQcdZlIuKDUS2U7/lVvitkC2tQF9A6P1WOR8Kpc1a h4orQI1Qk56krmLflkV/YE2Hg/NqfuwIamlhgpf02sM6jTOdGMbSlRMEnwNw8YZFYz// kYRg== X-Gm-Message-State: AFq9FYJ8EgxKxu8FOBprHaP7mDxi1humoKL9PLh0oeKhqZ7XPei8C+pi S/LnK7nYmwF7Oa1WDQcd/jrFsrY78Uf6s0JxlMUmi5eH8YehL2D1+oA9FuUWO3IXZl0V0TMIRzw N8Q9g X-Gm-Gg: AYBFou13xdxiFPKjA5iwL1Z8he41Fc5Zr5opo1SNAbC3Aab6q2QJhjfDYvAUgRaQpUm paZVNnFiNvbkVDaNuQuWd20urfOMvWBY3WxiLDWHgCYTFDIaza6uYLGlzeNu98DbnEJLS6E9VwJ bENWfvbPoi5RRH7wXuP8V74MV+XruvqRD61nQ9DnLeCAZIZbBDq9Zo1QcIivZUlEVkqCya04Ha2 fG285obLFBbum1o5Bb0Al9/zsi69A+h+PJwt7GoFkvX+GgUv574xcOh6tsf+tdnoDvHIigQmtrA If+7be+34xnPJlfwN4nWu54a8ZkubRMxySrCuO0hGvTgklSm/VUfmi8teI4QRx6UNtT7/LYVbQq q+3xN7DSVo9kk1BvkCm1Gx1NLgHJ08GG6QmhWAVae73kmVgHUluJtV/WOV6McndwZdHDkN3q4qi vOgOHRvU+eB7Df9Q3y8L0dWdHOKIB/slSEluEQ+UCrkfUP+M22LnoNFqPQsuJpnXD2zRfujlPTW WbHCigT0VMn+7PFgDB3JIA6Y09Hhm4cWdmvYjjYPnP+B4mL7w== X-Received: by 2002:a05:6102:808e:b0:7b5:4f3e:70ac with SMTP id ada2fe7eead31-7b54f3e7e86mr1014253137.24.1790621742134; Mon, 28 Sep 2026 11:55:42 -0700 (PDT) Received: from mandiga ([2804:1b3:a7c1:43a:4422:b237:80b0:bad8]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-988b86d6058sm887554241.0.2026.09.28.11.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2026 11:55:41 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: DJ Delorie Subject: [PATCH 1/8] elf: Fix auditor iteration in _dl_audit_symbind_alt (BZ 34684) Date: Mon, 28 Sep 2026 15:55:05 -0300 Message-ID: <20260928185535.1353957-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> References: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The loop only moved to the next auditor when the current one handled the binding. If an earlier auditor did not request it, a later interested auditor had the earlier auditor's la_symbind called with its cookies instead, and never saw the dlsym binding itself. This is a regression from cda4f265c65f. Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabihf, alpha-linux-gnu, hppa-linux-gnu, loongarch64-linux-gnu, mips64el-linux-gnu, powerpc64-linux-gnu, powerpc64le-linux-gnu, riscv64-linux-gnu, s390x-linux-gnu, and sparc64-linux-gnu. --- elf/Makefile | 11 +++++++ elf/dl-audit.c | 6 ++-- elf/tst-audit-symbind-dlsym-mod.c | 19 ++++++++++++ elf/tst-audit-symbind-dlsym.c | 35 +++++++++++++++++++++ elf/tst-auditmod-symbind-dlsym-a.c | 50 ++++++++++++++++++++++++++++++ elf/tst-auditmod-symbind-dlsym-b.c | 50 ++++++++++++++++++++++++++++++ 6 files changed, 168 insertions(+), 3 deletions(-) create mode 100644 elf/tst-audit-symbind-dlsym-mod.c create mode 100644 elf/tst-audit-symbind-dlsym.c create mode 100644 elf/tst-auditmod-symbind-dlsym-a.c create mode 100644 elf/tst-auditmod-symbind-dlsym-b.c diff --git a/elf/Makefile b/elf/Makefile index 79321d6a91d..9a0cdf42e69 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -406,6 +406,7 @@ tests += \ tst-align \ tst-align2 \ tst-align3 \ + tst-audit-symbind-dlsym \ tst-audit-tlsdesc \ tst-audit-tlsdesc-dlopen \ tst-audit-tlsdesc-dlopen2 \ @@ -911,6 +912,7 @@ modules-names += \ tst-alignmod3 \ tst-array2dep \ tst-array5dep \ + tst-audit-symbind-dlsym-mod \ tst-audit-tlsdesc-mod1 \ tst-audit-tlsdesc-mod2 \ tst-audit11mod1 \ @@ -946,6 +948,8 @@ modules-names += \ tst-auditmanymod7 \ tst-auditmanymod8 \ tst-auditmanymod9 \ + tst-auditmod-symbind-dlsym-a \ + tst-auditmod-symbind-dlsym-b \ tst-auditmod-tlsdesc \ tst-auditmod-tlsdesc2 \ tst-auditmod1 \ @@ -2863,6 +2867,13 @@ $(objpfx)tst-audit28.out: $(objpfx)tst-auditmod28.so $(objpfx)tst-auditmod28.so: $(libsupport) tst-audit28-ENV = LD_AUDIT=$(objpfx)tst-auditmod28.so +$(objpfx)tst-audit-symbind-dlsym.out: \ + $(objpfx)tst-audit-symbind-dlsym-mod.so \ + $(objpfx)tst-auditmod-symbind-dlsym-a.so \ + $(objpfx)tst-auditmod-symbind-dlsym-b.so +tst-audit-symbind-dlsym-ENV = \ + LD_AUDIT=$(objpfx)tst-auditmod-symbind-dlsym-a.so:$(objpfx)tst-auditmod-symbind-dlsym-b.so + # tst-sonamemove links against an older implementation of the library. LDFLAGS-tst-sonamemove-linkmod1.so = \ -Wl,--version-script=tst-sonamemove-linkmod1.map \ diff --git a/elf/dl-audit.c b/elf/dl-audit.c index aadc8ecc797..9c79b175b84 100644 --- a/elf/dl-audit.c +++ b/elf/dl-audit.c @@ -165,12 +165,12 @@ _dl_audit_symbind_alt (struct link_map *l, const ElfW(Sym) *ref, void **value, altvalue = LA_SYMB_ALTVALUE; sym.st_value = new_value; } - - afct = afct->next; } - *value = (void *) sym.st_value; + afct = afct->next; } + + *value = (void *) sym.st_value; } rtld_hidden_def (_dl_audit_symbind_alt) diff --git a/elf/tst-audit-symbind-dlsym-mod.c b/elf/tst-audit-symbind-dlsym-mod.c new file mode 100644 index 00000000000..08a119e8f92 --- /dev/null +++ b/elf/tst-audit-symbind-dlsym-mod.c @@ -0,0 +1,19 @@ +/* Module for tst-audit-symbind-dlsym. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +const int tst_audit_symbind_dlsym_data[] = { 0, 1, 2 }; diff --git a/elf/tst-audit-symbind-dlsym.c b/elf/tst-audit-symbind-dlsym.c new file mode 100644 index 00000000000..aa7b162ae5b --- /dev/null +++ b/elf/tst-audit-symbind-dlsym.c @@ -0,0 +1,35 @@ +/* Check la_symbind dispatch for dlsym with multiple auditors. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +static int +do_test (void) +{ + void *h = xdlopen ("tst-audit-symbind-dlsym-mod.so", RTLD_NOW); + const int *p = xdlsym (h, "tst_audit_symbind_dlsym_data"); + /* 1 means only the second auditor was called; 2 means the first + one was called instead. */ + TEST_COMPARE (*p, 1); + xdlclose (h); + return 0; +} + +#include diff --git a/elf/tst-auditmod-symbind-dlsym-a.c b/elf/tst-auditmod-symbind-dlsym-a.c new file mode 100644 index 00000000000..17fb3bfbe21 --- /dev/null +++ b/elf/tst-auditmod-symbind-dlsym-a.c @@ -0,0 +1,50 @@ +/* Auditor for tst-audit-symbind-dlsym that does not request any binding. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +unsigned int +la_version (unsigned int version) +{ + return LAV_CURRENT; +} + +unsigned int +la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie) +{ + return 0; +} + +#if __ELF_NATIVE_CLASS == 64 +uintptr_t +la_symbind64 (Elf64_Sym *sym, unsigned int ndx, + uintptr_t *refcook, uintptr_t *defcook, + unsigned int *flags, const char *symname) +#else +uintptr_t +la_symbind32 (Elf32_Sym *sym, unsigned int ndx, + uintptr_t *refcook, uintptr_t *defcook, + unsigned int *flags, const char *symname) +#endif +{ + if ((*flags & LA_SYMB_DLSYM) != 0 + && strcmp (symname, "tst_audit_symbind_dlsym_data") == 0) + return sym->st_value + 2 * sizeof (int); + return sym->st_value; +} diff --git a/elf/tst-auditmod-symbind-dlsym-b.c b/elf/tst-auditmod-symbind-dlsym-b.c new file mode 100644 index 00000000000..196ef5811d7 --- /dev/null +++ b/elf/tst-auditmod-symbind-dlsym-b.c @@ -0,0 +1,50 @@ +/* Auditor for tst-audit-symbind-dlsym that requests all bindings. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +unsigned int +la_version (unsigned int version) +{ + return LAV_CURRENT; +} + +unsigned int +la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie) +{ + return LA_FLG_BINDFROM | LA_FLG_BINDTO; +} + +#if __ELF_NATIVE_CLASS == 64 +uintptr_t +la_symbind64 (Elf64_Sym *sym, unsigned int ndx, + uintptr_t *refcook, uintptr_t *defcook, + unsigned int *flags, const char *symname) +#else +uintptr_t +la_symbind32 (Elf32_Sym *sym, unsigned int ndx, + uintptr_t *refcook, uintptr_t *defcook, + unsigned int *flags, const char *symname) +#endif +{ + if ((*flags & LA_SYMB_DLSYM) != 0 + && strcmp (symname, "tst_audit_symbind_dlsym_data") == 0) + return sym->st_value + 1 * sizeof (int); + return sym->st_value; +} From patchwork Mon Sep 28 18:55:06 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 144808 X-Patchwork-Delegate: fweimer@redhat.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8F9C94BAE7DC for ; Mon, 28 Sep 2026 18:56:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F9C94BAE7DC Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=aMRJN9hr X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ua2-x0f.google.com (mail-ua2-x0f.google.com [IPv6:2a00:1450:4864:39::f]) by sourceware.org (Postfix) with ESMTPS id 8F4094B9DB52 for ; Mon, 28 Sep 2026 18:55:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8F4094B9DB52 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 8F4094B9DB52 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:39::f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621745; cv=none; b=IMoYy0yiQ6HO1f+HWxkiiVRRZmGKmuAWoKzpAzjg1n1q/dDwJ0Jq+NyYQHhDGy+nyBGjW0iiSbyGAmM5Td9zYcsPtk9Mn3S8eE6oHB9wjEjph7tQi1X8wlmSxD3reIYM2ynzIYMdMq2a4aJAGCTjLcn+2YiQCA+MB3Uc+dU0vQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621745; c=relaxed/simple; bh=7OmogE2TH4Yi3+bwMS2/aHyl3ENM5pwKZPxZgZSS5f0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=KVBcEfunSOHyywSiL3TK5u5XW8BcM9FM1l8SaL1sRNoc8x3uMESdDr/HUC1qncYXqC68gukyk8U5s8OzlUwttgmcHxrQFYQYqLGF4yvS0QP6EL2dNt5mC05k7WOZgsSTb9PuTWrodqf48epzwCNnhaUAAfzD42IlkL4jfZc4Iuk= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=aMRJN9hr DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F4094B9DB52 Received: by mail-ua2-x0f.google.com with SMTP id a1e0cc1a2514c-988bb9d0548so27501241.2 for ; Mon, 28 Sep 2026 11:55:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1790621745; x=1791226545; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=1JXWd5JSiXUe1ISiKiwGZ2uLiQPTOGBZW7zg06gA1xs=; b=aMRJN9hrzWe4V3D69Z1s4UJBr+Ntg/S1hpH7TzuqRN0SCos30N0zqH+gtvVbXXNrMa 83iDTEJESxQYYerHMlLFWdmL3dOTDdvH0T2woN8VCfkX2nOyGep2NpPiXuITmy8u0t5y 7lP9q16bxHzqBjsuH5SstJ3qLtOkImm5GOLbYvzOh2u0wZ5HL3rWZOIehOLwu2KajFYQ nUUZiHA5sOszzv5rRrkSY9s3mmeAPCaO/6Ctgw7VtGqpxNs2VaSzAzc3dchiJNS6mJI7 NqaC1Kc5aUwYymB/Z66kByQ/DvMFh3fA4foO7riHdEGlyhG/Po4GzJYRrvwmMzHFSQk5 frMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790621745; x=1791226545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=1JXWd5JSiXUe1ISiKiwGZ2uLiQPTOGBZW7zg06gA1xs=; b=ctruIKMxyI87Es+2Q0vIoRvCIKNKYP2AXM1bubIldCkeGLCc7tr3ZzW0KHPNPCbwRZ Guk3wmBTOK0+UOVlRPZaLvFIpYpyxsim6xo70Cd6rYfivvRT3Gq7fCEjKO96InFg2DBm i3YBKXK+/9F0BcKGYjfBvIdElocY6em7K/xk0Gy8fqbtoxeejqhx6u+Ox61MxwLBXGEw mVicc4/uCdXAEqkoSR5HbthyLb1UWRc0AkT5swy3K73czbw3Gg+GvmHoEkejlrTgsyC4 AORUDqeDdH80BIvc8ZH/e6Ej7wvvGsZDMQk7ZeeFJ14QFvo0m1l/l17jXXvEIS9cuPOQ Imxg== X-Gm-Message-State: AFq9FYJ2sjNRDn1HqHu6Ibf45MlZep+Oa2H8lcefyPSHaudxE9jnuN29 0ymcFRbOrsggKjpzWmo5tL8znXtnlEP/sHQycln066kRgv7aDoWYOcVBtVbQtyPl0XbN2c7PPnl n+1pu X-Gm-Gg: AYBFou25APGXPLMYe+yasU2CzehbgOLmfNVS/mPrtOPnc75X4HpnZ8b+Cf8edFHYwsi qvqyNksXcyYf1qae7s00pnycAMyvc90NI7HivF27HpT+qSV7Un4pMcjnApyEckF1Fz96NVjRsDQ HUL3/kZhHSqd4mvAmhP0yAR2X3Ku32GSl9kbU0gEY/sRAzxshj2gkIja0njgaGXPqqbjiowYKdx YXi4IsdbtJzPvZGpuNUtf5wrf5+DroIvqG+vlOpOunbu2ZjxY0DpslR54cBikO5SZmzRHjQqVD6 zYhGIR8kjkTH+hIxb92LeP8Q7n28GLJxIfHQLYotap/pRACGYCJDntfNVGR1xgshhlb09Y1CZG6 uayQdlDitPRbph28QLQRWyUh74gtl3sGqo2t+2t0fKs73vt9TWGOuK/g+RKxJW5269M6NAix3Nf 53KP0cqdVvAMaAqFsvBbXP3F1up3m+O3+1AtHWkBYvJVwgN3TZJjvLzB9PVGg2dBE+DEpcmKpjE rExhdTCbaZ3y9x0EXxGTUPRXj2cFNQruSZ11IgcTPNGblB8eQ== X-Received: by 2002:a05:6102:14a3:b0:7b3:78ea:88fc with SMTP id ada2fe7eead31-7b378ea8a80mr1659231137.35.1790621744600; Mon, 28 Sep 2026 11:55:44 -0700 (PDT) Received: from mandiga ([2804:1b3:a7c1:43a:4422:b237:80b0:bad8]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-988b86d6058sm887554241.0.2026.09.28.11.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2026 11:55:43 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: DJ Delorie Subject: [PATCH 2/8] elf: Keep la_symbind and la_pltenter flags per auditor (BZ 34687) Date: Mon, 28 Sep 2026 15:55:06 -0300 Message-ID: <20260928185535.1353957-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> References: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> 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, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Both _dl_audit_symbind and _dl_audit_pltenter used a single flags variable for all auditors, so LA_SYMB_NOPLTENTER and LA_SYMB_NOPLTEXIT set by one auditor were passed to the next ones and recorded as their own choice, suppressing their la_pltenter and la_pltexit calls. Each auditor now starts with its own flags, and only LA_SYMB_ALTVALUE is carried over (which is also the only bit now kept in reloc_result->flags). The new test is XFAIL on mips, where la_symbind is not called for PLT bindings (BZ 29404). Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabihf, alpha-linux-gnu, hppa-linux-gnu, loongarch64-linux-gnu, mips64el-linux-gnu, powerpc64-linux-gnu, powerpc64le-linux-gnu, riscv64-linux-gnu, s390x-linux-gnu, and sparc64-linux-gnu. --- elf/Makefile | 10 +++ elf/dl-audit.c | 23 +++-- elf/tst-audit-symbind-flags-mod.c | 29 ++++++ elf/tst-audit-symbind-flags.c | 137 +++++++++++++++++++++++++++++ elf/tst-auditmod-symbind-flags-a.c | 64 ++++++++++++++ elf/tst-auditmod-symbind-flags-b.c | 64 ++++++++++++++ sysdeps/mips/Makefile | 1 + 7 files changed, 320 insertions(+), 8 deletions(-) create mode 100644 elf/tst-audit-symbind-flags-mod.c create mode 100644 elf/tst-audit-symbind-flags.c create mode 100644 elf/tst-auditmod-symbind-flags-a.c create mode 100644 elf/tst-auditmod-symbind-flags-b.c diff --git a/elf/Makefile b/elf/Makefile index 9a0cdf42e69..e3419cd1185 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -407,6 +407,7 @@ tests += \ tst-align2 \ tst-align3 \ tst-audit-symbind-dlsym \ + tst-audit-symbind-flags \ tst-audit-tlsdesc \ tst-audit-tlsdesc-dlopen \ tst-audit-tlsdesc-dlopen2 \ @@ -913,6 +914,7 @@ modules-names += \ tst-array2dep \ tst-array5dep \ tst-audit-symbind-dlsym-mod \ + tst-audit-symbind-flags-mod \ tst-audit-tlsdesc-mod1 \ tst-audit-tlsdesc-mod2 \ tst-audit11mod1 \ @@ -950,6 +952,8 @@ modules-names += \ tst-auditmanymod9 \ tst-auditmod-symbind-dlsym-a \ tst-auditmod-symbind-dlsym-b \ + tst-auditmod-symbind-flags-a \ + tst-auditmod-symbind-flags-b \ tst-auditmod-tlsdesc \ tst-auditmod-tlsdesc2 \ tst-auditmod1 \ @@ -2874,6 +2878,12 @@ $(objpfx)tst-audit-symbind-dlsym.out: \ tst-audit-symbind-dlsym-ENV = \ LD_AUDIT=$(objpfx)tst-auditmod-symbind-dlsym-a.so:$(objpfx)tst-auditmod-symbind-dlsym-b.so +$(objpfx)tst-audit-symbind-flags: $(objpfx)tst-audit-symbind-flags-mod.so +$(objpfx)tst-audit-symbind-flags.out: \ + $(objpfx)tst-auditmod-symbind-flags-a.so \ + $(objpfx)tst-auditmod-symbind-flags-b.so +LDFLAGS-tst-audit-symbind-flags = -Wl,-z,lazy + # tst-sonamemove links against an older implementation of the library. LDFLAGS-tst-sonamemove-linkmod1.so = \ -Wl,--version-script=tst-sonamemove-linkmod1.map \ diff --git a/elf/dl-audit.c b/elf/dl-audit.c index 9c79b175b84..cd2fa44cf14 100644 --- a/elf/dl-audit.c +++ b/elf/dl-audit.c @@ -211,7 +211,7 @@ _dl_audit_symbind (struct link_map *l, struct reloc_result *reloc_result, const char *strtab2 = (const void *) D_PTR (result, l_info[DT_STRTAB]); - unsigned int flags = 0; + unsigned int altvalue = 0; struct audit_ifaces *afct = GLRO(dl_audit); uintptr_t new_value = (uintptr_t) sym.st_value; for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt) @@ -222,17 +222,19 @@ _dl_audit_symbind (struct link_map *l, struct reloc_result *reloc_result, if ((l_state->bindflags & LA_FLG_BINDFROM) != 0 && (result_state->bindflags & LA_FLG_BINDTO) != 0) { + /* Only LA_SYMB_ALTVALUE is carried over from previous auditors. */ + unsigned int flags = altvalue; + if (for_jmp_slot) + flags |= LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT; if (afct->symbind != NULL) { - flags |= for_jmp_slot ? LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT - : 0; new_value = afct->symbind (&sym, boundndx, &l_state->cookie, &result_state->cookie, &flags, strtab2 + defsym->st_name); if (new_value != (uintptr_t) sym.st_value) { - flags |= LA_SYMB_ALTVALUE; + altvalue = LA_SYMB_ALTVALUE; sym.st_value = for_jmp_slot ? DL_FIXUP_BINDNOW_ADDR_VALUE (new_value) : new_value; } @@ -255,10 +257,10 @@ _dl_audit_symbind (struct link_map *l, struct reloc_result *reloc_result, if (!for_jmp_slot) { reloc_result->enterexit = enterexit; - reloc_result->flags = flags; + reloc_result->flags = altvalue; } - if (flags & LA_SYMB_ALTVALUE) + if (altvalue != 0) DL_FIXUP_BINDNOW_RELOC (l, reloc, value, new_value, sym.st_value, lazy); } @@ -288,7 +290,7 @@ _dl_audit_pltenter (struct link_map *l, struct reloc_result *reloc_result, const char *symname = strtab + sym.st_name; /* Keep track of overwritten addresses. */ - unsigned int flags = reloc_result->flags; + unsigned int altvalue = reloc_result->flags; struct audit_ifaces *afct = GLRO(dl_audit); for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt) @@ -301,13 +303,18 @@ _dl_audit_pltenter (struct link_map *l, struct reloc_result *reloc_result, struct auditstate *l_state = link_map_audit_state (l, cnt); struct auditstate *bound_state = link_map_audit_state (reloc_result->bound, cnt); + /* Each auditor only sees its own LA_SYMB_NOPLTENTER and + LA_SYMB_NOPLTEXIT. */ + unsigned int flags = altvalue + | ((reloc_result->enterexit >> (2 * (cnt + 1))) + & (LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT)); uintptr_t new_value = afct->ARCH_LA_PLTENTER (&sym, reloc_result->boundndx, &l_state->cookie, &bound_state->cookie, regs, &flags, symname, &new_framesize); if (new_value != (uintptr_t) sym.st_value) { - flags |= LA_SYMB_ALTVALUE; + altvalue = LA_SYMB_ALTVALUE; sym.st_value = new_value; } diff --git a/elf/tst-audit-symbind-flags-mod.c b/elf/tst-audit-symbind-flags-mod.c new file mode 100644 index 00000000000..34b4396e3dd --- /dev/null +++ b/elf/tst-audit-symbind-flags-mod.c @@ -0,0 +1,29 @@ +/* Module for tst-audit-symbind-flags. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +int +tst_audit_symbind_flags_func1 (void) +{ + return 1; +} + +int +tst_audit_symbind_flags_func2 (void) +{ + return 2; +} diff --git a/elf/tst-audit-symbind-flags.c b/elf/tst-audit-symbind-flags.c new file mode 100644 index 00000000000..daaf81acc8e --- /dev/null +++ b/elf/tst-audit-symbind-flags.c @@ -0,0 +1,137 @@ +/* Check that la_symbind and la_pltenter flags are per auditor. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int restart; +#define CMDLINE_OPTIONS \ + { "restart", no_argument, &restart, 1 }, + +int tst_audit_symbind_flags_func1 (void); +int tst_audit_symbind_flags_func2 (void); + +static int +handle_restart (void) +{ + /* Call each function twice so la_pltenter is also exercised after + the lazy binding. */ + TEST_COMPARE (tst_audit_symbind_flags_func1 (), 1); + TEST_COMPARE (tst_audit_symbind_flags_func1 (), 1); + TEST_COMPARE (tst_audit_symbind_flags_func2 (), 2); + TEST_COMPARE (tst_audit_symbind_flags_func2 (), 2); + return 0; +} + +static int +count_lines (const char *buf, const char *line) +{ + size_t len = strlen (line); + int n = 0; + for (const char *p = buf; p != NULL && *p != '\0'; ) + { + if (strncmp (p, line, len) == 0 && p[len] == '\n') + n++; + p = strchr (p, '\n'); + if (p != NULL) + p++; + } + return n; +} + +static void +run (char *program, bool bindnow) +{ + if (bindnow) + setenv ("LD_BIND_NOW", "1", 1); + else + unsetenv ("LD_BIND_NOW"); + + char *args[] = { program, (char *) "--direct", (char *) "--restart", NULL }; + struct support_spawn_wrapped *w + = support_spawn_wrap (program, args, NULL, 0); + struct support_capture_subprocess result + = support_capture_subprogram (w->path, w->argv, w->envp); + support_spawn_wrapped_free (w); + support_capture_subprocess_check (&result, "tst-audit-symbind-flags", 0, + sc_allow_stderr); + const char *err = result.err.buffer; + + /* tst-auditmod-symbind-flags-a.so sets LA_SYMB_NOPLTENTER and + LA_SYMB_NOPLTEXIT for func1 in la_symbind, which must not be seen by + tst-auditmod-symbind-flags-b.so. ld.so sets both for bind-now. */ + const char *expected1 = bindnow + ? "b: la_symbind: tst_audit_symbind_flags_func1 3" + : "b: la_symbind: tst_audit_symbind_flags_func1 0"; + const char *expected2 = bindnow + ? "b: la_symbind: tst_audit_symbind_flags_func2 3" + : "b: la_symbind: tst_audit_symbind_flags_func2 0"; + TEST_COMPARE (count_lines (err, expected1), 1); + TEST_COMPARE (count_lines (err, expected2), 1); + + /* Not all architectures support la_pltenter. If they do, the first auditor + sets LA_SYMB_NOPLTENTER for func2 in its first la_pltenter, which must + not stop the calls for the second auditor. */ + if (count_lines (err, "a: la_pltenter: tst_audit_symbind_flags_func2") > 0) + { + TEST_VERIFY (!bindnow); + TEST_COMPARE (count_lines (err, + "a: la_pltenter: tst_audit_symbind_flags_func2"), 1); + TEST_COMPARE (count_lines (err, + "b: la_pltenter: tst_audit_symbind_flags_func1"), 2); + TEST_COMPARE (count_lines (err, + "b: la_pltenter: tst_audit_symbind_flags_func2"), 2); + } + else if (!bindnow) + puts ("info: la_pltenter not called, skipping its checks"); + + if (support_record_failure_is_failed ()) + printf ("info: auditor output (LD_BIND_NOW=%d):\n%s", bindnow, err); + + support_capture_subprocess_free (&result); +} + +static int +do_test (void) +{ + if (restart) + return handle_restart (); + + char *audit = xasprintf ("%s/elf/tst-auditmod-symbind-flags-a.so" + ":%s/elf/tst-auditmod-symbind-flags-b.so", + support_objdir_root, support_objdir_root); + setenv ("LD_AUDIT", audit, 1); + free (audit); + + char *program = xasprintf ("%s/elf/tst-audit-symbind-flags", + support_objdir_root); + run (program, false); + run (program, true); + free (program); + + return 0; +} + +#include diff --git a/elf/tst-auditmod-symbind-flags-a.c b/elf/tst-auditmod-symbind-flags-a.c new file mode 100644 index 00000000000..c4f9a975707 --- /dev/null +++ b/elf/tst-auditmod-symbind-flags-a.c @@ -0,0 +1,64 @@ +/* Auditor for tst-audit-symbind-flags that opts out of PLT tracing. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +unsigned int +la_version (unsigned int version) +{ + return LAV_CURRENT; +} + +unsigned int +la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie) +{ + return LA_FLG_BINDFROM | LA_FLG_BINDTO; +} + +#if __ELF_NATIVE_CLASS == 64 +uintptr_t +la_symbind64 (Elf64_Sym *sym, unsigned int ndx, + uintptr_t *refcook, uintptr_t *defcook, + unsigned int *flags, const char *symname) +#else +uintptr_t +la_symbind32 (Elf32_Sym *sym, unsigned int ndx, + uintptr_t *refcook, uintptr_t *defcook, + unsigned int *flags, const char *symname) +#endif +{ + if (strcmp (symname, "tst_audit_symbind_flags_func1") == 0) + *flags |= LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT; + return sym->st_value; +} + +ElfW(Addr) +pltenter (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook, + uintptr_t *defcook, La_regs *regs, unsigned int *flags, + const char *symname, long int *framesizep) +{ + if (strcmp (symname, "tst_audit_symbind_flags_func2") == 0) + { + fprintf (stderr, "a: la_pltenter: %s\n", symname); + *flags |= LA_SYMB_NOPLTENTER; + } + return sym->st_value; +} diff --git a/elf/tst-auditmod-symbind-flags-b.c b/elf/tst-auditmod-symbind-flags-b.c new file mode 100644 index 00000000000..718449b82b5 --- /dev/null +++ b/elf/tst-auditmod-symbind-flags-b.c @@ -0,0 +1,64 @@ +/* Auditor for tst-audit-symbind-flags that logs the flags it gets. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#define PREFIX "tst_audit_symbind_flags_func" + +unsigned int +la_version (unsigned int version) +{ + return LAV_CURRENT; +} + +unsigned int +la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie) +{ + return LA_FLG_BINDFROM | LA_FLG_BINDTO; +} + +#if __ELF_NATIVE_CLASS == 64 +uintptr_t +la_symbind64 (Elf64_Sym *sym, unsigned int ndx, + uintptr_t *refcook, uintptr_t *defcook, + unsigned int *flags, const char *symname) +#else +uintptr_t +la_symbind32 (Elf32_Sym *sym, unsigned int ndx, + uintptr_t *refcook, uintptr_t *defcook, + unsigned int *flags, const char *symname) +#endif +{ + if (strncmp (symname, PREFIX, strlen (PREFIX)) == 0) + fprintf (stderr, "b: la_symbind: %s %u\n", symname, + *flags & (LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT)); + return sym->st_value; +} + +ElfW(Addr) +pltenter (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook, + uintptr_t *defcook, La_regs *regs, unsigned int *flags, + const char *symname, long int *framesizep) +{ + if (strncmp (symname, PREFIX, strlen (PREFIX)) == 0) + fprintf (stderr, "b: la_pltenter: %s\n", symname); + return sym->st_value; +} diff --git a/sysdeps/mips/Makefile b/sysdeps/mips/Makefile index c86bd3af33c..a497c7087b5 100644 --- a/sysdeps/mips/Makefile +++ b/sysdeps/mips/Makefile @@ -35,6 +35,7 @@ test-xfail-tst-audit24c = yes test-xfail-tst-audit24d = yes test-xfail-tst-audit25a = yes test-xfail-tst-audit25b = yes +test-xfail-tst-audit-symbind-flags = yes ifneq ($(o32-fpabi),) tests += tst-abi-interlink From patchwork Mon Sep 28 18:55:07 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 144812 X-Patchwork-Delegate: fweimer@redhat.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7630A4B9DB73 for ; Mon, 28 Sep 2026 18:58:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7630A4B9DB73 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=EZW4Y/F3 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-vs2-x0c.google.com (mail-vs2-x0c.google.com [IPv6:2a00:1450:4864:3a::c]) by sourceware.org (Postfix) with ESMTPS id 868004BAE7CE for ; Mon, 28 Sep 2026 18:55:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 868004BAE7CE 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 868004BAE7CE Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:3a::c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621747; cv=none; b=BCV5y6J+HrKBf63qy7+jgp/8LIdMYkWOrHbUwW2+WvzUn+zQyvfa3pixU8E3Qmtg+NM/Lnk4E3/59nOb3sajfMbGtNin1bZUOtc+oEKkrUWGMAO04ZilvZoz2lnJLySyks4pdL1RDSZ0xQxVi4+ElmSM0+vAqTwKu2u1NJgjhV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621747; c=relaxed/simple; bh=jf7NhDzdUCcO4GdUMpuF9eVKJhCHhEjjeVDI9hktf9U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=uy21llurqn1nbU8efE9gejmaSfiC3+oS/SDgHzyCdmjbYfzDr1KkpVK+JIsIITiLEh2SJMcoi20Kht1jrRUlpljhajS3GqW/y3Y8F29O3fE+bLYDm9ZRrAq/IqskRPrj4DxixF8FmYGx0sG8L9/DFPzwowmejS6su7xq4hj4nTA= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=EZW4Y/F3 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 868004BAE7CE Received: by mail-vs2-x0c.google.com with SMTP id ada2fe7eead31-7a4fb331cc0so870018137.3 for ; Mon, 28 Sep 2026 11:55:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1790621747; x=1791226547; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=m5kp0zEFRmhLPKF44VpFyUH82CiScZuHW62JAKKuvrI=; b=EZW4Y/F3AYhjcV+bpUUwLtgMf7el6RbPQxuQNiKtY3JALBb7czmWHKvPRZLr94lvLm 7TuS7GWFAnyt7C999zNrop3I1o0e1b7XXKfoBUePwsp5M5KHm+RHB8xgjLmb/N/iHy3n 0IqS+omRVwFvvfxF3UdlA26U1i+N8e3y+9UiYyhRLZrYBDI7UQ0LrVYl5RipnNwd89j8 ayDc976lHWH9hZfD4EccdYASxgP94SiSxcnX4pVuAf9WkMsYhTfUO0XMecagQ3k/F5HW NXP6Bfw+Fe/k1jzFqi0T2hYREGMmADRVcgbR9Cr5WgMAHWQ+xNnjxOiQ/OtPkoIcbvZo Lyrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790621747; x=1791226547; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=m5kp0zEFRmhLPKF44VpFyUH82CiScZuHW62JAKKuvrI=; b=ExyFMU7CKsk61FXTLxfI/suI1v5bKtoxw1BTsWvePk9u97Ck2PjajPpHecidYeDzb3 5QRAmKbP2Ae51YVqENDZ9yTi5mJPM75Fgmk0Ib3UxKzh3getwVbNGCujfEdyiizgabrY 2LFX5IC5WiH/JUAl4jOwYqaHteI+WmUSsm/l6VnGqJ3sXyh4Rt5/nPBAXxmKtPOJcxNP bm4KjRyXTtJuVyuR80g8a38bmYRrHNhcdPcroGO+GqGYqpHO2QzQroU+10Kxeq2Pp+Pq I7BSU5hMtI585HzF9nbuF4pYJMIe6DbFLC6sUzsD3KsXfj3gWQKEoO/GkljaXWbQSadT Mrvg== X-Gm-Message-State: AFq9FYKdWd7d8fh7aFd3XPFrjYxnKCNw9R6PIdZj5GLkqG/hjU601d4u HSVxDTcB/gBpsvaZz5SKKnPyu5sej+TmRS0EAJXq8Z1BgvYpKCpDZcMo7IjNmjl06xLgGbND7Go 3Vs47 X-Gm-Gg: AYBFou1cPT1+2yeBNGKpD8vtKuZJdm63wUzKxQk8ZIjS9/S4dMhh57cba+VP1UlD0QU T3oUKOFpuPaFShkf1wZDkJ5lav1d46wqWw9EmV3sgLsT6fwC9DGuJ8uXawli2EEiJIhEzLgsBzO wbz2I1IyXIOtCvPmF7DEsKBQM7+9nzfAY6Hzid/sHZ1mWF+FIv4PcB+oeAoaEeXHsmfOnQAwfmS 4BZh918Ubah3frfgOIeoJOXH7TcjKHgVkh3s2bM0+R44pOvgVtMC12WOEWoqLfiWh+9OYQwG2aw D6jFYck/r4Xw7k0jrQWWPk1ZBu5KhEP4Xk+Ln2tAPSQf9oEcTd36bGXbRtNpESbfWdhuxPwemSx SIMHtDfImfjt6vnI0r5LV/kmJRdTXWHzNo4i4zy1aK/qkGDH/j+9xGbzxknZSQTAEJXoMli5jZ8 IdDhLrM/hPu+GVpCSgSNp6pXUlro/dbuXFKLAuFW01y7cLQwo7sf13ojsd1+Yhnij1+wI4xdNQO OBOksTE2OXa7oKRoXScHm1ZlRcSp/yPGr61Xx+rAEloWfqkcg== X-Received: by 2002:a05:6102:8648:20b0:7b5:1ca4:9df3 with SMTP id ada2fe7eead31-7b51ca4ab66mr798810137.1.1790621746571; Mon, 28 Sep 2026 11:55:46 -0700 (PDT) Received: from mandiga ([2804:1b3:a7c1:43a:4422:b237:80b0:bad8]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-988b86d6058sm887554241.0.2026.09.28.11.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2026 11:55:46 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: DJ Delorie Subject: [PATCH 3/8] elf: Honor LA_SYMB_NOPLTENTER/NOPLTEXIT per auditor (BZ 34688) Date: Mon, 28 Sep 2026 15:55:07 -0300 Message-ID: <20260928185535.1353957-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> References: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org With more than one auditor, the LA_SYMB_NOPLTENTER and LA_SYMB_NOPLTEXIT an auditor sets in la_symbind were not honored: - _dl_audit_symbind updated the summary bits with 'enterexit &= flags & 3', which also cleared the per-auditor bits of the previous auditors. So only the choice of the last one was kept. - _dl_audit_pltexit checked 'LA_SYMB_NOPLTEXIT >> (2 * cnt)', which is the summary bit for the first auditor and zero for the others, instead of the auditor's own bit. Both date back to the original audit implementation. The new test is UNSUPPORTED if la_pltexit is never called (as on mips and hppa), and XFAIL on alpha, loongarch, riscv, and aarch64 with BTI, where the la_pltexit path of _dl_runtime_profile crashes. Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabihf, alpha-linux-gnu, hppa-linux-gnu, loongarch64-linux-gnu, mips64el-linux-gnu, powerpc64-linux-gnu, powerpc64le-linux-gnu, riscv64-linux-gnu, s390x-linux-gnu, and sparc64-linux-gnu. --- elf/Makefile | 10 +++ elf/dl-audit.c | 11 +-- elf/tst-audit-plt-flags-mod.c | 35 ++++++++++ elf/tst-audit-plt-flags.c | 124 +++++++++++++++++++++++++++++++++ elf/tst-auditmod-plt-flags-a.c | 85 ++++++++++++++++++++++ elf/tst-auditmod-plt-flags-b.c | 22 ++++++ sysdeps/aarch64/Makefile | 4 ++ sysdeps/alpha/Makefile | 4 ++ sysdeps/loongarch/Makefile | 2 + sysdeps/riscv/Makefile | 2 + 10 files changed, 294 insertions(+), 5 deletions(-) create mode 100644 elf/tst-audit-plt-flags-mod.c create mode 100644 elf/tst-audit-plt-flags.c create mode 100644 elf/tst-auditmod-plt-flags-a.c create mode 100644 elf/tst-auditmod-plt-flags-b.c diff --git a/elf/Makefile b/elf/Makefile index e3419cd1185..e3dbe83cc21 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -406,6 +406,7 @@ tests += \ tst-align \ tst-align2 \ tst-align3 \ + tst-audit-plt-flags \ tst-audit-symbind-dlsym \ tst-audit-symbind-flags \ tst-audit-tlsdesc \ @@ -913,6 +914,7 @@ modules-names += \ tst-alignmod3 \ tst-array2dep \ tst-array5dep \ + tst-audit-plt-flags-mod \ tst-audit-symbind-dlsym-mod \ tst-audit-symbind-flags-mod \ tst-audit-tlsdesc-mod1 \ @@ -950,6 +952,8 @@ modules-names += \ tst-auditmanymod7 \ tst-auditmanymod8 \ tst-auditmanymod9 \ + tst-auditmod-plt-flags-a \ + tst-auditmod-plt-flags-b \ tst-auditmod-symbind-dlsym-a \ tst-auditmod-symbind-dlsym-b \ tst-auditmod-symbind-flags-a \ @@ -2884,6 +2888,12 @@ $(objpfx)tst-audit-symbind-flags.out: \ $(objpfx)tst-auditmod-symbind-flags-b.so LDFLAGS-tst-audit-symbind-flags = -Wl,-z,lazy +$(objpfx)tst-audit-plt-flags: $(objpfx)tst-audit-plt-flags-mod.so +$(objpfx)tst-audit-plt-flags.out: \ + $(objpfx)tst-auditmod-plt-flags-a.so \ + $(objpfx)tst-auditmod-plt-flags-b.so +LDFLAGS-tst-audit-plt-flags = -Wl,-z,lazy + # tst-sonamemove links against an older implementation of the library. LDFLAGS-tst-sonamemove-linkmod1.so = \ -Wl,--version-script=tst-sonamemove-linkmod1.map \ diff --git a/elf/dl-audit.c b/elf/dl-audit.c index cd2fa44cf14..a64f978cfb4 100644 --- a/elf/dl-audit.c +++ b/elf/dl-audit.c @@ -241,10 +241,11 @@ _dl_audit_symbind (struct link_map *l, struct reloc_result *reloc_result, } /* Remember the results for every audit library and store a summary - in the first two bits. */ - enterexit &= flags & (LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT); - enterexit |= ((flags & (LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT)) - << ((cnt + 1) * 2)); + in the first two bits, without clearing the bits of the previous + auditors. */ + unsigned int noplt = flags & (LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT); + enterexit &= noplt | ~(LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT); + enterexit |= noplt << ((cnt + 1) * 2); } else /* If the bind flags say this auditor is not interested, set the bits @@ -375,7 +376,7 @@ _dl_audit_pltexit (struct link_map *l, ElfW(Word) reloc_arg, { if (afct->ARCH_LA_PLTEXIT != NULL && (reloc_result->enterexit - & (LA_SYMB_NOPLTEXIT >> (2 * cnt))) == 0) + & (LA_SYMB_NOPLTEXIT << (2 * (cnt + 1)))) == 0) { struct auditstate *l_state = link_map_audit_state (l, cnt); struct auditstate *bound_state diff --git a/elf/tst-audit-plt-flags-mod.c b/elf/tst-audit-plt-flags-mod.c new file mode 100644 index 00000000000..c661440c994 --- /dev/null +++ b/elf/tst-audit-plt-flags-mod.c @@ -0,0 +1,35 @@ +/* Module for tst-audit-plt-flags. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +int +tst_audit_plt_flags_func1 (void) +{ + return 1; +} + +int +tst_audit_plt_flags_func2 (void) +{ + return 2; +} + +int +tst_audit_plt_flags_func3 (void) +{ + return 3; +} diff --git a/elf/tst-audit-plt-flags.c b/elf/tst-audit-plt-flags.c new file mode 100644 index 00000000000..c4562e2d74e --- /dev/null +++ b/elf/tst-audit-plt-flags.c @@ -0,0 +1,124 @@ +/* Check that LA_SYMB_NOPLTENTER and LA_SYMB_NOPLTEXIT are honored per auditor. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int restart; +#define CMDLINE_OPTIONS \ + { "restart", no_argument, &restart, 1 }, + +int tst_audit_plt_flags_func1 (void); +int tst_audit_plt_flags_func2 (void); +int tst_audit_plt_flags_func3 (void); + +static int +handle_restart (void) +{ + TEST_COMPARE (tst_audit_plt_flags_func1 (), 1); + TEST_COMPARE (tst_audit_plt_flags_func2 (), 2); + TEST_COMPARE (tst_audit_plt_flags_func3 (), 3); + return 0; +} + +static int +count_lines (const char *buf, const char *line) +{ + size_t len = strlen (line); + int n = 0; + for (const char *p = buf; p != NULL && *p != '\0'; ) + { + if (strncmp (p, line, len) == 0 && p[len] == '\n') + n++; + p = strchr (p, '\n'); + if (p != NULL) + p++; + } + return n; +} + +static int +do_test (void) +{ + if (restart) + return handle_restart (); + + char *audit = xasprintf ("%s/elf/tst-auditmod-plt-flags-a.so" + ":%s/elf/tst-auditmod-plt-flags-b.so", + support_objdir_root, support_objdir_root); + setenv ("LD_AUDIT", audit, 1); + free (audit); + + char *program = xasprintf ("%s/elf/tst-audit-plt-flags", + support_objdir_root); + char *args[] = { program, (char *) "--direct", (char *) "--restart", NULL }; + struct support_spawn_wrapped *w + = support_spawn_wrap (program, args, NULL, 0); + struct support_capture_subprocess result + = support_capture_subprogram (w->path, w->argv, w->envp); + support_spawn_wrapped_free (w); + free (program); + support_capture_subprocess_check (&result, "tst-audit-plt-flags", 0, + sc_allow_stderr); + const char *err = result.err.buffer; + + if (strstr (err, ": la_pltexit: ") == NULL) + FAIL_UNSUPPORTED ("la_pltexit not supported"); + + /* Both auditors request la_pltexit in la_pltenter. The first one + sets LA_SYMB_NOPLTEXIT for func1 and LA_SYMB_NOPLTENTER for func3, + the second one sets LA_SYMB_NOPLTEXIT for func2. */ + static const struct + { + const char *line; + int count; + } expected[] = + { + { "a: la_pltenter: tst_audit_plt_flags_func1", 1 }, + { "a: la_pltexit: tst_audit_plt_flags_func1", 0 }, + { "b: la_pltenter: tst_audit_plt_flags_func1", 1 }, + { "b: la_pltexit: tst_audit_plt_flags_func1", 1 }, + { "a: la_pltenter: tst_audit_plt_flags_func2", 1 }, + { "a: la_pltexit: tst_audit_plt_flags_func2", 1 }, + { "b: la_pltenter: tst_audit_plt_flags_func2", 1 }, + { "b: la_pltexit: tst_audit_plt_flags_func2", 0 }, + { "a: la_pltenter: tst_audit_plt_flags_func3", 0 }, + { "a: la_pltexit: tst_audit_plt_flags_func3", 1 }, + { "b: la_pltenter: tst_audit_plt_flags_func3", 1 }, + { "b: la_pltexit: tst_audit_plt_flags_func3", 1 }, + }; + for (size_t j = 0; j < array_length (expected); j++) + if (count_lines (err, expected[j].line) != expected[j].count) + FAIL ("expected %d \"%s\" lines", expected[j].count, + expected[j].line); + + if (support_record_failure_is_failed ()) + printf ("info: auditor output:\n%s", err); + + support_capture_subprocess_free (&result); + return 0; +} + +#include diff --git a/elf/tst-auditmod-plt-flags-a.c b/elf/tst-auditmod-plt-flags-a.c new file mode 100644 index 00000000000..2bf12669ba7 --- /dev/null +++ b/elf/tst-auditmod-plt-flags-a.c @@ -0,0 +1,85 @@ +/* Auditor for tst-audit-plt-flags. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#ifndef TAG +# define TAG "a" +/* The functions for which la_pltexit and la_pltenter are not wanted. */ +# define NOPLTEXIT_FUNC "tst_audit_plt_flags_func1" +# define NOPLTENTER_FUNC "tst_audit_plt_flags_func3" +#endif + +#define PREFIX "tst_audit_plt_flags_func" + +unsigned int +la_version (unsigned int version) +{ + return LAV_CURRENT; +} + +unsigned int +la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie) +{ + return LA_FLG_BINDFROM | LA_FLG_BINDTO; +} + +#if __ELF_NATIVE_CLASS == 64 +uintptr_t +la_symbind64 (Elf64_Sym *sym, unsigned int ndx, + uintptr_t *refcook, uintptr_t *defcook, + unsigned int *flags, const char *symname) +#else +uintptr_t +la_symbind32 (Elf32_Sym *sym, unsigned int ndx, + uintptr_t *refcook, uintptr_t *defcook, + unsigned int *flags, const char *symname) +#endif +{ + if (strcmp (symname, NOPLTEXIT_FUNC) == 0) + *flags |= LA_SYMB_NOPLTEXIT; + if (strcmp (symname, NOPLTENTER_FUNC) == 0) + *flags |= LA_SYMB_NOPLTENTER; + return sym->st_value; +} + +ElfW(Addr) +pltenter (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook, + uintptr_t *defcook, La_regs *regs, unsigned int *flags, + const char *symname, long int *framesizep) +{ + if (strncmp (symname, PREFIX, strlen (PREFIX)) == 0) + { + fprintf (stderr, TAG ": la_pltenter: %s\n", symname); + *framesizep = 1024; + } + return sym->st_value; +} + +unsigned int +pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook, + uintptr_t *defcook, const La_regs *inregs, La_retval *outregs, + const char *symname) +{ + if (strncmp (symname, PREFIX, strlen (PREFIX)) == 0) + fprintf (stderr, TAG ": la_pltexit: %s\n", symname); + return 0; +} diff --git a/elf/tst-auditmod-plt-flags-b.c b/elf/tst-auditmod-plt-flags-b.c new file mode 100644 index 00000000000..5f1ec5c7d68 --- /dev/null +++ b/elf/tst-auditmod-plt-flags-b.c @@ -0,0 +1,22 @@ +/* Second auditor for tst-audit-plt-flags. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define TAG "b" +#define NOPLTEXIT_FUNC "tst_audit_plt_flags_func2" +#define NOPLTENTER_FUNC "" +#include "tst-auditmod-plt-flags-a.c" diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile index f046148091c..74c8fc8bada 100644 --- a/sysdeps/aarch64/Makefile +++ b/sysdeps/aarch64/Makefile @@ -29,6 +29,10 @@ $(objpfx)tst-audit27: $(objpfx)tst-audit27mod.so \ $(objpfx)tst-audit27mod.so: $(libsupport) LDFLAGS-tst-audit27 += -Wl,-z,lazy tst-audit27-ENV = LD_AUDIT=$(objpfx)tst-auditmod27.so + +ifeq (yes,$(have-test-bti)) +test-xfail-tst-audit-plt-flags = yes +endif endif ifeq ($(subdir),elf) diff --git a/sysdeps/alpha/Makefile b/sysdeps/alpha/Makefile index faa59ab27a6..ebf6288ccc4 100644 --- a/sysdeps/alpha/Makefile +++ b/sysdeps/alpha/Makefile @@ -69,6 +69,10 @@ CFLAGS-s_isnan.c += -fno-builtin-isnanf test-xfail-test-float32x-float64-div = yes endif +ifeq ($(subdir),elf) +test-xfail-tst-audit-plt-flags = yes +endif + # Build everything with full IEEE math support, and with dynamic rounding; # there are a number of math routines that are defined to work with the # "current" rounding mode, and it's easiest to set this with all of them. diff --git a/sysdeps/loongarch/Makefile b/sysdeps/loongarch/Makefile index 5818755f053..304f246630b 100644 --- a/sysdeps/loongarch/Makefile +++ b/sysdeps/loongarch/Makefile @@ -22,6 +22,8 @@ gen-as-const-headers += \ CFLAGS-tst-tunables-seal.c += -DTST_SEAL_TUNABLE_NAME=hwcaps tst-tunables-seal-TUNABLES += glibc.cpu.hwcaps=-LASX + +test-xfail-tst-audit-plt-flags = yes endif ifeq ($(subdir),csu) diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile index c08753ae8a3..5962c42b0eb 100644 --- a/sysdeps/riscv/Makefile +++ b/sysdeps/riscv/Makefile @@ -4,6 +4,8 @@ endif ifeq ($(subdir),elf) gen-as-const-headers += dl-link.sym + +test-xfail-tst-audit-plt-flags = yes endif # RISC-V's assembler also needs to know about PIC as it changes the definition From patchwork Mon Sep 28 18:55:08 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 144811 X-Patchwork-Delegate: fweimer@redhat.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1BB824BAE7E4 for ; Mon, 28 Sep 2026 18:56:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BB824BAE7E4 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=N3dZWoqK X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ua2-x0f.google.com (mail-ua2-x0f.google.com [IPv6:2a00:1450:4864:39::f]) by sourceware.org (Postfix) with ESMTPS id 1F4A44BAE7CF for ; Mon, 28 Sep 2026 18:55:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1F4A44BAE7CF 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 1F4A44BAE7CF Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:39::f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621749; cv=none; b=IsaEQxXR+pBeNi2yL0KPW7dDSh//pIJ11QlF2KsKuZ3CgbkXSfT5fygC1CTC1DkO41+UZaBHoX98rahNilCPGBAsSq+WbZcPZ/qG9k2jfys3Q4iQLra78Z9Mo3sHw1X4mLMkfzHewE3poCPauTy44u8iSbgPFb1AP+sEi85yJeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621749; c=relaxed/simple; bh=HFdgoLJ8cEYY2cyAZ2/CoMZ+8Em06XWDzBq/884No3o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=puOVjbbKjIYGM8XfEK2TSrMdW5JO0KlPkgjS2QwYbrpoDfeXV6VtzGfQspbl0SOasu1fBuof1uF2DJfuqUdl8aLv5RYOq5e8ZfuSvYPJjHc0JwP4p5iXAWdaVJJ8Y9WMdQSA+zxT+A1c+0gRpZ2TeUmXrUrQGDFt7+HenhNMQXU= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=N3dZWoqK DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1F4A44BAE7CF Received: by mail-ua2-x0f.google.com with SMTP id a1e0cc1a2514c-988b3922341so255827241.3 for ; Mon, 28 Sep 2026 11:55:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1790621748; x=1791226548; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=xL2PL6BA19c2Zuqu3Yhcf8mJLDz96y77e//6zAQLdjk=; b=N3dZWoqKQFQTIViUdrD+dl7QTgxyXAly4Oo6/34LAP9od1LF/RZajjQ1Yr5bSQ/FzZ EWfx4cniFBA5uFUe/uwd9aM9LjFVFocRaX3coCLBeIE+DZH+bmLgC2QsDVNdpOhFiwty /4Uf3kA1QNbR2fDfkuCai+G4ONQf+7I1SS15I4aiG1KW9U6v7bUE4gQ1uIQcjBPNbio1 7JJmRQE9p3LFYHrkYlFOpmW4At4RSGs6jSBCapwsGQFxDrAeJ+aT8PIr3HzF602Pilmz c2+9xYjBp8sJ3QDZd3G+LzGd3frt/r2OqxJIlq708SR2t2JPvMQ8r05TTrdbJx/c1Xjy kyLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790621748; x=1791226548; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=xL2PL6BA19c2Zuqu3Yhcf8mJLDz96y77e//6zAQLdjk=; b=yUjxWA4gx51/ewK7X3OR04EEY2K0JxX7zM1NZWsRFA/SB1YdCFFvUtIWoto9KCO1Bc 41zhvHqGO6kXjao0sOZLXn/o1A2kE7QKd8Yng7KSdQR//+jbpDsYyME7iR+YlGDuykbh uzXTWkFWdHWxEhkYx4u6zUAX3PsSZ+4wcaEn3LlBiHPhAoDJk867pw24CIi9mwzo6f1v /eP6wuQuYHkgmehanSyh7Zo6mDyr0P7oVDomquRh4w5PHIQAb5aTNOVLvtzHNCk0PaJH xxiB6LnlI9Uox8KxWA7nL83ZWRUMwx/pYB5Ujl2ohN7WOAr315iLRdE/UtBiDEwAA/by AIWg== X-Gm-Message-State: AFq9FYK0/+VKZgKcMHBROAP5YGUyq84lHMh5ZnYD1P9sr5h9m7kqQ+H/ P7rh8E7r8MQEMQL/e/5FCGIOYuVa05l4aNuPVsBKgJvFQKju0TJVJnsWRIFatV97LDzpdLmX3zJ YgBQJ X-Gm-Gg: AYBFou2mAZG3Od3Z1aA0Nimdrhpd//b0gjFJryPVs/x2nLqI4B0m2MbLr7KdPfFW6Po lvAQ3r6mFZdGuBXFAW23QyQ5jht1TEWGhARhvwU8rLX3QQSIu1qjpLMsImAqmDPCtF/vewOUcWY xlJIXkqrT605R/x/udHgnjmHk+iVfGjqtM6XedIH8PEKdGIQN4pF9kgXQ4CORqJRvFRP8khkmi0 7qvirE/0rO6gzxtM+KGNP2NBIdzDVsDZhemBVMnf//Fg0G+RYhLEaYzGXlYBMO6K2XiFwtn5Cl+ Igv6RGhK43a4ppC2VdpFLU3HtOoJaXlnjFPfjNOAJSIceMkT8RR1XJ71M5biBkNFjBnrGq9ISKg PA975GKplYmgDRbiwbyPWKn37152dLxClIVsJMTCL1guMu1uiuLkn0GewsQEGtb1TT+/dORt058 lwNHZz5E19pjKuSUXqA3pJrXIWW+GOTW0f86AborCbZgjuBTqV3VZpXftOgiJVhY7BcRLcvVQiR DRlb1h43Pd2tBABft/AbBIW X-Received: by 2002:a05:6102:504d:b0:7a6:85d6:8ae0 with SMTP id ada2fe7eead31-7b1c4a2eae5mr2364468137.1.1790621748362; Mon, 28 Sep 2026 11:55:48 -0700 (PDT) Received: from mandiga ([2804:1b3:a7c1:43a:4422:b237:80b0:bad8]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-988b86d6058sm887554241.0.2026.09.28.11.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2026 11:55:47 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: DJ Delorie Subject: [PATCH 4/8] aarch64: Return with ret from the la_pltexit path of _dl_runtime_profile Date: Mon, 28 Sep 2026 15:55:08 -0300 Message-ID: <20260928185535.1353957-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> References: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 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_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The la_pltexit path returned to the caller with 'br lr', and an indirect branch must land on a BTI instruction (which the caller's return site does not have). Checked on aarch64-linux-gnu. Reviewed-by: Yury Khrustalev --- sysdeps/aarch64/Makefile | 4 ---- sysdeps/aarch64/dl-trampoline.S | 4 +++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile index 74c8fc8bada..f046148091c 100644 --- a/sysdeps/aarch64/Makefile +++ b/sysdeps/aarch64/Makefile @@ -29,10 +29,6 @@ $(objpfx)tst-audit27: $(objpfx)tst-audit27mod.so \ $(objpfx)tst-audit27mod.so: $(libsupport) LDFLAGS-tst-audit27 += -Wl,-z,lazy tst-audit27-ENV = LD_AUDIT=$(objpfx)tst-auditmod27.so - -ifeq (yes,$(have-test-bti)) -test-xfail-tst-audit-plt-flags = yes -endif endif ifeq ($(subdir),elf) diff --git a/sysdeps/aarch64/dl-trampoline.S b/sysdeps/aarch64/dl-trampoline.S index b40d8bb31bc..412fb859064 100644 --- a/sysdeps/aarch64/dl-trampoline.S +++ b/sysdeps/aarch64/dl-trampoline.S @@ -321,7 +321,9 @@ _dl_runtime_profile: add sp, sp, SF_SIZE + 16 cfi_adjust_cfa_offset (- SF_SIZE - 16) - br lr + /* Use ret instead of br: the caller's return site is not a BTI + landing pad. */ + ret cfi_endproc .size _dl_runtime_profile, .-_dl_runtime_profile From patchwork Mon Sep 28 18:55:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 144814 X-Patchwork-Delegate: fweimer@redhat.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 12EA64BAE7D4 for ; Mon, 28 Sep 2026 18:59:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 12EA64BAE7D4 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=UmMrw4vW X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ua2-x24.google.com (mail-ua2-x24.google.com [IPv6:2a00:1450:4864:39::24]) by sourceware.org (Postfix) with ESMTPS id 1F4024BAE7F9 for ; Mon, 28 Sep 2026 18:55:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1F4024BAE7F9 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 1F4024BAE7F9 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:39::24 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621751; cv=none; b=TOkJrBQpCEvjIgAzV6UzQsr7iQ7ahNbF4YcYYbPdRdPF2UFmb5mKFK7dzLdUZb7OjWrfQn9eu3jr/Hyb8+SMlKSfB7qZJ+T/Ta56l1jrU6TumniHwFgJzZwe8NTQVJXEaBHa9+UglSMT8ffuvhwRpEAdw7BUXutEhmnBHAQdfYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621751; c=relaxed/simple; bh=P3q9vO4GhrSgMsj21dN//DXMQuAB+P9xacLlPn5qpJs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=sQOqwvCfinDN+RlOB1Zo96CGMlAeewrbLe8Xw9M/FQvbGorQvzektV27CjKJIHC/xZ+o7yRcPCBC3Fiowal9vO9M8yu2mdpZGWXplur/LA37xXZI3CMe+lpGlQJlBpdvLHQmFvQqnVeI8zq2pDsdBbCoVgjrNC32jFYdQYMbcGE= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=UmMrw4vW DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1F4024BAE7F9 Received: by mail-ua2-x24.google.com with SMTP id a1e0cc1a2514c-97e97e2c7d4so1922847241.1 for ; Mon, 28 Sep 2026 11:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1790621750; x=1791226550; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NUJo698mVPKf14LjwON6l2BJjXy5zdVqGQTfIb9m3Cg=; b=UmMrw4vWampfqofxW7M9BrxRvZ8IDo0bZNjGfFkTIcKSasUgPQRVbWmfCiItDketRK I3CFSU8BLEsQRU2+XdJQXIlaPtc6y+Q1KUY5YbRVG27xJvkC3LzPKD3L3jn/KMtvXdOG f3US6Un3C4sIJ115tlXo0fJYuNK8eITz3puSSqoEuaPxppYuQfs/EvtjdiE9L3xxTtBn WYZ7TTmw/crjDamJrf1tcjnHvJRF3LmIDGDb51vF2RIUxFqQIQfRVcW9IeQMIwP0jsoX 1Kkv4vD3aVLk/1cPz452uEoqnySUnCuJ+KmojdH2m/aQO/0u3UlPVVBSDOsfOeWC8YyF Q6Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790621750; x=1791226550; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=NUJo698mVPKf14LjwON6l2BJjXy5zdVqGQTfIb9m3Cg=; b=WxE6uOu/Sjv69w6kmCzsXxwHATt7N4M/XLu28O7kQPYM12GDVBraZLdHKkzCA+b74W iyMFdj1hzUA2Dm9PGiVcOmbbiqg/9mJon0tcbvdd+T1w4RJDNYcaTc8xSoqMtwO5Y8RZ am0Ty7dVRgFTIQcffRIu1jApZrEpoNJWIeB5ZeX8JtdtpmL2hQN2wwlwiDyhCkfxvtdM Xn5miE0tyCXFeKh2M4gu+ic+7xtL/9CC77dwmT539o7iqGq/qkXN+JcVHomJzqd2C153 kKYHl1AJI8lbJMCMvwFvvIu9UG5xiyu4jCBCQA6YcIvfqpsBH9dhE60IrRdJp2zFHN6Q JVTA== X-Gm-Message-State: AFq9FYKIYrGqks8QntG2TvEQDMhSCwfS2dWmBjVIJvdyL3toYbb99fT+ 7vOI8PMQcEx2rJnEVtXgf5ocr5KmdDchayT3uS/QarmupYQRnUQ46i4nkel+OcrqCHQS/3ZOMzx baR8W X-Gm-Gg: AYBFou33RKwokW1ol1M+hvnpTBkfAuw7whjZe2D3Lgy3Gq/8w4nd+kTXBLV51Cb35U7 C+yrtFmQqatnc6Sw1ZMIkFPDQlQVo2aUnjOflSXECLLmLmNSmn9DqEG0y0ZDbw0NgULKKQODmGj bJPGGPpJ5vL6DPJc2ag/I9wfDIhbgbyHu+JnJ4kjXRTySN7vv9Yd+dfM0CGnr8dXh1Fa8c6659v Pe1+DDYlG976M6tnxgT5DlghLTNqClXgsB/T5yI6Oh7RBP6ZgQcGjri4ZMrDiUhUQYHkDTUJeH9 hQzsQn3G5XuwehPegI49dwR32f8ORmRXgjTC2abdKJmIVTOWOnxsaEQGnB6BNosCnxFMmpOjoYh 6UEuYKtQvTOjsUkWbpVm7M81ryMx6NRc+GiNw47jITrpxFcrtE5/joiG9YTD91Uz0nAFmMA4vvt tAEx4qxQ6LwdlrpXpg6a1UTY+p281pevkv0KngeoYHQQA3hPHl6Ay3ZoLiHRyRGDtpMalP9RSsf MhFKhx5lFIPJhAu1ILSIhYJkS04DeXrWuREnjs= X-Received: by 2002:a05:6102:2c8d:b0:7a8:2a34:433a with SMTP id ada2fe7eead31-7af1cc9e2b6mr5668996137.9.1790621750260; Mon, 28 Sep 2026 11:55:50 -0700 (PDT) Received: from mandiga ([2804:1b3:a7c1:43a:4422:b237:80b0:bad8]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-988b86d6058sm887554241.0.2026.09.28.11.55.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2026 11:55:49 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: DJ Delorie Subject: [PATCH 5/8] alpha: Fix the la_pltexit path of _dl_runtime_profile Date: Mon, 28 Sep 2026 15:55:09 -0300 Message-ID: <20260928185535.1353957-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> References: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The la_pltexit path of both _dl_runtime_profile_new and _dl_runtime_profile_old had two issues: - The call destination was saved in the new argument frame, which the memcpy of the stack arguments then overwrote. The trampoline jumped to a random address for any frame size larger than 14*8. - The return values were not reloaded from La_alpha_retval after _dl_audit_pltexit. The caller got whatever _dl_audit_pltexit left in the return registers. The tst-audit-plt-flags XFAIL is removed. Checked on alpha-linux-gnu. --- sysdeps/alpha/Makefile | 4 ---- sysdeps/alpha/dl-trampoline.S | 26 ++++++++++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/sysdeps/alpha/Makefile b/sysdeps/alpha/Makefile index ebf6288ccc4..faa59ab27a6 100644 --- a/sysdeps/alpha/Makefile +++ b/sysdeps/alpha/Makefile @@ -69,10 +69,6 @@ CFLAGS-s_isnan.c += -fno-builtin-isnanf test-xfail-test-float32x-float64-div = yes endif -ifeq ($(subdir),elf) -test-xfail-tst-audit-plt-flags = yes -endif - # Build everything with full IEEE math support, and with dynamic rounding; # there are a number of math routines that are defined to work with the # "current" rounding mode, and it's easiest to set this with all of them. diff --git a/sysdeps/alpha/dl-trampoline.S b/sysdeps/alpha/dl-trampoline.S index c69d03c03b8..2602b3d0c58 100644 --- a/sysdeps/alpha/dl-trampoline.S +++ b/sysdeps/alpha/dl-trampoline.S @@ -161,8 +161,9 @@ _dl_runtime_profile_new: bic $18, 15, $18 subq $30, $18, $30 - /* Save the call destination around memcpy. */ - stq $0, 14*8($30) + /* Save the call destination around memcpy, in the fixed frame + since the new argument frame is overwritten by the copy. */ + stq $0, 14*8($15) /* Copy the stack arguments into place. */ lda $16, 0($30) @@ -171,7 +172,7 @@ _dl_runtime_profile_new: ldgp $29, 0($26) /* Reload the argument registers. */ - ldq $27, 14*8($30) + ldq $27, 14*8($15) ldq $16, 2*8($15) ldq $17, 3*8($15) ldq $18, 4*8($15) @@ -199,6 +200,12 @@ _dl_runtime_profile_new: stt $f1, 19*8($15) bsr $26, _dl_audit_pltexit !samegp + /* Reload the return values, which la_pltexit may change. */ + ldq $0, 16*8($15) + ldq $1, 17*8($15) + ldt $f0, 18*8($15) + ldt $f1, 19*8($15) + mov $15, $30 cfi_def_cfa_register (30) ldq $26, 0($30) @@ -494,8 +501,9 @@ _dl_runtime_profile_old: bic $18, 15, $18 subq $30, $18, $30 - /* Save the call destination around memcpy. */ - stq $0, 46*8($30) + /* Save the call destination around memcpy, in the fixed frame + since the new argument frame is overwritten by the copy. */ + stq $0, 46*8($15) /* Copy the stack arguments into place. */ lda $16, 0($30) @@ -504,7 +512,7 @@ _dl_runtime_profile_old: ldgp $29, 0($26) /* Reload the argument registers. */ - ldq $27, 46*8($30) + ldq $27, 46*8($15) ldq $16, 2*8($15) ldq $17, 3*8($15) ldq $18, 4*8($15) @@ -532,6 +540,12 @@ _dl_runtime_profile_old: stt $f1, 49*8($15) bsr $26, _dl_audit_pltexit !samegp + /* Reload the return values, which la_pltexit may change. */ + ldq $0, 46*8($15) + ldq $1, 47*8($15) + ldt $f0, 48*8($15) + ldt $f1, 49*8($15) + mov $15, $30 cfi_def_cfa_register (30) ldq $26, 0($30) From patchwork Mon Sep 28 18:55:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 144813 X-Patchwork-Delegate: fweimer@redhat.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EDFFF4BAE7E6 for ; Mon, 28 Sep 2026 18:59:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EDFFF4BAE7E6 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=do3q0sXX X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ua2-x0f.google.com (mail-ua2-x0f.google.com [IPv6:2a00:1450:4864:39::f]) by sourceware.org (Postfix) with ESMTPS id E31EA4B99F64 for ; Mon, 28 Sep 2026 18:55:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E31EA4B99F64 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 E31EA4B99F64 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:39::f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621753; cv=none; b=QrgUT194Na7VYExsAhZmlh6x9csGxnBi4m+RdP7LpVz9VaNj+en+o9+vC2AavOd+65yo8wykAEiVsVpMxpGfffsGpA4y6RnyGTm8426FL53q0eFxL82rXMir/0Q/wRsvPPMnZ9zv18EA/kZZuO/5PysTwo0HQNyjEOx1RBztxcI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621753; c=relaxed/simple; bh=3JmpNDLagGrEFkePrUXTUxQ53F0mJn+KMDcCc/ZxqHo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hwVYCtxe2x2AEwEiFQW7QnehfXKZp6ZwUZhINo4RCzs9vFL5KhKUn8v5PP9EscLcpJ2T01nq/8/YkYOnU7R5Ai4PVxWW/8xdntXKuqyIs8qFSe8WBMcOKFSrDmQ4MXQIb5oKYsRw+P9ogMzyyWRNXRw8cnxCJ/J4abWWsaPFAss= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=do3q0sXX DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E31EA4B99F64 Received: by mail-ua2-x0f.google.com with SMTP id a1e0cc1a2514c-97eaa1155fdso771754241.2 for ; Mon, 28 Sep 2026 11:55:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1790621752; x=1791226552; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=edZhURImL+6XM09r24PGOXB3gCkA2WpT8Y/rAKZ+nXE=; b=do3q0sXXGZ6M5PxE5huGTo3ri+RqvZOFVMabZdnUZLMgwqysy/8fqrecOkQXRsbqUV rAvz+Z2Nx5SWpe96PPpOr2c+Nl3fnudxiLQaAMnemJ0SreTwJ9EpWaWSZ0XPdJP2GlNa 8kzL9iNg9lHZcPex00I9ogDYB8cBceAtFGP3cMRNO0nIlrE/7B90rnWNMHz15oGy4N1v EnA45wF1/I9nZDC3d1r4eq8HDvnBdaF4FgKeM/eGp0sF6b7vN5Hp5rdNyEpwf1DJdys3 69QLGMpb33E2D8BpxQbjBZt9S1AkoKp7XpXmbnOOHqLFHlUDIZIxCXQtYzVfeO3XVHmj APMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790621752; x=1791226552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=edZhURImL+6XM09r24PGOXB3gCkA2WpT8Y/rAKZ+nXE=; b=10xOb6zs7NLQEn5dQ7Vs0Kfo1H4y/oV0RAaOdV1Oc4aIQqwjwj0RrMsP+VmdO7WxOC 1PK5HAHyy7unMbzBvKVgX0fuyXb2M25Tat+gnivpDlC7h59D8a4OZDKwrJBu9+IX0AnN OYG2jK8xtYGXgaDFWfdlLC3ZETFNbZQioVpnn1iwmpr6OOhSJPSjRW6Q/BXOfVhxEmZK Fv7rfSkhaDsoeVUI4ehKrUPBBPbG/tDrLLczw0/rv/hQVB0f5qrV1nVGxrdTq3K2B427 XowB6LOgRdvg7LOEx0lECivy/Ka9CE34Qun+9CyiMiY172rgwvPLAIib5X7gYq2G5HOH O6cw== X-Gm-Message-State: AFq9FYIPLp/JP7cwCSKOeQUFKqjjxC9QzC8bs7dVR2w3vzBmVH1iAejS vF0Q3gepOLkdeJ1iH0/+KLKCEOxgvoUIVFPaOsllNZMraoFgAK8o0nVG6rQq01c5gbBAuZ05bo4 Kebih X-Gm-Gg: AYBFou2xebFo9WwndHvHRsc/R7jEfEWwVp/1s/241Fnhu+Dfm/++qB7inedFsXozTa4 zqPemJe7sS8evG4/uOs2tZXpP8sY8tG+xRF2WObOSCZCyWMtv5qkVM0xQj+9dVlm5obJhImWYpD 43176lRF1yLnDvvVBZkK8tpHV/BcbF9bS/6o7FgjbJ6mHFgR0cj25Xf4SSxryEg0Nvnf/aXECYx Melp49yAy34FNBfExQndHizkcM2t3ec8vcTShb5Y2kaqwM4jmIutr0FqKbdv1pRzOXvciD3CJpi efBlBz+de7+PQdmGCJN+OSLFAQUjvHBGQDMiA6fP5PTy38tmbNEsoblvqhX9JmbT24eJ241IWHI Ep2Xl0Y6QmRhxD7qGHhBZIVcpqUShnMieXRwI30yOVELXGIHl3C2rllh7F2pXFiIo7xGpsesijh EtjQ8kJcXU7YB5VwmMK65U31XKKCRnBYGAIoZ8qypp7+DmhvJ+jFALHKvdflP7CHKkgN+NzmIU8 1rHh+0SSaQLPeMxSWzE6GGENch8801gGUjDeEg= X-Received: by 2002:a05:6102:41a1:b0:7a7:19aa:f0d0 with SMTP id ada2fe7eead31-7af1eff6b23mr4067020137.29.1790621752168; Mon, 28 Sep 2026 11:55:52 -0700 (PDT) Received: from mandiga ([2804:1b3:a7c1:43a:4422:b237:80b0:bad8]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-988b86d6058sm887554241.0.2026.09.28.11.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2026 11:55:51 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: DJ Delorie Subject: [PATCH 6/8] LoongArch: Fix the la_pltexit path of _dl_runtime_profile Date: Mon, 28 Sep 2026 15:55:10 -0300 Message-ID: <20260928185535.1353957-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> References: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 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_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The la_pltexit path stored the return values over the saved _dl_audit_pltexit arguments instead of in La_loongarch_retval, so _dl_audit_pltexit was called with the return value as its link map. It then returned through the lr_ra field, which was never set, and stored fp instead of restoring it. Set lr_ra and lr_sp at entry, use La_loongarch_retval for the return values, and restore fp. The tst-audit-plt-flags XFAIL is removed. Checked on loongarch64-linux-gnuf64. --- sysdeps/loongarch/Makefile | 2 -- sysdeps/loongarch/dl-trampoline.h | 35 ++++++++++++++++++------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/sysdeps/loongarch/Makefile b/sysdeps/loongarch/Makefile index 304f246630b..5818755f053 100644 --- a/sysdeps/loongarch/Makefile +++ b/sysdeps/loongarch/Makefile @@ -22,8 +22,6 @@ gen-as-const-headers += \ CFLAGS-tst-tunables-seal.c += -DTST_SEAL_TUNABLE_NAME=hwcaps tst-tunables-seal-TUNABLES += glibc.cpu.hwcaps=-LASX - -test-xfail-tst-audit-plt-flags = yes endif ifeq ($(subdir),csu) diff --git a/sysdeps/loongarch/dl-trampoline.h b/sysdeps/loongarch/dl-trampoline.h index 578ed8600ae..02818280b1e 100644 --- a/sysdeps/loongarch/dl-trampoline.h +++ b/sysdeps/loongarch/dl-trampoline.h @@ -164,6 +164,11 @@ ENTRY (_dl_runtime_profile) or fp, sp, zero + /* The la_pltexit path returns through lr_ra. */ + REG_S ra, fp, OFFSET_RG + DL_OFFSET_RG_RA + ADDI t2, fp, SF_SIZE + REG_S t2, fp, OFFSET_RG + DL_OFFSET_RG_SP + REG_S a0, fp, OFFSET_RG + DL_OFFSET_RG_A0 + 0*SZREG REG_S a1, fp, OFFSET_RG + DL_OFFSET_RG_A0 + 1*SZREG REG_S a2, fp, OFFSET_RG + DL_OFFSET_RG_A0 + 2*SZREG @@ -323,18 +328,18 @@ ENTRY (_dl_runtime_profile) jirl ra, t6, 0 - REG_S a0, fp, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_A0 - REG_S a1, fp, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_A0 + SZREG + REG_S a0, fp, OFFSET_RV + DL_OFFSET_RV_A0 + REG_S a1, fp, OFFSET_RV + DL_OFFSET_RV_A0 + SZREG #ifdef USE_LASX - xvst xr0, fp, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_VEC0 - xvst xr1, fp, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_VEC0 + SZXREG + xvst xr0, fp, OFFSET_RV + DL_OFFSET_RV_VEC0 + xvst xr1, fp, OFFSET_RV + DL_OFFSET_RV_VEC0 + SZXREG #elif defined USE_LSX - vst vr0, fp, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_VEC0 - vst vr1, fp, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_VEC0 + SZVREG + vst vr0, fp, OFFSET_RV + DL_OFFSET_RV_VEC0 + vst vr1, fp, OFFSET_RV + DL_OFFSET_RV_VEC0 + SZVREG #elif !defined __loongarch_soft_float - FREG_S fa0, fp, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_VEC0 - FREG_S fa1, fp, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_VEC0 + SZFREG + FREG_S fa0, fp, OFFSET_RV + DL_OFFSET_RV_VEC0 + FREG_S fa1, fp, OFFSET_RV + DL_OFFSET_RV_VEC0 + SZFREG #endif /* Setup call to pltexit. */ @@ -349,21 +354,21 @@ ENTRY (_dl_runtime_profile) REG_L a1, fp, OFFSET_RV + DL_OFFSET_RV_A0 + SZREG #ifdef USE_LASX - xvld xr0, fp, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_VEC0 - xvld xr1, fp, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_VEC0 + SZXREG + xvld xr0, fp, OFFSET_RV + DL_OFFSET_RV_VEC0 + xvld xr1, fp, OFFSET_RV + DL_OFFSET_RV_VEC0 + SZXREG #elif defined USE_LSX - vld vr0, fp, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_VEC0 - vld vr1, fp, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_VEC0 + SZVREG + vld vr0, fp, OFFSET_RV + DL_OFFSET_RV_VEC0 + vld vr1, fp, OFFSET_RV + DL_OFFSET_RV_VEC0 + SZVREG #elif !defined __loongarch_soft_float - FREG_L fa0, fp, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_VEC0 - FREG_L fa1, fp, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_VEC0 + SZFREG + FREG_L fa0, fp, OFFSET_RV + DL_OFFSET_RV_VEC0 + FREG_L fa1, fp, OFFSET_RV + DL_OFFSET_RV_VEC0 + SZFREG #endif /* RA from within La_loongarch_reg. */ REG_L ra, fp, OFFSET_RG + DL_OFFSET_RG_RA or sp, fp, zero + REG_L fp, sp, SZREG ADDI sp, sp, SF_SIZE - REG_S fp, fp, SZREG jirl zero, ra, 0 From patchwork Mon Sep 28 18:55:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 144815 X-Patchwork-Delegate: fweimer@redhat.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 94A674BAE7EF for ; Mon, 28 Sep 2026 19:00:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 94A674BAE7EF Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=A+O0ZD+/ X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ua2-x0f.google.com (mail-ua2-x0f.google.com [IPv6:2a00:1450:4864:39::f]) by sourceware.org (Postfix) with ESMTPS id C70164BAE7FC for ; Mon, 28 Sep 2026 18:55:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C70164BAE7FC 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 C70164BAE7FC Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:39::f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621754; cv=none; b=jKdwy/FlWVUnaLASNzfFy5wk/D6fSSbxNG1OsM4fDIm5cGg++vo20DLI3Xvv3l84nCZG/t98nom1W+SrpiLvio2lS4k70HKLCvbJjVWVuSIe753gKWSRcb5NOSR/+kkLVh1rTk33JxqVo5I1sA1HLRqxBgDqvmWOVZfiTtrc2t4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621754; c=relaxed/simple; bh=KEY8sTULd1ziolTGNJg5E7lrn66tQs4J6zOXckxv+iQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NYrdqe4HNMI0SCMr4yrfC4AEGYS+mdTvrf73kpq9avjA2W7hqyWt5Z4kSscHDvIHF4q7ITZGiqw79bDzrVo0mFuF/hM5I7K1IsHf9Z6JjM0ToZUbRIc8vScU43kHuenC0l2htUhJ3lKJqYeLv8FK4rIWJM1zkLxJ/bPLKHz0BO0= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=A+O0ZD+/ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C70164BAE7FC Received: by mail-ua2-x0f.google.com with SMTP id a1e0cc1a2514c-98514b4115eso2274618241.1 for ; Mon, 28 Sep 2026 11:55:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1790621754; x=1791226554; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+mVZ030dXixwL5DUPLmmbZAtRPaH+jfnchV/r5A1nLM=; b=A+O0ZD+/9Cyw0IeRKJlcb+Z4YgPDaLtXYKNqURotlgdu1gYh+HCoVm/9q1FgR/r7yV 1tX+fhI89XfhnjszOPB6GrkeeLZ0Lr72BQAyDdN8FdhBl17cGHmuV6fXV3y2lknAu3WU U2AWJmECq3kD7O8YoPanmIMrDZdlTWx3dMVQmf9v/O6Un30EJrOqi8RgC5xPYcUHcpzp S6TIKj7sfVILiQAClRmYLq8pM1Rr7Wofzg5i5/PQQOq48bpVP2c4nuXzksc4Qeb2vXro 8gSqdD62C0AHw03rz4YqVn1UEiWG/R+xRW+Wb4FXHt9UIrZNsItkKMFVrKGanDjZ8l7n gEwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790621754; x=1791226554; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=+mVZ030dXixwL5DUPLmmbZAtRPaH+jfnchV/r5A1nLM=; b=oJqKYCTZKOzLZuY1DT5aGuDeSM0TKRECv0Tpx5OeXR9tkAeLCCn64SvgGmHSWli2sh IuPxeFeKazkEgGj/R8hppABmvt1cft1rPMIhV8+6BxbgJ10ZmfmeXQ5ii7YwZeawhuce Zl+gvDzu7Bc92hwjVistyAs1+HM4wEkKa56trpsnxz7l1de6mvF2hxHde2ewF5LbHQkd hVeBQvWhUcO+T8wF7qq1RmPyK7r9Aj6Q8fxi1YlWneVOsF8wIVIpTExFrN5aCyHAS5CE YnaHKl7RFk7pznXtYjeCFgBTyq9kyCZy3sdW2faLIwdDZ9LZRzDslbs1gpMRe1+jRxPj NM9g== X-Gm-Message-State: AFq9FYJkZMPaGSkrcl2h/v37+yGWe9nvIfBtLmHqZvdwjyzv06VW5AR7 g+2h/qEavHscu0zxukgCyQNuH1Ir0V/M2rzbpbyTbWpX8Q5PA8BfNjmYfTnWNeLwV0v61KNN1bv I4yGC X-Gm-Gg: AYBFou0hINQXyHoMngBkeAggi/zdhAXYPmA+2DXUwpXqXO3vtjNRtt+hWNi1nUYNpk8 xmHkVU8CMkmowAZU2/4xVhAKXFqLyI8zSufDfarXC39RJGQRjoqNnFAZjMiB0HI84MYXlZ4UIUE pmtjR2cSchZhSmqysS5qZwgDmpM80k+/1pOsvXEpmw+WQlz+cm2BE/ZhNhRh96G6uFWIidyzYDC fhdCGmpTYRTXK2zFgF8hBi2NaMoKTcOm7uuw7uID8lk5LxCgQ5mVSduW6bPgcPZoAs956EJOj8Q uNKyBmQrcnVXCzEzqleq5OvX/aZQvBUa+f6LanQYgaEcSCgitSBLaAvIqmZgXkACBMOXBtltY32 S/VPfwDjB/lzFemIyudsnyq5vJdXGUt2YSPvDhzdTdtOrx9RsJwVrOtJvii61dUPFwoZJQyH6tG Ijf10Z1dnedR1r97iDWAcY6NefmSwQyq1MpcEX2FpASJEq4Z1eMdBl+zEslq0k6wCPaPzXX8/5b hp20e83qGf50jr3GLUr3tWCPGJLXzQ0fxq1MZF2yGDXlQxEXw== X-Received: by 2002:a05:6102:644c:b0:7b4:b196:f632 with SMTP id ada2fe7eead31-7b4b196fb03mr1600156137.30.1790621754081; Mon, 28 Sep 2026 11:55:54 -0700 (PDT) Received: from mandiga ([2804:1b3:a7c1:43a:4422:b237:80b0:bad8]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-988b86d6058sm887554241.0.2026.09.28.11.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2026 11:55:53 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: DJ Delorie Subject: [PATCH 7/8] riscv: Fix the la_pltexit path of _dl_runtime_profile Date: Mon, 28 Sep 2026 15:55:11 -0300 Message-ID: <20260928185535.1353957-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> References: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 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_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The la_pltexit path stored the return values over the saved _dl_audit_pltexit arguments instead of in La_riscv_retval, so _dl_audit_pltexit was called with the return value as its link map. It then returned through the lr_ra field, which was never set, and stored fp instead of restoring it. Set lr_ra and lr_sp at entry, use La_riscv_retval for the return values, and restore fp. The tst-audit-plt-flags XFAIL is removed. Checked on riscv64-linux-gnu-rv64imafdc-lp64d. --- sysdeps/riscv/Makefile | 2 -- sysdeps/riscv/dl-trampoline.S | 17 +++++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile index 5962c42b0eb..c08753ae8a3 100644 --- a/sysdeps/riscv/Makefile +++ b/sysdeps/riscv/Makefile @@ -4,8 +4,6 @@ endif ifeq ($(subdir),elf) gen-as-const-headers += dl-link.sym - -test-xfail-tst-audit-plt-flags = yes endif # RISC-V's assembler also needs to know about PIC as it changes the definition diff --git a/sysdeps/riscv/dl-trampoline.S b/sysdeps/riscv/dl-trampoline.S index 6c731fcfd41..6139fc638e9 100644 --- a/sysdeps/riscv/dl-trampoline.S +++ b/sysdeps/riscv/dl-trampoline.S @@ -127,6 +127,11 @@ ENTRY (_dl_runtime_profile) mv fp, sp + # The la_pltexit path returns through lr_ra. + REG_S ra, OFFSET_RG + DL_OFFSET_RG_RA(fp) + addi t2, fp, SF_SIZE + REG_S t2, OFFSET_RG + DL_OFFSET_RG_SP(fp) + REG_S a0, OFFSET_RG + DL_OFFSET_RG_A0 + 0*SZREG(fp) REG_S a1, OFFSET_RG + DL_OFFSET_RG_A0 + 1*SZREG(fp) REG_S a2, OFFSET_RG + DL_OFFSET_RG_A0 + 2*SZREG(fp) @@ -231,12 +236,12 @@ ENTRY (_dl_runtime_profile) #endif jalr t4 - REG_S a0, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_A0(fp) - REG_S a1, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_A0 + SZREG(fp) + REG_S a0, OFFSET_RV + DL_OFFSET_RV_A0(fp) + REG_S a1, OFFSET_RV + DL_OFFSET_RV_A0 + SZREG(fp) #ifndef __riscv_float_abi_soft - FREG_S fa0, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_FA0(fp) - FREG_S fa1, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_FA0 + SZFREG(fp) + FREG_S fa0, OFFSET_RV + DL_OFFSET_RV_FA0(fp) + FREG_S fa1, OFFSET_RV + DL_OFFSET_RV_FA0 + SZFREG(fp) #endif # Setup call to pltexit. @@ -258,8 +263,8 @@ ENTRY (_dl_runtime_profile) # RA from within La_riscv_reg. REG_L ra, OFFSET_RG + DL_OFFSET_RG_RA(fp) mv sp, fp - ADDI sp, sp, SF_SIZE - REG_S fp, SZREG(fp) + REG_L fp, SZREG(sp) + addi sp, sp, SF_SIZE jr ra From patchwork Mon Sep 28 18:55:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 144810 X-Patchwork-Delegate: fweimer@redhat.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4C8204B9DB61 for ; Mon, 28 Sep 2026 18:56:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C8204B9DB61 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=urU2faA5 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ua2-x0f.google.com (mail-ua2-x0f.google.com [IPv6:2a00:1450:4864:39::f]) by sourceware.org (Postfix) with ESMTPS id B4F764BAE7E4 for ; Mon, 28 Sep 2026 18:55:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B4F764BAE7E4 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 B4F764BAE7E4 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:39::f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621756; cv=none; b=wq1viH33u/UZNKpM5xrkwRuk0CDQlYxmwepz/2YuYUzrhiWHwsn3EgMyNRb0Fw0RqXB1jO1poLstaPsxiVYLxP50nqpnNUbHc1hj197e0kV+f8MRSyMJxErQ3NVNtAyRFUM9I1c5xQl1jE6wYU/K96Y6TEhlzpLBXOWWREn4qs0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790621756; c=relaxed/simple; bh=PFHfSq3buYwd4Fi67wxi9HU/uD2QRj+Eyjs412wsAbM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=t3Nf5j2EDY/2noPx5bXjm7pos7OoWKCYPCc6Bu2yXomPst7ePqOC1HH457ixAwhX9IeaZjqiDlfboFlEmeNx08YZ+mIP3MCDljdpgyiCf6IlXvw4/Ov0l55t6c0i4Y71yn3BUOv5YVwKRO8kxut8cowZRmwcqmUCTk/w1CfVjZk= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=urU2faA5 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4F764BAE7E4 Received: by mail-ua2-x0f.google.com with SMTP id a1e0cc1a2514c-988b3761477so231332241.2 for ; Mon, 28 Sep 2026 11:55:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1790621756; x=1791226556; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=tWSqWOqRPcTtb7fWeQUSgrby7WypnaW0MlPoeVJFq/o=; b=urU2faA5E+J4hooR+ulf9BQbbSAKeOb8DJcuDrrJ7ZB+J0Cr9xAkVRKy2ICK1MTS7s 3jl9EPFO4XqI4FildMVHzQsdB89swDLeQcEG/cxMgMzHH2Pp34oW8dAWgl446Yz9DHA+ RLWj4J3TQtiioMdTTmuRdtdJa578lwBJTa9XHiLjEl+RY99MLGT6yV69px5X1JiCPs5a PclGJ5OJuecAoKQLqJqUcfFxZsISwp+q6PhXoRKi9ZC7S/isWlIUw4ctS5XPz3Hyc/sY 6zlPH4kalEeER9+nMfinNBV6wgpXla5gYExBt/DucSspmBBBkzOJTiiUIoEwCa4XlcjC F+FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790621756; x=1791226556; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=tWSqWOqRPcTtb7fWeQUSgrby7WypnaW0MlPoeVJFq/o=; b=tpmmlqrrItttbKoNbX3a7uPRBFw6Pc1ZQQcr8iwvP8xtnEePmAbKCxMvdYR+tnvHsb CnP6Sg/i8Qa0dTht30ZcOkczXAHAcHs5C4gmSzB63DoA0x29ucH1ogI5mbImq2AMzWxR OnB5TuUsLkVuMK4ceepzkETx/wZDo5rWWVk+y+6jjbTsxM/2yDF98Pt5uGuSx7H79Che oY1eZANLfGflcpO3T3BnkamOg8naqg30/VakbQ6FdcIQTv6/+jpukdqBeuN5bjjxAtpo 6fwll33rho9+m79e0UYCdjoLfTrjkgWHcA5MDpqxCOt6jMU1xS9dJNauEQ2Vfk37Mvp4 4S9A== X-Gm-Message-State: AFq9FYI5Yp0D3iFGqo+t5LrSi9JcwdwMUJU+znlSdTVrFGRWpkRBAWcs 11O+JUplDiw/AIYMH/KogpWPJAJdsU+EBvh7AIqQs3R+JrzCkWfX9XDRY7LOUh415KSZDwpNsAk rgUwD X-Gm-Gg: AYBFou0T1+9Yca9owO7JDuUFNp93HagwNqQk8hgQuA7u9Fizs1eEbZY0SrwwN6OmmkH Z0eG1Xyo3tALKEn1px2aTCMZ4S6WRNDPNeGrYEqlJopHU8jz72eyIDbyVcK/IioUsqop7LSKlxC LVnurKlIv4MItQbMIHcoHX50SaA3J5rQVazwoVhvyiStClX3KoMzKGDETZehYJBa9NZSQ1iuubO wFoTDLNw14evZbt2+w7qadNfA6fVvnXUI2H8hdN/sphe6yvgIBsJ+jKIi8EmFkBoY0VFsscNq/t v9hoivbBayJUP/W3TqB69NIwS6r8j++rqoMI11tJyN1jDO+uWygxVa5NzCV/njAegItLqHy416Y KkWSzzE/JLfQR9dr3dS/Bh3p/vsQjSCVxiIrTjdSVuFpcT0uZseDEVHLGMfMth5iCg6hMJ9EUZR 5RO/InHA2wb8v8l10ejl6fqKHiZMd/84EwaXU/hbcg3osWvIPF/vOS/muU6JA/c3xid/b+YzIRR M0R4AQF0IIbDFQFONmaieV1XrN7AmxutT2jhgc= X-Received: by 2002:a05:6102:e10:b0:7a7:195a:1b27 with SMTP id ada2fe7eead31-7af1f611721mr4237307137.33.1790621755846; Mon, 28 Sep 2026 11:55:55 -0700 (PDT) Received: from mandiga ([2804:1b3:a7c1:43a:4422:b237:80b0:bad8]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-988b86d6058sm887554241.0.2026.09.28.11.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2026 11:55:55 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: DJ Delorie Subject: [PATCH 8/8] hppa: Fix the la_pltexit path of _dl_runtime_profile Date: Mon, 28 Sep 2026 15:55:12 -0300 Message-ID: <20260928185535.1353957-9-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> References: <20260928185535.1353957-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SCC_5_SHORT_WORD_LINES, SPF_HELO_NONE, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The la_pltexit path of _dl_runtime_profile could not work: - The frame size was checked with an unsigned compare, so the path was only taken for a frame size of 0. - The rounding of the frame size cleared the wrong bits, leaving the new stack pointer misaligned. - The stack copy copied the trampoline frame instead of the stack arguments below the entry stack pointer (the stack grows up), and overwrote the saved stack pointer. - _dl_audit_pltexit was called with the ltp of the called function and with a La_hppa_retval pointer that did not match where the return values were stored. - The stack was unwound by adding the frame size instead of subtracting it. With this, tst-audit-plt-flags runs instead of being UNSUPPORTED. Checked on hppa-linux-gnu. --- sysdeps/hppa/dl-trampoline.S | 53 ++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/sysdeps/hppa/dl-trampoline.S b/sysdeps/hppa/dl-trampoline.S index 44ae3869975..690f37848db 100644 --- a/sysdeps/hppa/dl-trampoline.S +++ b/sysdeps/hppa/dl-trampoline.S @@ -181,10 +181,9 @@ _dl_runtime_profile: stw %r21,-32(%sp) /* PIC register value */ /* Create La_hppa_retval */ - /* -140, lrv_r28 - -136, lrv_r29 - -132, 4 byte pad - -128, lr_fr4 (8 bytes) */ + /* -144, lrv_r28 + -140, lrv_r29 + -136, lr_fr4 (8 bytes) */ /* Create save space for _dl_profile_fixup arguments -120, Saved reloc offset @@ -248,7 +247,7 @@ _dl_runtime_profile: /* *framesizep is >= 0 if we have to run pltexit */ ldw -112(%sp),%r28 - cmpb,>>=,N %r0,%r28,L(cpe) + cmpb,<=,N %r0,%r28,L(cpe) /* Adjust sp, and restore function result address*/ ldwm -192(%sp),%r28 @@ -269,27 +268,32 @@ L(cpe): guess how much extra frame we need, and how much frame to copy forward. */ - /* Round to nearest multiple of 64 */ + /* Round up to a multiple of 64 */ addi 63, %r28, %r28 - depi 0, 27, 6, %r28 + depi 0, 31, 6, %r28 - /* Calculate start of stack copy */ + /* The stack grows up, so the stack arguments are the framesize + bytes below the entry sp. */ ldo -192(%sp),%r2 /* Increate the stack by *framesizep */ - copy %sp, %r1 add %sp, %r28, %sp - /* Save stack pointer */ - stw %r1, -4(%sp) - /* Single byte copy of previous stack onto newly allocated stack */ + /* Single byte copy of the bytes below the entry sp to below the + new sp, using a negative index from both. */ + cmpb,=,n %r0,%r28,2f + sub %r0,%r28,%r28 1: ldb %r28(%r2), %r1 add %r28, %sp, %r26 stb %r1, 0(%r26) - addi,< -1,%r28,%r28 + addi,>= 1,%r28,%r28 b,n 1b - /* Restore r28 and r27 and r2 already points at -192(%sp) */ + /* Save stack pointer, after the copy that overwrites -4(%sp) */ +2: ldo 192(%r2),%r1 + stw %r1, -4(%sp) + + /* Restore r28 and r26, r2 still points at the entry sp */ ldw 0(%r2),%r28 ldw 84(%r2),%r26 @@ -305,26 +309,27 @@ L(cont): ldw -116(%sp), %r26 /* (1) got[1] == struct link_map */ ldw -120(%sp), %r25 /* (2) reloc offsets */ ldo -56(%sp), %r24 /* (3) *La_hppa_regs */ - ldo -124(%sp), %r23 /* (4) *La_hppa_retval */ + ldo -144(%sp), %r23 /* (4) *La_hppa_retval */ /* Fill *La_hppa_retval */ - stw %r28,-140(%sp) - stw %r29,-136(%sp) - ldo -128(%sp), %r1 + stw %r28,-144(%sp) + stw %r29,-140(%sp) + ldo -136(%sp), %r1 fstd %fr4,0(%r1) - /* Call _dl_audit_pltexit */ + /* Call _dl_audit_pltexit, the called function may have changed + the ltp. */ bl _dl_audit_pltexit,%rp - nop + ldw -32(%sp),%r19 /* Restore *La_hppa_retval */ - ldw -140(%sp), %r28 - ldw -136(%sp), %r29 - ldo -128(%sp), %r1 + ldw -144(%sp), %r28 + ldw -140(%sp), %r29 + ldo -136(%sp), %r1 fldd 0(%r1), %fr4 /* Unwind the stack */ - ldo 192(%sp),%sp + ldo -192(%sp),%sp /* Restore callers rp */ ldw -20(%sp),%rp /* Return */