From patchwork Wed Oct 23 08:39:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Khrustalev X-Patchwork-Id: 2000864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XYN3203RTz1xx0 for ; Wed, 23 Oct 2024 19:47:25 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 344003858C5F for ; Wed, 23 Oct 2024 08:47:24 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 945063858C50 for ; Wed, 23 Oct 2024 08:44:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 945063858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 945063858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729673064; cv=none; b=vPyBxMGHABEd+sPakBT219Cvc0EwWOWHV4A6j7c+XbA3LQeQ/2XfDGwXLrU0NVufUt8hupXNUYPu+h+0Z7jz75iSFce9n4K0EtFLctWBf+GYsR+05b1awiDnhCxYAAkqpZeBUtP+x6SFtW850fKSk16lYCi78N5pGgzpmYLhMK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729673064; c=relaxed/simple; bh=Q8HslczlT64puxqYjZNDWc4qXOvaRIUoFjvqx8w5sSY=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=bAZE3BY0AiRNmbKfeVDda3UOPF05t7lJS+mB74oS/XeB/c3a5ii8VuGkKblPtGVen7jOhb3bW435e5mKtX7A8+ayvuPgWrCsjuUcVHih97wwbL4M+BuMRg2cid8AfjjVyaVphmzw+L7EzeXXkWa4C7Q0lY52K6lvzA5dIVDJwGY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 079601575; Wed, 23 Oct 2024 01:44:50 -0700 (PDT) Received: from udebian.localdomain (unknown [10.1.39.30]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 956BC3F528; Wed, 23 Oct 2024 01:44:19 -0700 (PDT) From: Yury Khrustalev To: libc-alpha@sourceware.org Cc: fweimer@redhat.com, adhemerval.zanella@linaro.org, codonell@redhat.com, nsz@gcc.gnu.org Subject: [PATCH v3 20/23] aarch64: Process gnu properties in static exe Date: Wed, 23 Oct 2024 09:39:17 +0100 Message-Id: <20241023083920.466015-21-yury.khrustalev@arm.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241023083920.466015-1-yury.khrustalev@arm.com> References: <20241023083920.466015-1-yury.khrustalev@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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~incoming=patchwork.ozlabs.org@sourceware.org From: Szabolcs Nagy Unlike for BTI, the kernel does not process GCS properties so update GL(dl_aarch64_gcs) before the GCS status is set. --- sysdeps/unix/sysv/linux/aarch64/libc-start.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sysdeps/unix/sysv/linux/aarch64/libc-start.h b/sysdeps/unix/sysv/linux/aarch64/libc-start.h index 0dd102c374..1cc4dab818 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libc-start.h +++ b/sysdeps/unix/sysv/linux/aarch64/libc-start.h @@ -21,6 +21,8 @@ #ifndef SHARED +# include + # ifndef PR_SET_SHADOW_STACK_STATUS # define PR_GET_SHADOW_STACK_STATUS 74 # define PR_SET_SHADOW_STACK_STATUS 75 @@ -36,6 +38,16 @@ aarch64_libc_setup_tls (void) { __libc_setup_tls (); + struct link_map *main_map = _dl_get_dl_main_map (); + const ElfW(Phdr) *phdr = GL(dl_phdr); + const ElfW(Phdr) *ph; + for (ph = phdr; ph < phdr + GL(dl_phnum); ph++) + if (ph->p_type == PT_GNU_PROPERTY) + { + _dl_process_pt_gnu_property (main_map, -1, ph); + _rtld_main_check (main_map, _dl_argv[0]); + break; + } uint64_t s = GL(dl_aarch64_gcs); if (s != 0) INLINE_SYSCALL_CALL (prctl, PR_SET_SHADOW_STACK_STATUS, s, 0, 0, 0);