From patchwork Tue Nov 3 10:25:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 11876665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED, USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3E2FC2D0A3 for ; Tue, 3 Nov 2020 10:28:37 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 13B48206C0 for ; Tue, 3 Nov 2020 10:28:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BtlE4q7y"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="yYXYdIAc"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="yYXYdIAc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13B48206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=0vSJKrIhJSZtX9H1r/E9Zq5tjRoJOYUR+piVOopxRp4=; b=BtlE4q7ys/+3iPUI7q0W/WmOLg LOR3MSR8nkjO4Xwxf/Bu0is9HtuCX+nWPOlxUKraubm7Hm/7a2UD0tTt2p29X8646IMGK+jqW+dAv KCndRMftgOeozCUtju9j70XNUHBx80vAZr6Q1/VnTjFP+10jrk5N8kTlUdKc9n9Exx33so5eKnVnF IBX1XEQOzmOKkspSNHGyhnWM/wafcFAXbh6ZwTuurec43QBMrspNr+H44nq86Fwg+YfdqvPUDoZCb DStSaZpe56YUbm9AJ3E74B4ddk3Kyfic4o8wHOT2b75ZEZXfDXUHOBL+4ar+hPJbFa/GMqze0yMVE YOl7SdUA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZtW8-0008Qq-Fe; Tue, 03 Nov 2020 10:26:20 +0000 Received: from mail-eopbgr10050.outbound.protection.outlook.com ([40.107.1.50] helo=EUR02-HE1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZtW3-0008OL-9R for linux-arm-kernel@lists.infradead.org; Tue, 03 Nov 2020 10:26:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U9IJavFSnLVyxgelY1q3iBNMxsZVKwWSfeObLsze7Gc=; b=yYXYdIAc4FOA5a7hA3AL74ba+QFhbHpF4iQGggi0zpa2IVwGrSL5KxAp5AoLLrqFUTqjU79qiJUn4+qxKCPjXvyuyOnNg0WVPm3IQp9dOsbhaM3/lN0tMMMsSUiaDFPzVtWTR2UuOpweumhPHBuug4//DuZ8y20xOgkmlfLpKTM= Received: from AM5PR0301CA0012.eurprd03.prod.outlook.com (2603:10a6:206:14::25) by DBBPR08MB4300.eurprd08.prod.outlook.com (2603:10a6:10:c5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.32; Tue, 3 Nov 2020 10:26:06 +0000 Received: from VE1EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:14:cafe::cd) by AM5PR0301CA0012.outlook.office365.com (2603:10a6:206:14::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Tue, 3 Nov 2020 10:26:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.infradead.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.infradead.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT004.mail.protection.outlook.com (10.152.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3520.15 via Frontend Transport; Tue, 3 Nov 2020 10:26:05 +0000 Received: ("Tessian outbound 68da730eaaba:v64"); Tue, 03 Nov 2020 10:26:05 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 938e218c014de032 X-CR-MTA-TID: 64aa7808 Received: from 16d8a73bd160.3 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7506EF37-D79D-4E3F-8893-D75F5BE78EC4.1; Tue, 03 Nov 2020 10:25:57 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 16d8a73bd160.3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 03 Nov 2020 10:25:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LTJMPAFsv3JLr2epKsgUmW9kq9CMh/QF4jyqrSDll0NAiUxylJFjYSza1i0W/ZoRKfL0MR3RdMXQ+NH6a8JUotpVBt+Hd7rE33hTHlT9cFyqjgUYjOPcZqlBXHIy6n85Rr6KS0R01Cw9YLXjeZFaC+sG4tLvxr4zI5jgFJmIJ/PL8vjC6ndUAG55VfsJ/cF1ePKMhb5sVGweHSZ1RkNd49u3ahfKc0im9oGvXZn2D7MwQPvTt2TjEeys8Y5pmhVahseGp7ySHMNgO4dhMb33/B8H974Dmiy5WEpAgO8jQmVk5RGk6AQaqSjJIJ1FtntuYBQx7EE1RgmXjpV2JrwIHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U9IJavFSnLVyxgelY1q3iBNMxsZVKwWSfeObLsze7Gc=; b=HGgwyQSYx2PH/lgMWjO4HbAQoyItXJvpo+XkH3A6HV1Td2PUmokssCjDFkjsnjBiyA5zNdgORHsY421Wc/cR6oNLJvGuPfaJBOS4dbjkPzGGMZGC97THKnRBHZyQr66Kq0BF1kIOG8SQyOjBWPm1ymlRtUN25Vmu7pb4LrtycBQGq/zW+MWQma1b8M2FwAMOW7qwNWyPvzCon3UBKhQkyqls8Y6UQilV1Y2oII0Ly6BKBLHE6KSsLkAgapVSW33uLfNJVvyp3JjJ/p8OzQK/+xPZMPJLeSPie0qzS+eNq+7to9zA3276RCFASLUwvIxDDSOk7Sp1QHu2A+vxWXpxPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U9IJavFSnLVyxgelY1q3iBNMxsZVKwWSfeObLsze7Gc=; b=yYXYdIAc4FOA5a7hA3AL74ba+QFhbHpF4iQGggi0zpa2IVwGrSL5KxAp5AoLLrqFUTqjU79qiJUn4+qxKCPjXvyuyOnNg0WVPm3IQp9dOsbhaM3/lN0tMMMsSUiaDFPzVtWTR2UuOpweumhPHBuug4//DuZ8y20xOgkmlfLpKTM= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from PR3PR08MB5564.eurprd08.prod.outlook.com (2603:10a6:102:87::18) by PA4PR08MB6285.eurprd08.prod.outlook.com (2603:10a6:102:e0::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Tue, 3 Nov 2020 10:25:52 +0000 Received: from PR3PR08MB5564.eurprd08.prod.outlook.com ([fe80::2904:edcf:b299:f792]) by PR3PR08MB5564.eurprd08.prod.outlook.com ([fe80::2904:edcf:b299:f792%3]) with mapi id 15.20.3499.032; Tue, 3 Nov 2020 10:25:52 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH 0/4] aarch64: avoid mprotect(PROT_BTI|PROT_EXEC) [BZ #26831] Date: Tue, 3 Nov 2020 10:25:37 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: SN6PR2101CA0025.namprd21.prod.outlook.com (2603:10b6:805:106::35) To PR3PR08MB5564.eurprd08.prod.outlook.com (2603:10a6:102:87::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.54) by SN6PR2101CA0025.namprd21.prod.outlook.com (2603:10b6:805:106::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.6 via Frontend Transport; Tue, 3 Nov 2020 10:25:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 51ef471c-2703-4b7b-6dfe-08d87fe2df36 X-MS-TrafficTypeDiagnostic: PA4PR08MB6285:|DBBPR08MB4300: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Stsu0KlIb4lIVOOruG4jS/t9+9pc1OmBNb73BCLh7fhi7Eq5PJQRKF+kJfjIpfgkKldLCchS08mJH89qcjTCa94WZmJKYsoTQo4YM9atfd9kDqX4or4wsrgxzkMhMb15Vgo57AWo9SQU9jlXQhztf4+JiVgGgY0ZYTzBEalByDd/DSOowhbD1lc/puItWGJVsDwPyH1cI1q2pfWOJpiwSX5/1tWrO7Ef22XFKNj2n+g+OXBSFf0BvokqMmiQAZgTuZOZIzB70XO43zwO4iaIBjXPr3GPOLH3NEeSKy2I6SrXNJd+dZyx1VEhlRJs85Q8+jk/i7DZSN+e8/d3N7VVEo3zStlheFVdm8/RuuSlbNvNRVB05X+VmxnbGV9ImcGWcxyhBBgy5fkigVi9NBadCKfh8buFP/hzqgYiAwk/c7Q= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PR3PR08MB5564.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(39860400002)(136003)(396003)(366004)(6506007)(36756003)(186003)(54906003)(478600001)(8936002)(6916009)(52116002)(316002)(4326008)(16526019)(26005)(69590400008)(86362001)(5660300002)(2616005)(44832011)(7416002)(956004)(8676002)(66476007)(66556008)(6512007)(83380400001)(6486002)(2906002)(6666004)(66946007)(83133001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ZG0YhZU+otW5WO1ZgGeP4bqhUY0GXSksmxb9xYXof6TK25jFOavZyghJWuZ6wReEOVND03gBsMTpx20GXHnTGUKCblEBQEXg3waQNclQwWD7kg1pWbuN73oAuTYn1Um5FPNgjeWbiHDv2QBdMFTQk9Ats9GjwcEoqwukcmn5Zpc0VuUoGrooI4F/3hsFfjigrSP0eRbVRWoOFLXk4P1m4Lolq4l0an6stCFOvQZ4gcJgw0u4Ok5KcNqn0U0Zze7N3gofdU3p3cahfRHwqwAllZ9OzcWM71lh87pYiNxLTAu1dHhWKjDjMxiz0ElGb5GjVEj3YA1SLBuFxFOY7SKeqk894akYEWQaTA8l1JTXDJluYefX6ISDKBESqIQGYG/VBfHF+jODLt3+DAQQ7QOdycqwq9anjkgWH7oJSSryrNBZoYZ9I9AVKunvx/kQgYtj77EmQM7caDNLhZYmR4V9rtxqi8tCfT0kDy8TGlU8lnywohF5v9BBEy3YP8stsNwQYOGBzTXeJrFcsD4UU+S2xjjL7U33782oqTfscN6E6bI6aU2lTdlLQVNkJbSKVE2JpF+Xgl1fTFzTqKLsfbqdkZ7oPQsEoFsj0+XvQNapUkA76Kx7iRRXEomOY3YqJqF68laEI2I+8qpfnBfgl94EZg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6285 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ec11855b-163b-432a-ee29-08d87fe2d6e5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wqYZIXbMDRafKD+TIlm1Tudj3xDQsnF+zMbRHfJsul6hbJitBKf4eH6WBvTi7GklJ2kwUQqU4V7YXBytmDAfAaSmzyYnY8syLDkmgIpNAUmwkkG4v/gW3JP5Td6dZQI1InUAnUVGQLwTlImQvhXDEGNM3jl1NjWd9TZ4LCQSmQRfqDSdIBN3kduzUQI/HinBF0kdLrT+DRu7x7/NI3lK77Z3i+LF+Ps6xPGNLj2jQ1SOsIeiVGwggMIVrfvwJpcocX3p+p+zFmSI6jATtDG3kNeII1tRQ8pliqyN4ljLUZH4xp1Jrd3tnSJkVB3poEw25eMfljrr2DdOmkBP0P+e7noxPmkEjVU9YmlKrPx8Nxw48OnBtjen4J7c1Ms5Nf9rEsT68c2mxY3t5xxuaDNI+5Y6Gk4dza4MhIk7eKi9vXyWabKD3aclRlh6tt9O7yyXoogK9rcD2RN8zL18WBXsDA== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(396003)(136003)(39860400002)(346002)(376002)(46966005)(956004)(2616005)(6486002)(4326008)(70206006)(70586007)(336012)(107886003)(316002)(36756003)(54906003)(8936002)(44832011)(8676002)(6512007)(478600001)(34206002)(26005)(16526019)(36906005)(186003)(83380400001)(6506007)(2906002)(69590400008)(86362001)(82310400003)(356005)(82740400003)(47076004)(5660300002)(81166007)(6666004)(83133001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 10:26:05.6058 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 51ef471c-2703-4b7b-6dfe-08d87fe2df36 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4300 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201103_052615_537323_5240E29B X-CRM114-Status: GOOD ( 12.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Florian Weimer , Kees Cook , kernel-hardening@lists.openwall.com, Salvatore Mesoraca , Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Jeremy Linton , Mark Brown , Lennart Poettering , linux-hardening@vger.kernel.org, Topi Miettinen , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Re-mmap executable segments instead of mprotecting them in case mprotect is seccomp filtered. For the kernel mapped main executable we don't have the fd for re-mmap so linux needs to be updated to add BTI. (In the presence of seccomp filters for mprotect(PROT_EXEC) the libc cannot change BTI protection at runtime based on user space policy so it is better if the kernel maps BTI compatible binaries with PROT_BTI by default.) Szabolcs Nagy (4): elf: Pass the fd to note processing [BZ #26831] elf: Move note processing after l_phdr is updated [BZ #26831] aarch64: Use mmap to add PROT_BTI instead of mprotect [BZ #26831] aarch64: Remove the bti link_map field [BZ #26831] elf/dl-load.c | 38 ++++++++++++++++--------------- elf/rtld.c | 4 ++-- sysdeps/aarch64/dl-bti.c | 46 ++++++++++++++++++++------------------ sysdeps/aarch64/dl-prop.h | 17 +++++++------- sysdeps/aarch64/linkmap.h | 1 - sysdeps/generic/dl-prop.h | 6 ++--- sysdeps/generic/ldsodefs.h | 5 +++-- sysdeps/x86/dl-prop.h | 6 ++--- 8 files changed, 64 insertions(+), 59 deletions(-)