From patchwork Mon Sep 30 20:08:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 831574 Delivered-To: patch@linaro.org Received: by 2002:a5d:66c8:0:b0:367:895a:4699 with SMTP id k8csp2120535wrw; Mon, 30 Sep 2024 13:09:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWTxbhbkJar47kM7uNXB6SK4PTmEHD9ODiKFLkPlgcr/re5HGFVUDIh19yG98QDdy6/ndnlSw==@linaro.org X-Google-Smtp-Source: AGHT+IEbpwS5h8PLl1mdUXBa/JoNdp28uk0kZ+Rbbtmxc84X5223NTnJF26ab7I+s98DuTfTf81y X-Received: by 2002:a05:622a:1aa5:b0:458:31ae:d45 with SMTP id d75a77b69052e-45d73aeb8b9mr13477771cf.26.1727726985036; Mon, 30 Sep 2024 13:09:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1727726985; cv=pass; d=google.com; s=arc-20240605; b=hMA5bjp1UwBwL6qBW53nggQBaTuLnBZ+KJUHSanGziqchsFZkp7V1oC/aDERURt8vP 9FtGtBb/bRUGBJtCJjdCeHc9gsq32eIJQqiUi8gywT4Rmknasm0qcdrp9PyWPePWlwFC E7xbdN/lgH82/wfNWeeO45QCFWQTIrFz64b9gh8qKyVbU2zvJMXxrld6Rgaac3e37kf4 qeAcOfypAB+lf6b4tjeDI6glfcnIT6aHp1cXdUGeWywN4unpnLavTMtYr8Nnghy2vWF2 VsYG31oQeKd5iiA6VsvIInTMIZeLk6lVZtCkfD/tRWiimpm2GDrX7jIi+7YPLB+5aXn6 dEUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=qo1+QsqCRiZ1lpIaotDFAn0w97r06TArb2ben/5KGn4=; fh=3tUIaab7WH3k5DYf15UFmY7vUQNGmrLDHVJFJrkNDfY=; b=QvhSsgclR2fyjI/GRLpDYFb1lbPC0U7Xy54NAywhuFhR0o8qlPoZdHdmboF4uDP5fI MaysPJPiAWVuBVGTleuPfmFoTx48ifFy0h52hsuA91TDtt7eni1tUhDgHdVl688CIGiB fWh5gWwCyWIy9ZYW1rbSN7iska7hc2pYbnlUkg/Gei+iphV8PqnipTHMN5RmF4Sdr00A Df36tGGQvwMXxXzSeBk7Xy54eghssbmoY5H+plQmRE7vrJ8aF9TZQj9iXW1wEO8VtEuJ ezPR3AZ7ymFWHCCaiz/LkjNFqEeM1W/GSz5rHdDvcojS+p0FZZFh1uYOBNvGH7X/NlHG m2Rg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XE+pcQZ0; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d75a77b69052e-45c9f2bd60esi90852121cf.164.2024.09.30.13.09.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 13:09:45 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XE+pcQZ0; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9AF153845BD3 for ; Mon, 30 Sep 2024 20:09:44 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id B6BC83849AC4 for ; Mon, 30 Sep 2024 20:08:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B6BC83849AC4 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 B6BC83849AC4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727726932; cv=none; b=h8E5O0lsEULswf1QGOCX/OGTWlV/g98R37r1qawMdFWGVMip1vwmwAmm8ZcJcdC1ejT3DkvkNXHjfKiPWSuuV87Mi5iXS7VTzBRXStcTbaifESaYW7Z/KhOKJSiDuURNZHuMTXTo2k2A/jv1kTdjxNsUo94c5M0/3NsT44Oid0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727726932; c=relaxed/simple; bh=Z/IFPyohGzY2amWz/0l6s4QlyK0PDIJ3nmjjdByNp1w=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Rox5IoBYiOe51h4CO00A5fSNwHqn/zjYzsx12qtQeMs7UaZhZ1OhNinQAw2RSHDDbb1D4uFsMfM42jgjZn/OTi5HQmY8//Bui13l+KYzUao5Q+WTSR/uXemFDVzK69mxwFneL04KZSS98LHZEc3xTkmtoRAZH8f8sYjgui8GrnQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-20b01da232aso34051945ad.1 for ; Mon, 30 Sep 2024 13:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727726929; x=1728331729; 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; bh=qo1+QsqCRiZ1lpIaotDFAn0w97r06TArb2ben/5KGn4=; b=XE+pcQZ0Cmf80wviz97OnTa8m7Wk09KwgEBoXG10xkK7TG27joJ0H2YDRJmoe12doS T/jMvi4mDyW2Z5HQDjdGN25S22mR18zUSAvjsKCbwVtZ3n06L7zeuL/hv570gULUwpoM NewZYliK0h/U3NVN2t7BGCwYiTgduQ+OOSE8/BRDquI2pQIRUqV2U8oGoOfxFWknjCWh eF1FouK5AMq81W2ZnIFPJGweraj+GT9L6DubQ4FSG8BPyQ6vlYSJW7gqDCmoQtISqWLH hMdFLT8c+DEWo55DxPoUajKjIH3kANGAAX2RiKmAhfFNXitBIthaTHIuFoZi0P9or4mG 731Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727726929; x=1728331729; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qo1+QsqCRiZ1lpIaotDFAn0w97r06TArb2ben/5KGn4=; b=bROMLNg2IpKFrbfhR4ZGaQmhYpGTA6ffyVOQAN+Bu7ziYYHm2/7S/zwLax0tr6DuaG QCSe6TuThY+d4seAHLbHysST0afIHLV9uB3G1ZWSb0tQBdSbnr64IcMaTJU0u+N4O0H2 WbcOXBU+ADORpLpdd2qFINhGsg8xkJgs/4S/pk+HW8kjM11Bsjf+PT8UVr7vVm5Qnwy4 zi64yeCUfkrwakY6M5Cj/cZP4gVYgMYhqNx3b11d1o0HQIDNyi3HETeywUxTVlas/ilG T96Xn9FIIMAYUhncSNdpS7pqH6XYxESJGHS2cohSCBf6+UAQ5bkuDkcezEKKF0/cG9ng sAhQ== X-Gm-Message-State: AOJu0YzjYX+X4zGTBL1690miMFn2BTsgeqqxEBkhVZkAXPHddY4tzJvw zIiCh5PO10TuxhxJMimOLqpkKopENJ0Q3juthnqTgh0IkykLy3UJFxM3vzRlhBi2KGyAqvJVLcL 3lpo= X-Received: by 2002:a17:903:230c:b0:206:9c9b:61bb with SMTP id d9443c01a7336-20ba9e9ab3dmr12677655ad.6.1727726929452; Mon, 30 Sep 2024 13:08:49 -0700 (PDT) Received: from ubuntu-vm.. (201-92-183-102.dsl.telesp.net.br. [201.92.183.102]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6db2c4845sm6869565a12.43.2024.09.30.13.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 13:08:49 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Stephen Roettger , Jeff Xu , Florian Weimer , Mike Hommey , Adhemerval Zanella Subject: [PATCH v3 3/9] elf: Parse gnu properties for the loader Date: Mon, 30 Sep 2024 17:08:25 -0300 Message-Id: <20240930200831.1669010-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240930200831.1669010-1-adhemerval.zanella@linaro.org> References: <20240930200831.1669010-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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~patch=linaro.org@sourceware.org So it can opt-in for memory sealing. Checked on x86_64-linux-gnu. --- elf/rtld.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/elf/rtld.c b/elf/rtld.c index cb6b61d570..8dfa089f83 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -1751,11 +1751,15 @@ dl_main (const ElfW(Phdr) *phdr, /* PT_GNU_RELRO is usually the last phdr. */ size_t cnt = rtld_ehdr->e_phnum; while (cnt-- > 0) - if (rtld_phdr[cnt].p_type == PT_GNU_RELRO) + switch (rtld_phdr[cnt].p_type) { + case PT_GNU_RELRO: GL(dl_rtld_map).l_relro_addr = rtld_phdr[cnt].p_vaddr; GL(dl_rtld_map).l_relro_size = rtld_phdr[cnt].p_memsz; break; + case PT_GNU_PROPERTY: + _dl_process_pt_gnu_property (&GL(dl_rtld_map), -1, &rtld_phdr[cnt]); + break; } /* Add the dynamic linker to the TLS list if it also uses TLS. */