Message ID | 20221026150457.36957-3-joey.gouly@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp328645wru; Wed, 26 Oct 2022 08:18:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Wzc1woq0F4IDQEZ6QEmzrHuoZu3mCWmUpaHYq43EuLLzsPVsn20/rl0Ckl3+CdPPvnaW2 X-Received: by 2002:a17:906:cc0f:b0:7a1:6786:f55 with SMTP id ml15-20020a170906cc0f00b007a167860f55mr19802854ejb.359.1666797527968; Wed, 26 Oct 2022 08:18:47 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1666797527; cv=pass; d=google.com; s=arc-20160816; b=csYXzr1xtK+dV0mhKSavbnP7E9iDdPOjJigxlcR6qbyN0BVkAFlHOsdGfnECL/4CcJ wA84rsmjsMgfOZrN+DkShgCEtWjPxGzMwbfJPG24x4Z65P23oMlKSi5pve6C0aRh8foI jrQKqtFVWg3RC9ri6TbYsz/zALEySOwpA/HG579F6EH+Q44g44vzx/S++3BrIeR9fJYt 5KNvJvcbo2OXMDxRHn7QQ1FTUaYzCLUC2Bwu3wQJzG8l+OBci5/Q6BJv+USK/gD4Tyf8 l3/2RYD1r1r/ceLq0A2wcWtUlvpHG5KUU8k2A5Alji9qH04fxu6QQOLqONDCJp9sZPSS 0i5Q== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:nodisclaimer:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=Md2eIw/qYyLb6WObHWIWKkMCdMsgVJSwb+YL6Upe9Nw=; b=OkdvIx25yR6z5RJ9rdgcP9DzAvjgKKQCnkeo2XX+7YeoY982kjwQjyXINxfUKrsJm6 UvCBUHQtdOcnmiwtdtOHN5jXpLxvnTWXXYsbR+nC7Fz3cNFCs3C0RWXT27QBl6IvKSwh 3pK9m54y5DohGS0SCxL2yXnYTMQSZbM3k8N1IltnaIPkHH2KDqqPMxK6NlSyIKW/DyiP EDsQlrBGMvlNWJm95c1M36QYsOD+y17SnWF2Q7Mf+hjs+VuEvUDY5siQ+yTUaligrzyf +Xs8E19Vp9R3JmfJt0ETr8rCYg02vXu9WEL8PSGLsC2djIFsbPWB0ztFNzFcItlS81iF ovEg== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=gmO25wVa; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=gmO25wVa; arc=pass (i=2 spf=pass spfdomain=arm.com dkim=pass dkdomain=armh.onmicrosoft.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n12-20020aa7c68c000000b00459101ecc5esi5100022edq.468.2022.10.26.08.18.20; Wed, 26 Oct 2022 08:18:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=gmO25wVa; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=gmO25wVa; arc=pass (i=2 spf=pass spfdomain=arm.com dkim=pass dkdomain=armh.onmicrosoft.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234463AbiJZPIz (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Wed, 26 Oct 2022 11:08:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234355AbiJZPIw (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 26 Oct 2022 11:08:52 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2043.outbound.protection.outlook.com [40.107.20.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FD0E122BE1 for <linux-kernel@vger.kernel.org>; Wed, 26 Oct 2022 08:08:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Ycp3xYjdTUt036PVyj3/YDREHGXVSGXrz7Fodnc9X+pJ1nMkeXjObrEAVgT1VisJLQy2OjjAJkvgeZXyifPcdujpZeQZJkcCkAgkshF0Ac/A7mmCCl8UMUrK8ZTkA3JSlyc5nDMymn31Xov1TWTdt02P2KQq4EJSpaAvVA4Bc29zcZKfvWR4Lay4naoq2sWAgQR1tyTAV6e6h1IwokjiVdpIaMEqX6uOWeBoIeRkIuYAEpQwFzR6sy5f1vY1bjYEMPeTGN4+9QOZSaF1mQwHPRPmf/CmJOK/Rh1IcfX3i76+5r/8WG0JmRD9w0LGkfDlRoVKRx5JHXUgZ9kO+L5bcQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Md2eIw/qYyLb6WObHWIWKkMCdMsgVJSwb+YL6Upe9Nw=; b=FMzGEPMb+Q825QfwshVnhk3l+e7Ao6C6IJASG3vrpmtGd4464JYj1ymnNMY5eE50YkuWqE9PEZ40HxeT2NXJkRBgAEU9RUH8KNlD4gonG6c20ZVuRz0w21DwtUIu8fiSy+6xi8orAki5ywSPtv9Mbe1ReNzWmQtXq50EXsENNpk577c5HwAURk3F20ReX6MMshMRX8ox0hmxOmYm2Ltj54pHedLgMuHa1NZqVmyB2JhAzLixGi/OEBXN24wINbhiF6nGtBJKbjCw+J8fZ8Pgc4po7ydnz5Vg+DAbstb/G+kqvMRJGwycoqa4cUSXXh/X5GKCI57Rz2CLe/0yq/qKDQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com]) 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=Md2eIw/qYyLb6WObHWIWKkMCdMsgVJSwb+YL6Upe9Nw=; b=gmO25wVav1/taN5Db1F/nBf1QL4tpJUiaOaPxD/0idMSd0YDbd3bB8pptW63IRr9TmThEjPOg+7+F/WuLZPbw5NyJWzWON/GVMinv8kM7dmnqApCzSkfwNnzWWZZ4hIRYGsSOgpMzvFsly4hXOofPvmBF3moV9zTAEAa8/moU9g= Received: from DB6P193CA0003.EURP193.PROD.OUTLOOK.COM (2603:10a6:6:29::13) by DU2PR08MB10303.eurprd08.prod.outlook.com (2603:10a6:10:491::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Wed, 26 Oct 2022 15:08:34 +0000 Received: from DBAEUR03FT028.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:29:cafe::be) by DB6P193CA0003.outlook.office365.com (2603:10a6:6:29::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.28 via Frontend Transport; Wed, 26 Oct 2022 15:08:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;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; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT028.mail.protection.outlook.com (100.127.142.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20 via Frontend Transport; Wed, 26 Oct 2022 15:08:34 +0000 Received: ("Tessian outbound 2ff13c8f2c05:v130"); Wed, 26 Oct 2022 15:08:34 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b53391cd8ab55964 X-CR-MTA-TID: 64aa7808 Received: from cbae66d2aa36.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B8046C14-437F-41FF-8087-0946A0586D4C.1; Wed, 26 Oct 2022 15:05:22 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id cbae66d2aa36.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 26 Oct 2022 15:05:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZkX9V87TVMr6BEvHgsJ7bMISzqAtEQBdCxCP1BRKLY5FRfL/fLcdbUzACSwaMV8X4rn9FRJu/zfAgskCHs7JcUa6gaBcMa0OdCpFVmWpRx5zusMCy0HG+DhcTZDIg6aIX/LZ/5CZindckNuxaZFTfXIFk6DwFsay2axLp0hU+8oDPeajMWSTkOVCfe7kc9OvbkeexIw3v8aiALwlcQVkiw5aZvGHVqfEBbTygDfr+7NMizHvBbFoAjeaa0TozWY0znqzTaVOjgHoGGOss4CsXwogqDrxN4OeQdjcMpbkghUPU6RS6F7X+5Yo4/F+fBmwNqpjJvTOHPj1lJjEi8acuA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Md2eIw/qYyLb6WObHWIWKkMCdMsgVJSwb+YL6Upe9Nw=; b=fmw5/kMPoZb9v+vG9Ed+S5AYvRzQsE6Dsmm1EogIwR8r2WDEymazlwsoY4apwd8MPixWW1TJrh1Oorh3Jpn3ZQ9JTl1Nwx8MLiZh3ttd98a00N5psJMi77BnbQdzEb/ZooORcq1+YTFWc59MDOLyh3oCuk11KRtEqwFjQu7B2yLf0QRypIHg/NneRXEO3FdDCFJe3njkmF+psQfXjwSefVtVV2Zp5LtZKB7W3xf9PikCdyVZWjNJTqTa1JrnMJuXDdSorXbhJzpMyqnAhRPgdHqJDOkN7XIrXOxmykA75bjD5rFdEL/AdjcgQVR6WzDiulQnX8CgQeh8Vg9qnZSbsg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux-foundation.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); 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=Md2eIw/qYyLb6WObHWIWKkMCdMsgVJSwb+YL6Upe9Nw=; b=gmO25wVav1/taN5Db1F/nBf1QL4tpJUiaOaPxD/0idMSd0YDbd3bB8pptW63IRr9TmThEjPOg+7+F/WuLZPbw5NyJWzWON/GVMinv8kM7dmnqApCzSkfwNnzWWZZ4hIRYGsSOgpMzvFsly4hXOofPvmBF3moV9zTAEAa8/moU9g= Received: from DB6PR0601CA0002.eurprd06.prod.outlook.com (2603:10a6:4:7b::12) by AS8PR08MB6552.eurprd08.prod.outlook.com (2603:10a6:20b:31c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.28; Wed, 26 Oct 2022 15:05:19 +0000 Received: from DBAEUR03FT057.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:7b:cafe::91) by DB6PR0601CA0002.outlook.office365.com (2603:10a6:4:7b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23 via Frontend Transport; Wed, 26 Oct 2022 15:05:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT057.mail.protection.outlook.com (100.127.142.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5709.10 via Frontend Transport; Wed, 26 Oct 2022 15:05:19 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Wed, 26 Oct 2022 15:05:16 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Wed, 26 Oct 2022 15:05:16 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Wed, 26 Oct 2022 15:05:15 +0000 From: Joey Gouly <joey.gouly@arm.com> To: Catalin Marinas <catalin.marinas@arm.com>, Andrew Morton <akpm@linux-foundation.org>, Lennart Poettering <lennart@poettering.net>, =?utf-8?q?Zbigniew_J=C4=99drze?= =?utf-8?q?jewski-Szmek?= <zbyszek@in.waw.pl> CC: Alexander Viro <viro@zeniv.linux.org.uk>, Kees Cook <keescook@chromium.org>, Szabolcs Nagy <szabolcs.nagy@arm.com>, Mark Brown <broonie@kernel.org>, Jeremy Linton <jeremy.linton@arm.com>, Topi Miettinen <toiwoton@gmail.com>, <linux-mm@kvack.org>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>, <linux-abi-devel@lists.sourceforge.net>, <nd@arm.com>, <joey.gouly@arm.com>, <shuah@kernel.org> Subject: [PATCH v1 2/2] kselftest: vm: add tests for memory-deny-write-execute Date: Wed, 26 Oct 2022 16:04:57 +0100 Message-ID: <20221026150457.36957-3-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221026150457.36957-1-joey.gouly@arm.com> References: <20221026150457.36957-1-joey.gouly@arm.com> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT057:EE_|AS8PR08MB6552:EE_|DBAEUR03FT028:EE_|DU2PR08MB10303:EE_ X-MS-Office365-Filtering-Correlation-Id: 9e3c2767-3218-400f-35da-08dab763f3d1 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: QwUsFmYxus8FCwgw7iqHDmsu585q6R/EEuS7Le6LjGD7MNIY0l77EukW35nVVetZuhWc8+MgFHZFBkAzAAJTx+LVTxPU8dmbv1UCtNjmQvF9NUZTbR6w9YpjHMB8qUS/xhTeyWns1Piq5cIx91spkFwo8wOI9uPc5NnWHQ+Qt24CzoX1qtD3RvOLSHkdyyFOTnp6VIggOsvA39VgsLFdpP8XCH6S+VZr0IGjz8Hi1rQ84z/jVN6mUpPVzD0jlleX0+rXvsSd+zkJgPQuvyM5tWKpmaPhovioliQaxSAh6HJAl4jNDCm6A9Qy2qhuXfCtF51WSSNIU4TR7JRpf1OcXkYgqc3ShTcR0ZDX+QlhL6PY/CpO51k7hKXkcCHsRvCk0/5IJCY0AHoTjNJJKZCk8LfNFE/KJyxeg+qiIMLxCx0QSGP9kuLPpqrV1Q33Mliz7A/YqpWeRejvWSW/X7MQUqZLF8KLbxkKei/zL1asOi2pznH0q+ozOWU11iJzhWaS4Owfv29YtTQXYQBg3iR+xaJkIQ5vOTcD0r0KsuclpDCnbd/inz7xPgEMm2Jc7eGnB8lQQSg7SQyQLTZUM9ZUdUcyWsdS5NRV6tSDUsY6qpGiINP0dg4LYvygQ9WgMmVKqSWHC82NM3hqZDQhliso4sR71ylNfjpc4fW04g7eBDj51aFZP9Afdc/2Wzj0YVIO7vNCEqPecuogXf0y6WAujPDVZugBTci019ySZHa7zh2FuZZDQo7/OUfIIVP3ZYUqHKIuiudTrckDbnoMOEpRydS5WgmFXq4aA3fCduH7o+V9MyxLvRR+JE9io3g+NZcT X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(376002)(396003)(346002)(451199015)(36840700001)(46966006)(40470700004)(82740400003)(36860700001)(86362001)(81166007)(356005)(110136005)(54906003)(316002)(40480700001)(83380400001)(47076005)(70586007)(2906002)(70206006)(5660300002)(478600001)(8936002)(8676002)(44832011)(426003)(41300700001)(4326008)(7416002)(186003)(6666004)(336012)(1076003)(7696005)(40460700003)(2616005)(26005)(82310400005)(36756003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6552 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT028.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: bb267f41-e2a6-415a-b2af-08dab7637f9a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: htz8CXt+O2fm2bwC6EB3mkho0ZgMyWeTEGbXvfX3/uPmwdk48jJ1e5C17FaiPJq7ARTALk75lnfVBvCReNkD/OIEn+PJHMCgSR7y54MFgmh4BKL/kSaUp3Kfg62BWFltzbuqQw0QCA/updi8XUGNjp+BqRKbYmBbQLpVTI3VyJdqXJG7pwmLhlGCy0SnxKRvsw7rOH0L4/JeWhr4jjbvLJf2iHmYk2/UBr7FfLBwCwCq04euTVDrubS+yCFjDWUBk9wjvGE6Y7Ap2bNySeVibHGv3kqTpDgJrJSxqSGWzuMb4Zp7ivIAOPZ1OFZYgNVw5cSv4YPlhWMG1Tn+w3WkrT0M5Ulq+M8j4aOzhUwpfo6btlFejJPEAqMiCDp13lf0AmVAlAN1BD10GJEqKrqVIcXEaBRs9tCe48IfkEFonGo2C/ahZ9KavT5hf6UTEDQrBsU5G8Iq0Dflj0vLK7swlG9chWecDD3AdNxjGzi8kvEJsXYm+v2NX82y2fI+FNVNjzDERCja2eAKrGEmi2TEUthmeU1LdAny1rHyBmtQXDc4sncmv2hDQF5RwyFe9QXFAcWiOHtAsyUpcghx8pniFEn2468aGwNIPEuVG2hThxWMc8vFj0PD64O8hillCqKdSj7+EpYhaLKTTaWUzgXDBf6ImIjFCEe9K6UPauQqa9WiZGaLpGrf2+IpKxDm9b1VaoTDLC9PnOsGyLgfZ3BVLiCzUc2kS8Gbgm/SnXC2SJTUYa0JyFVxrN6rruLXn3D9ZEwmEHHseiehhkdlNU3Jrg== 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:(13230022)(4636009)(346002)(376002)(39860400002)(136003)(396003)(451199015)(40470700004)(36840700001)(46966006)(70206006)(54906003)(5660300002)(36756003)(110136005)(44832011)(4326008)(86362001)(8676002)(41300700001)(26005)(70586007)(316002)(8936002)(2906002)(40460700003)(47076005)(36860700001)(83380400001)(426003)(81166007)(186003)(40480700001)(2616005)(336012)(1076003)(6666004)(82310400005)(478600001)(82740400003)(7696005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 15:08:34.6566 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9e3c2767-3218-400f-35da-08dab763f3d1 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: DBAEUR03FT028.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR08MB10303 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_NONE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747763884386414012?= X-GMAIL-MSGID: =?utf-8?q?1747763884386414012?= |
Series |
mm: In-kernel support for memory-deny-write-execute (MDWE)
|
|
Commit Message
Joey Gouly
Oct. 26, 2022, 3:04 p.m. UTC
Add some tests to cover the new PR_SET_MDWE prctl.
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Cc: Shuah Khan <shuah@kernel.org>
---
tools/testing/selftests/vm/mdwe_test.c | 194 +++++++++++++++++++++++++
1 file changed, 194 insertions(+)
create mode 100644 tools/testing/selftests/vm/mdwe_test.c
Comments
On Wed, Oct 26, 2022 at 04:04:57PM +0100, Joey Gouly wrote: > Add some tests to cover the new PR_SET_MDWE prctl. Some comments below but they're all stylistic and let's not make perfect be the enemy of the good here so Reviewed-by: Mark Brown <broonie@kernel.org> and we can iterate later rather than blocking anything on the testcase. > +#ifdef __aarch64__ > +#define PROT_BTI 0x10 /* BTI guarded page */ > +#endif We should get this from the kernel headers shouldn't we? We generally rely on things getting pulled in from there rather than locally defining. > +#define TEST1 "mmap(PROT_WRITE | PROT_EXEC)\n" > +#define TEST2 "mmap(PROT_WRITE); mprotect(PROT_EXEC)\n" > +#define TEST3 "mmap(PROT_EXEC); mprotect(PROT_EXEC | PROT_READ)\n" > +#define TEST4 "mmap(PROT_EXEC); mprotect(PROT_EXEC | PROT_BTI)\n" > +int test1(int mdwe_enabled) > +{ It feels like we could usefully make an array of struct test { int (*run)(bool mdwe_enabled); char *name; } then we'd need fewer ifdefs, things could be more usefully named and it'd be a bit easier to add new cases. > +#ifdef __aarch64__ > + ksft_set_plan(12); > +#else > + ksft_set_plan(9); > +#endif That'd just be ksft_test_plan(3 * ARRAY_SIZE(tests). > + // First run the tests without MDWE > + test_result(test1(0), TEST1); > + test_result(test2(0), TEST2); > + test_result(test3(0), TEST3); > +#ifdef __aarch64__ > + test_result(test4(0), TEST4); > +#endif and these calls to the tests would all be iterating over the array.
On Wed, Oct 26, 2022 at 04:04:57PM +0100, Joey Gouly wrote:
> +#include "../kselftest.h"
I recommend using kselftest_harness.h instead; it provides much of the
infrastructure that is open-coded here. But yes, testing is good; thank
you! :)
Here's an alternative rewritten to use kselftest_harness.h, with tests for the prctl() flags, and the missed Makefile addition. This should be much easier to add more variants and tests to, I hope. -Kees From bc442a99ebd9852bfaa7444b521bd55fdbb4d369 Mon Sep 17 00:00:00 2001 From: Kees Cook <keescook@chromium.org> Date: Fri, 28 Oct 2022 13:10:45 -0700 Subject: [PATCH] selftests/vm: add tests for memory-deny-write-execute Add tests for new prctl() commands, including flag values. Add tests for new denials based on PROT_EXEC across mmap() and mprotect() with MDWE. Co-developed-by: Joey Gouly <joey.gouly@arm.com> Signed-off-by: Joey Gouly <joey.gouly@arm.com> Signed-off-by: Kees Cook <keescook@chromium.org> --- tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/mdwe_test.c | 201 +++++++++++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100644 tools/testing/selftests/vm/mdwe_test.c diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index 163c2fde3cb3..8dd4d4910fa5 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -52,6 +52,7 @@ TEST_GEN_FILES += userfaultfd TEST_GEN_PROGS += soft-dirty TEST_GEN_PROGS += split_huge_page_test TEST_GEN_FILES += ksm_tests +TEST_GEN_PROGS += mdwe_test ifeq ($(MACHINE),x86_64) CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_32bit_program.c -m32) diff --git a/tools/testing/selftests/vm/mdwe_test.c b/tools/testing/selftests/vm/mdwe_test.c new file mode 100644 index 000000000000..d6f6b751bcd6 --- /dev/null +++ b/tools/testing/selftests/vm/mdwe_test.c @@ -0,0 +1,201 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifdef __aarch64__ +#include <asm/hwcap.h> +#endif +#include <stdio.h> +#include <stdlib.h> +#include <sys/auxv.h> +#include <sys/mman.h> +#include <sys/prctl.h> +#include <sys/wait.h> +#include <unistd.h> + +#include <linux/prctl.h> + +#include "../kselftest_harness.h" + +#define PR_SET_MDWE 65 +# define PR_MDWE_FLAG_MMAP 1 + +#define PR_GET_MDWE 66 + +#ifdef __aarch64__ +# define PROT_BTI 0x10 /* BTI guarded page */ +#else +# define PROT_BTI 0 +#endif + +TEST(prctl_flags) +{ + EXPECT_LT(prctl(PR_SET_MDWE, 7, 0, 0, 0), 0); + EXPECT_LT(prctl(PR_SET_MDWE, 0, 7, 0, 0), 0); + EXPECT_LT(prctl(PR_SET_MDWE, 0, 0, 7, 0), 0); + EXPECT_LT(prctl(PR_SET_MDWE, 0, 0, 0, 7), 0); + + EXPECT_LT(prctl(PR_GET_MDWE, 7, 0, 0, 0), 0); + EXPECT_LT(prctl(PR_GET_MDWE, 0, 7, 0, 0), 0); + EXPECT_LT(prctl(PR_GET_MDWE, 0, 0, 7, 0), 0); + EXPECT_LT(prctl(PR_GET_MDWE, 0, 0, 0, 7), 0); +} + +FIXTURE(mdwe) +{ + void *p; + int flags; + size_t size; + pid_t pid; +}; + +FIXTURE_VARIANT(mdwe) +{ + bool enabled; + bool forked; +}; + +FIXTURE_VARIANT_ADD(mdwe, stock) +{ + .enabled = false, + .forked = false, +}; + +FIXTURE_VARIANT_ADD(mdwe, enabled) +{ + .enabled = true, + .forked = false, +}; + +FIXTURE_VARIANT_ADD(mdwe, forked) +{ + .enabled = true, + .forked = true, +}; + +FIXTURE_SETUP(mdwe) +{ + int ret, status; + + self->p = NULL; + self->flags = MAP_SHARED | MAP_ANONYMOUS; + self->size = getpagesize(); + + if (!variant->enabled) + return; + + ret = prctl(PR_SET_MDWE, PR_MDWE_FLAG_MMAP, 0, 0, 0); + ASSERT_EQ(ret, 0) { + TH_LOG("PR_SET_MDWE failed or unsupported"); + } + + ret = prctl(PR_GET_MDWE, 0, 0, 0, 0); + ASSERT_EQ(ret, 1); + + if (variant->forked) { + self->pid = fork(); + ASSERT_GE(self->pid, 0) { + TH_LOG("fork failed\n"); + } + + if (self->pid > 0) { + ret = waitpid(self->pid, &status, 0); + ASSERT_TRUE(WIFEXITED(status)); + exit(WEXITSTATUS(status)); + } + } +} + +FIXTURE_TEARDOWN(mdwe) +{ + if (self->p && self->p != MAP_FAILED) + munmap(self->p, self->size); +} + +TEST_F(mdwe, mmap_READ_EXEC) +{ + self->p = mmap(NULL, self->size, PROT_READ | PROT_EXEC, self->flags, 0, 0); + EXPECT_NE(self->p, MAP_FAILED); +} + +TEST_F(mdwe, mmap_WRITE_EXEC) +{ + self->p = mmap(NULL, self->size, PROT_WRITE | PROT_EXEC, self->flags, 0, 0); + if (variant->enabled) { + EXPECT_EQ(self->p, MAP_FAILED); + } else { + EXPECT_NE(self->p, MAP_FAILED); + } +} + +TEST_F(mdwe, mprotect_stay_EXEC) +{ + int ret; + + self->p = mmap(NULL, self->size, PROT_READ | PROT_EXEC, self->flags, 0, 0); + ASSERT_NE(self->p, MAP_FAILED); + + ret = mprotect(self->p, self->size, PROT_READ | PROT_EXEC); + EXPECT_EQ(ret, 0); +} + +TEST_F(mdwe, mprotect_add_EXEC) +{ + int ret; + + self->p = mmap(NULL, self->size, PROT_READ, self->flags, 0, 0); + ASSERT_NE(self->p, MAP_FAILED); + + ret = mprotect(self->p, self->size, PROT_READ | PROT_EXEC); + if (variant->enabled) { + EXPECT_LT(ret, 0); + } else { + EXPECT_EQ(ret, 0); + } +} + +TEST_F(mdwe, mprotect_WRITE_EXEC) +{ + int ret; + + self->p = mmap(NULL, self->size, PROT_WRITE, self->flags, 0, 0); + ASSERT_NE(self->p, MAP_FAILED); + + ret = mprotect(self->p, self->size, PROT_WRITE | PROT_EXEC); + if (variant->enabled) { + EXPECT_LT(ret, 0); + } else { + EXPECT_EQ(ret, 0); + } +} + +TEST_F(mdwe, mmap_FIXED) +{ + void *p; + + self->p = mmap(NULL, self->size, PROT_READ, self->flags, 0, 0); + ASSERT_NE(self->p, MAP_FAILED); + + p = mmap(self->p, self->size, PROT_READ | PROT_EXEC, + self->flags | MAP_FIXED, 0, 0); + if (variant->enabled) { + EXPECT_EQ(p, MAP_FAILED); + } else { + EXPECT_EQ(p, self->p); + } +} + +TEST_F(mdwe, arm64_BTI) +{ + int ret; + +#ifdef __aarch64__ + if (!(getauxval(AT_HWCAP2) & HWCAP2_BTI)) +#endif + SKIP(return, "HWCAP2_BTI not supported"); + + self->p = mmap(NULL, self->size, PROT_EXEC, self->flags, 0, 0); + ASSERT_NE(self->p, MAP_FAILED); + + ret = mprotect(self->p, self->size, PROT_EXEC | PROT_BTI); + EXPECT_EQ(ret, 0); +} + +TEST_HARNESS_MAIN
On Wed, Oct 26, 2022 at 04:04:57PM +0100, Joey Gouly wrote: > [...] > +# define PR_MDWE_FLAG_MMAP 1 > [...] > + // Enable MDWE and then run the tests again. > + ret = prctl(PR_SET_MDWE, PR_MDWE_FLAG_MMAP, 0, 0, 0); > + if (ret < 0) { > + ksft_print_msg("PR_SET_MDWE failed or unsupported!\n"); > + goto exit; > + } > + > + ret = prctl(PR_GET_MDWE, PR_MDWE_FLAG_MMAP, 0, 0, 0); > + if (ret == 0) > + ksft_exit_fail_msg("PR_GET_MDWE failed!"); This flag (PR_MDWE_FLAG_MMAP), while defined in uapi, wasn't actually being used in the proposed prctl() api. :)
The 10/28/2022 13:16, Kees Cook wrote: > +++ b/tools/testing/selftests/vm/mdwe_test.c > @@ -0,0 +1,201 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#ifdef __aarch64__ > +#include <asm/hwcap.h> > +#endif > +#include <stdio.h> > +#include <stdlib.h> > +#include <sys/auxv.h> > +#include <sys/mman.h> > +#include <sys/prctl.h> > +#include <sys/wait.h> > +#include <unistd.h> > + > +#include <linux/prctl.h> > + > +#include "../kselftest_harness.h" > + > +#define PR_SET_MDWE 65 > +# define PR_MDWE_FLAG_MMAP 1 > + > +#define PR_GET_MDWE 66 > + > +#ifdef __aarch64__ > +# define PROT_BTI 0x10 /* BTI guarded page */ > +#else > +# define PROT_BTI 0 > +#endif > + > +TEST(prctl_flags) > +{ > + EXPECT_LT(prctl(PR_SET_MDWE, 7, 0, 0, 0), 0); > + EXPECT_LT(prctl(PR_SET_MDWE, 0, 7, 0, 0), 0); > + EXPECT_LT(prctl(PR_SET_MDWE, 0, 0, 7, 0), 0); > + EXPECT_LT(prctl(PR_SET_MDWE, 0, 0, 0, 7), 0); note that prctl is declared as int prctl(int, ...); and all 4 arguments are documented to be unsigned long in the linux man pages (even though some are pointers: this is already a problem for the libc as it does not know if it should use va_arg(ap, unsigned long) or va_arg(ap, void *), in practice the call abi rules are the same for those on linux, so either works unless the compiler deliberately breaks the code due to the type mismatch ub). passing an int where an unsigned long is needed is wrong: it breaks va_arg rules on the c language level (posix rules too) but more importantly it breaks abi rules: on most LP64 abis it is not required to be signextended so arbitrary top 32bits may be passed down. so e.g. prctl(option, 0, 0, 0, 0); should be written as prctl(option, 0L, 0L, 0L, 0L); or similar (int signedness does not matter according to c rules), otherwise non-zero top bits may be passed that the kernel has to ignore, which it currently does not always do. ideally the kernel updated all the prctl arg macros to have type long or unsigned long. or explicitly masked out the top bits when it only uses an int. see my related rant at https://lore.kernel.org/linux-api/Y1%2FDS6uoWP7OSkmd@arm.com/
Hi, On Fri, Oct 28, 2022 at 06:03:18PM +0100, Mark Brown wrote: > On Wed, Oct 26, 2022 at 04:04:57PM +0100, Joey Gouly wrote: > > > Add some tests to cover the new PR_SET_MDWE prctl. > > Some comments below but they're all stylistic and let's not make perfect > be the enemy of the good here so > > Reviewed-by: Mark Brown <broonie@kernel.org> Thanks for the review, however I won't keep your R-b tag because I'm going to move forward with Kees' approach from: https://lore.kernel.org/linux-arm-kernel/202210281314.C5D3414722@keescook/T/#m45ac9de6c205b560d072a65e4e67e2a7ee363588 Thanks to Kees for rewriting that. > > and we can iterate later rather than blocking anything on the testcase. > > > +#ifdef __aarch64__ > > +#define PROT_BTI 0x10 /* BTI guarded page */ > > +#endif > > We should get this from the kernel headers shouldn't we? We generally > rely on things getting pulled in from there rather than locally > defining. I believe the mman.h included is from the toolchain, not the kernel's uapi headers. The toolchain I was using didn't have PROT_BTI defined in its mman.h > > > +#define TEST1 "mmap(PROT_WRITE | PROT_EXEC)\n" > > +#define TEST2 "mmap(PROT_WRITE); mprotect(PROT_EXEC)\n" > > +#define TEST3 "mmap(PROT_EXEC); mprotect(PROT_EXEC | PROT_READ)\n" > > +#define TEST4 "mmap(PROT_EXEC); mprotect(PROT_EXEC | PROT_BTI)\n" > > > +int test1(int mdwe_enabled) > > +{ > > It feels like we could usefully make an array of > > struct test { > int (*run)(bool mdwe_enabled); > char *name; > } > > then we'd need fewer ifdefs, things could be more usefully named and > it'd be a bit easier to add new cases. > > > +#ifdef __aarch64__ > > + ksft_set_plan(12); > > +#else > > + ksft_set_plan(9); > > +#endif > > That'd just be ksft_test_plan(3 * ARRAY_SIZE(tests). > > > + // First run the tests without MDWE > > + test_result(test1(0), TEST1); > > + test_result(test2(0), TEST2); > > + test_result(test3(0), TEST3); > > +#ifdef __aarch64__ > > + test_result(test4(0), TEST4); > > +#endif > > and these calls to the tests would all be iterating over the array. These comments are solved by the kselftest_harness approach that Kees suggested. Thanks, Joey
On Tue, Nov 08, 2022 at 05:33:03PM +0000, Joey Gouly wrote: > On Fri, Oct 28, 2022 at 06:03:18PM +0100, Mark Brown wrote: > > On Wed, Oct 26, 2022 at 04:04:57PM +0100, Joey Gouly wrote: > > > +#ifdef __aarch64__ > > > +#define PROT_BTI 0x10 /* BTI guarded page */ > > > +#endif > > We should get this from the kernel headers shouldn't we? We generally > > rely on things getting pulled in from there rather than locally > > defining. > I believe the mman.h included is from the toolchain, not the kernel's uapi headers. > The toolchain I was using didn't have PROT_BTI defined in its mman.h I'd expect that whatever we're doing in the build process ought to be overriding the default headers provided by the toolchain, that's kind of the point here...
diff --git a/tools/testing/selftests/vm/mdwe_test.c b/tools/testing/selftests/vm/mdwe_test.c new file mode 100644 index 000000000000..67f3fc06d069 --- /dev/null +++ b/tools/testing/selftests/vm/mdwe_test.c @@ -0,0 +1,194 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <asm/hwcap.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/auxv.h> +#include <sys/mman.h> +#include <sys/prctl.h> +#include <sys/wait.h> +#include <unistd.h> + +#include <linux/prctl.h> + +#include "../kselftest.h" + +#define PR_SET_MDWE 65 +# define PR_MDWE_FLAG_MMAP 1 + +#define PR_GET_MDWE 66 + +#ifdef __aarch64__ +#define PROT_BTI 0x10 /* BTI guarded page */ +#endif + +#define TEST1 "mmap(PROT_WRITE | PROT_EXEC)\n" +#define TEST2 "mmap(PROT_WRITE); mprotect(PROT_EXEC)\n" +#define TEST3 "mmap(PROT_EXEC); mprotect(PROT_EXEC | PROT_READ)\n" +#define TEST4 "mmap(PROT_EXEC); mprotect(PROT_EXEC | PROT_BTI)\n" + +int fork_test(int (*func)(int)) +{ + pid_t pid; + int status; + + pid = fork(); + if (pid < 0) { + printf("fork failed\n"); + return KSFT_FAIL; + } + + if (pid == 0) + exit(func(1)); + + waitpid(pid, &status, 0); + + if (WIFEXITED(status)) + return WEXITSTATUS(status); + + return 0; +} + +static inline void test_result(int err, const char *msg) +{ + switch (err) { + case KSFT_PASS: + ksft_test_result_pass(msg); + break; + case KSFT_FAIL: + ksft_test_result_fail(msg); + break; + case KSFT_SKIP: + ksft_test_result_skip(msg); + break; + default: + ksft_test_result_error("Unknown return code %d from %s", + err, msg); + break; + } +} + +int test1(int mdwe_enabled) +{ + void *p; + + int size = getpagesize(); + int mmap_flags = MAP_SHARED | MAP_ANONYMOUS; + + p = mmap(0, size, PROT_WRITE | PROT_EXEC, mmap_flags, 0, 0); + + if (mdwe_enabled) + return p == MAP_FAILED ? KSFT_PASS : KSFT_FAIL; + else + return p != MAP_FAILED ? KSFT_PASS : KSFT_FAIL; +} + +int test2(int mdwe_enabled) +{ + void *p; + int ret; + + int size = getpagesize(); + int mmap_flags = MAP_SHARED | MAP_ANONYMOUS; + + p = mmap(0, size, PROT_WRITE, mmap_flags, 0, 0); + if (p == MAP_FAILED) + return 0; + ret = mprotect(p, size, PROT_EXEC); + + if (mdwe_enabled) + return ret < 0 ? KSFT_PASS : KSFT_FAIL; + else + return ret == 0 ? KSFT_PASS : KSFT_FAIL; +} + +int test3(int mdwe_enabled) +{ + void *p; + int ret; + + int size = getpagesize(); + int mmap_flags = MAP_SHARED | MAP_ANONYMOUS; + + p = mmap(0, size, PROT_EXEC, mmap_flags, 0, 0); + if (p == MAP_FAILED) + return 0; + + ret = mprotect(p, size, PROT_EXEC | PROT_READ); + + return ret == 0 ? KSFT_PASS : KSFT_FAIL; +} + +#ifdef __aarch64__ +int test4(int mdwe_enabled) +{ + void *p; + int ret; + + int size = getpagesize(); + int mmap_flags = MAP_SHARED | MAP_ANONYMOUS; + + if (!(getauxval(AT_HWCAP2) & HWCAP2_BTI)) + return KSFT_SKIP; + + p = mmap(0, size, PROT_EXEC, mmap_flags, 0, 0); + if (p == MAP_FAILED) + return KSFT_FAIL; + + ret = mprotect(p, size, PROT_EXEC | PROT_BTI); + + return ret == 0 ? KSFT_PASS : KSFT_FAIL; +} +#endif + +int main(void) +{ + int ret; + + ksft_print_header(); +#ifdef __aarch64__ + ksft_set_plan(12); +#else + ksft_set_plan(9); +#endif + + // First run the tests without MDWE + test_result(test1(0), TEST1); + test_result(test2(0), TEST2); + test_result(test3(0), TEST3); +#ifdef __aarch64__ + test_result(test4(0), TEST4); +#endif + + // Enable MDWE and then run the tests again. + ret = prctl(PR_SET_MDWE, PR_MDWE_FLAG_MMAP, 0, 0, 0); + if (ret < 0) { + ksft_print_msg("PR_SET_MDWE failed or unsupported!\n"); + goto exit; + } + + ret = prctl(PR_GET_MDWE, PR_MDWE_FLAG_MMAP, 0, 0, 0); + if (ret == 0) + ksft_exit_fail_msg("PR_GET_MDWE failed!"); + + test_result(test1(1), "MDWE: " TEST1); + test_result(test2(1), "MDWE: " TEST2); + test_result(test3(1), "MDWE: " TEST3); +#ifdef __aarch64__ + test_result(test4(1), "MDWE: " TEST4); +#endif + + // Verify the MDWE setting is transferred when fork()ing + test_result(fork_test(test1), "MDWE+fork: " TEST1); + test_result(fork_test(test2), "MDWE+fork: " TEST2); + test_result(fork_test(test3), "MDWE+fork: " TEST3); +#ifdef __aarch64__ + test_result(fork_test(test4), "MDWE+fork: " TEST4); +#endif + +exit: + ksft_finished(); + + return 0; +} +