From patchwork Fri Dec 6 17:37:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 847839 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp910557wrt; Fri, 6 Dec 2024 09:40:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVUADd2wwBcw/qFR/w2Vy8GYL3dtgrEmZ25Hqy4ktMxzne5hrHR8GQVrandC5hEqpxnKJeR9g==@linaro.org X-Google-Smtp-Source: AGHT+IGkyKDC4u/uDQ1efV63bACE0Kuah5Pxz6C7A5CvMMhufjJepSsxPpbwdqbJydvv6+DqIDPi X-Received: by 2002:a05:6102:304d:b0:4af:4945:9a0b with SMTP id ada2fe7eead31-4afcaa23ac8mr4754509137.5.1733506818002; Fri, 06 Dec 2024 09:40:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1733506817; cv=pass; d=google.com; s=arc-20240605; b=D7qZnjZJCaTX6bQGJ4s2s7QDyF99rkjjIdAiIlPSXZGJGFtdv+7ELg5tb4dsw7FaDy HIUj8kVYgmtJe4LPn+SjUZqlG1LvBWz03khwR9AFUzFj7sFzLryMEHn6OU2Y0cUhfuoX LZFT16287f6UEywHOyUSytBdMqkwNnGhjDaG84MlpMPCPlRg9XJm0gWTF73/0qEaEQ9Z Mzyzifs1URqj3GsUUjGEqgCTp5L85txxHp7p48h0NkxPZKbxwYWT1XKvWDk19mP1XkIi dirAuYqGSB2IjB5WVbX0DgaUtal5PM77syXlq1aOP0E8ZhrHj/G54K0i0dyMLPcCzImK XF3Q== 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:dkim-filter:arc-filter:dmarc-filter :delivered-to:dkim-filter; bh=cPEqMAXi1/CcDCU7DfI3OZGCMz96IJO+8lN7RSsBLBc=; fh=39H2oohB6ZYGhyKHcKf9chiYMCdt+XzUdxuRAxp69qM=; b=fb4UGmUeE7gMft5FlAxHa+bVuK1XCwnd42N/UQPk1VmGVPBi/w3GhVLsFgbTm38NkJ tb7c7Wjb/fAbfWMelFi6xrQ7k08HTCaY3mbZr3Mk2Bir+fRlhHKhTk1Xv/yd+nY+kpmF AIAUZy8nVH+kGQCBLn7iTT2w5INAm4DKtSegV8mQIsqOtyhvoesQHJ69VuGdFrjrKHUP i0UZSCvSNTBEvtvbKC8IrXq/Z63j0EbuC23yTaDeyu0b19pKDx3P128Ig2Y3thYN4e/8 FI9HkS4B469pTNRq7eGl/A9xgC8ScVXnvAe7iIQwvgopFb6KAYfjk6XaYfx/e2kAO7O1 mAYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u9RFxJj9; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ada2fe7eead31-4afde4a3104si284137.155.2024.12.06.09.40.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 09:40:17 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u9RFxJj9; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 7E9153858CDB for ; Fri, 6 Dec 2024 17:40:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E9153858CDB 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=u9RFxJj9 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 3AA56385840B for ; Fri, 6 Dec 2024 17:39:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3AA56385840B 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 3AA56385840B 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=1733506743; cv=none; b=bet0+7PFXq959kfpv4ykCFFF6/kxiLkTn6VsXQCl2rqq5U0wUpWsrJWE0PqNh6f1PtKpOOTD8UB/PLYtFmdthnLO0QDQjjkHtHH2ZboS8gNVQHfwFxBrz+WejZ0Z7NDFRGs/NhBn243kGN71cq5qZdB0WGClY9g3CBswOoP/DLc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733506743; c=relaxed/simple; bh=Gmm1Q1a4lsJw3noBbRK01sKogkQLwZaXPHy2R2xOU5A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Ctvokz5noNu67IH/HHR3JSTho7xu7SaRgKFSzCghk1btw4tFbPuu6et/348UjBd0cGoyKj2VMmUQUafhyYFWuCYtGeZD1qnWGM286WsIdjUY3lKDst+2aEiYglJUBu1ixckO0RUYeBw79hFRc+nzqNHkF7+jtxuEpGhiph3vp6s= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3AA56385840B Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-215b4681c94so20126355ad.0 for ; Fri, 06 Dec 2024 09:39:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733506742; x=1734111542; 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=cPEqMAXi1/CcDCU7DfI3OZGCMz96IJO+8lN7RSsBLBc=; b=u9RFxJj9gj2mwvItr9fw+3oKRS7CEDFFbC1PJ5FrJjIiW4SfHOt+bmcgNJqBAolDeN 9KzSx0QOWqj1rvPpPZcuuodb01yIPbOSx9kAAkIlN8PabRs/MT1m8p1VPgKzf0ifAr/s em6MVZP1DSVTJqWOAe/4J3rttq8OFuLhg+EMIHOGXOhNu6wiAvv3G2RBzaiYREpO2H87 QWRv8DSE+BlGmmSuf16jpgQOOpJlU+ILAiMbAg3uHPfTeHRvvqfxP5XeULXrq5v2USni ymfTyrLhmEFt93O/pF7X+KN0F2nmqM0ddERrYwgxzRrHecuuSDRiESEspGcDnbbNzXLE Ex/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733506742; x=1734111542; 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=cPEqMAXi1/CcDCU7DfI3OZGCMz96IJO+8lN7RSsBLBc=; b=MPXYKtaX0A0ztimVUcEdrg2fkEnGLHEm+Ay2o02yT9wHVRH7yYyc/otaTsG5wsaeqz xcbJjXmdDPm+9PcSRLlFYYK8nrlWzcqJYSNSbNdkrm2a1p65iiqWYM5uOtjq72VR0mqM RnltNB70TRtSuXYC4OsjQO3B6Z4LcHrhHq80eyHogcXbqnzVpxVITq7giTg4xJVDduFe Twklm8zeuuHXvNnzUpJyqMl3IIj4Cv1v+teYh++0ZRRBjkaMqcGmQmnqtUk1GKF82RHr LbAoaA0qts7E07OUaCQKMe2yiLK1nQTu+/F9vmqHUyBx5ZmzvyWnJc+UJSWsQqsBen6b v5FQ== X-Gm-Message-State: AOJu0Yx+R534qjCuHc8S1+zwmapKbESySkb0uAGAKUaHRs7qFxzaFEVZ 783b1wYZxe5NTf+6fbNCX6ffdwY2+F9ObzLT7X8zQnVos00SIUjplEDpizPOAmCx68MZ+fAAhTD A X-Gm-Gg: ASbGncseJp+MCs/0wlUCF7TAXkJXlIWlg3ft7RWNlSzjJFJh9eBE93i4G2zRU0Z10+f C98qMKpSZSglcU0zypJQvIdhBv8Uv+7QABPf/O88yVp9ta8dUAzub7CHrPqA7TGcXsVOv3fU+RQ eUu7zsLhiqnb/S2nKHBAO1O5FIf9SFvrd33rQdRHwWtRYHRzQPM5YtA6U6sX5+uqr9ipE++ggDW XRc9uOLZewBxvAfoyK8wF53zD6bTTeUizhLej8qWUV1kIAKS10JuG2wyOAPvw== X-Received: by 2002:a17:902:dac5:b0:215:8112:2fa with SMTP id d9443c01a7336-21614da9d08mr50770065ad.36.1733506741957; Fri, 06 Dec 2024 09:39:01 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:2d1:1460:dd43:b597:c3fc]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8f29635sm31409495ad.241.2024.12.06.09.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 09:39:01 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Jeff Xu , Florian Weimer , Mike Hommey , "H . J . Lu" Subject: [PATCH v4 3/9] elf: Parse gnu properties for the loader Date: Fri, 6 Dec 2024 14:37:51 -0300 Message-ID: <20241206173850.3766841-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206173850.3766841-1-adhemerval.zanella@linaro.org> References: <20241206173850.3766841-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 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 b8cc3f605f..e19086ecad 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. */