Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757349AbeAIEGg (ORCPT + 1 other); Mon, 8 Jan 2018 23:06:36 -0500 Received: from mail-co1nam03on0069.outbound.protection.outlook.com ([104.47.40.69]:50528 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756630AbeAIEGe (ORCPT ); Mon, 8 Jan 2018 23:06:34 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jayachandran.Nair@cavium.com; Date: Mon, 8 Jan 2018 20:06:27 -0800 From: Jayachandran C To: Will Deacon Cc: Marc Zyngier , linux-arm-kernel@lists.infradead.org, lorenzo.pieralisi@arm.com, ard.biesheuvel@linaro.org, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, labbott@redhat.com, christoffer.dall@linaro.org Subject: Re: [v2,03/11] arm64: Take into account ID_AA64PFR0_EL1.CSV3 Message-ID: <20180109040626.GB4924@jc-sabre> References: <1515157961-20963-4-git-send-email-will.deacon@arm.com> <20180108072253.GA178830@jc-sabre> <9bc1f137-d78c-e46e-e1bc-f49160d5f289@arm.com> <20180108174016.GB180149@jc-sabre> <20180108175100.GW25869@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180108175100.GW25869@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: CY1PR07CA0031.namprd07.prod.outlook.com (2a01:111:e400:c60a::41) To SN2PR0701MB1070.namprd07.prod.outlook.com (2a01:111:e400:341f::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1bba2ec9-ec45-4102-2f7b-08d557165dba X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:SN2PR0701MB1070; X-Microsoft-Exchange-Diagnostics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Ze1JBuiEdhzqRCzbELQdNdV2j3uCTHHDhGelWqEgy8Tud9RHlVvv9EtTuoQxdSvJATUPrTE33uiIifCf2QjQ7RYdxmA6f5+QJlcrYv4hkQ4cLldZppjViZALQqvdi4IiF3QkLfwcw7nDdYasvg0eUfpKBk+IxFFo1ESM3Zvu9KZkdjCzt5XvBTSyrsiOCOwRm5veVI+Le+rXsVForuyjHVPYywgomxBTCrglHXb5n6dYvbiNgvruJi1eTXmcJ0uVXyDDi90W73gRqkne8ewdOpdq41ZKZxATq/TBU00uXXqsAdLVWq6xuFRunVa2k3H5rlI1Oc/W5lDcFnwQlshOi660fA1H9Q9XmTPx/SN0b+Zc+qM+Gia7hM96LLIMvcCy/HPcdvMwfjS1R+wb5GwpL+OwSagrC8jy7A5aYEuWrwiDJzCXee8tTKm4FyKgAH+0GyBl0hWh83r7GyMXW6NCNe0QEUk=;4:gzeoMu2e/SbOWSdj+DogBFA54bY8ax+ZvnnC+4wvdOCGyEswd6k8oPMr0YkzD5Cq77zWj2DwEUDuTcO94dAweqGHHbFU3p9bxI1c0WImw4KkQi4yraxujlTOsKiUCDazpFHjnIyxitpj9EQAXkC3GycK1TAfiw8jlJV42+2RtvbDIhiJVhQmrsyl2cun5muzIyNI+5ZcxxPdgasrMUUuG5HKduuKFKFzS9fkPgper7SUfJLGOQsyLTcVDynMP2aRKao1oX8ZgpGkNuDNar29/w== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231023)(944501075)(93006095)(6041268)(20161123558120)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011);SRVR:SN2PR0701MB1070;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:SN2PR0701MB1070; X-Forefront-PRVS: 0547116B72 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(346002)(396003)(39860400002)(376002)(366004)(39380400002)(24454002)(199004)(189003)(478600001)(33716001)(23726003)(33896004)(16526018)(105586002)(52116002)(316002)(76176011)(16586007)(8936002)(58126008)(72206003)(2906002)(93886005)(4326008)(386003)(8676002)(83506002)(33656002)(81156014)(81166006)(68736007)(6246003)(55016002)(9686003)(106356001)(229853002)(25786009)(50466002)(53546011)(3846002)(6496006)(6116002)(5660300001)(53936002)(66066001)(97736004)(42882006)(6916009)(2950100002)(6666003)(305945005)(1076002)(7736002)(47776003)(18370500001)(107986001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN2PR0701MB1070;H:jc-sabre;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN2PR0701MB1070;23:pkYdLausJSUgZGOgbvAJZD2j/RknbD6xSgjo+/W?= =?us-ascii?Q?A59hB3nyA7jDBaQhuI9HNswT9PFlFb6GJsxsw/Y01zAn2cdwlicgq0FjU7uB?= =?us-ascii?Q?65wQz9AcVVYNyak5SZSNy0xfhokdKMepDEnR3rWK3SCL85dV3kJOZ1N5QrSN?= =?us-ascii?Q?qNXB2I5232EIsgtyWkVIEWCIsjK9WAJ0OHqZWA1Paz2M2Jt28nv+VUU61Sv4?= =?us-ascii?Q?xZ0+V0xRhVQw2+zC6ISK/ox0ODBBvF83ByiZXlGdXvK+i7b9R2hvToW3I/fU?= =?us-ascii?Q?CyknITEQQyPownp4naCH01lz0JQBSFuE51ru7A6deo8YSEikK53H2mK+s3q6?= =?us-ascii?Q?YoJ01dBZXulkJ3EE1DtdyBXV52FYHCg+95NT0YIAKXQMU45vd2X5WC6kZo97?= =?us-ascii?Q?Xfq2OeE+3dU38lqG/GKJ6ML8TjfR74PIOJhJcXoopI378Sl8WOjpy9HMUqt8?= =?us-ascii?Q?pntl+gMRxFnEIZTyzHNa8b4huUNe/U0cs2a6IwTYFhXOqzlOg9fErYIRXRpT?=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d6ZK1BdAM65au08jxs7ehdPrjZMouvukAcJ6T3fxWbuCqpAAVvoJroPclFTg4Lt14ltcihmShlJuJzP4tZEYMlVqAR4U3bL7b1HrIeOhlXDMlKSHCCVCu+VYhgfPVoiJyFpGwiZ5keJd31NYVbLCDI2mDA+0zUyMcjuw7EktMOQQPjVgVeFHvEh0etK1f1WHoyVxZb8JNu+iev0dFGoRpBuj0O5f6ollo6d1rW0QwGdskKU1/+JDIKOydMlzw7NxEeQpdD7QdxskdN4zJ4d8SE/Qe5sIvThdw7NGS+wb8Psr2W1OMKAKFIOyuHvmuknkNwCAPc=;5:q0MuIqmwR6sZpWY3qeGWc234al0+ezD67z/QYOQRjIv1G2kEKMayT+wFB9kPP4VRyf22bKsM1aowUiz3I0xWVnKKDPFFXZ6wiDhwuOoV6/tqdUb+/k3Su287ZzAi/kcw1FjHmuCkQG1v7m8RHkreZPPbPfae4bObgtIY5aJ2lFI=;24:ld0mFTu1/I81RwlNh5vm4ipFVVxCu5/c+kUYd9X15t7XxlGJC6WRez83f9/ytbR2ZXa1f5QPu2jGJyAVDy5qh3X2pg584Euz3J5tds10i3I=;7:Ua5PzjKftlCbQFvV4LcygfnaNClPhLdBvQBK1Jp4eqOMoO/ftFUMChrcb+vNa0XCdiDKaJp7X5or/cPPwjjFgvhlHjBGerflENKhZE/8pKvRYYFDnkRtHSe/8T4O+02wxeiyIxfkbn6HcjiI+Vl3QV7htTDOpf84RnEJn0zBeCDQAHrsanlE7EXj/GYaBhBqboy+iaKjgSGA0qDdNfl3tLym8hY6YhiPCTRs3rooqLNjBYHNQ1+5D0jJhKAx2vGe SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2018 04:06:30.9766 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1bba2ec9-ec45-4102-2f7b-08d557165dba X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR0701MB1070 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, Jan 08, 2018 at 05:51:00PM +0000, Will Deacon wrote: > On Mon, Jan 08, 2018 at 09:40:17AM -0800, Jayachandran C wrote: > > On Mon, Jan 08, 2018 at 09:20:09AM +0000, Marc Zyngier wrote: > > > On 08/01/18 07:24, Jayachandran C wrote: > > > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > > > > index 19ed09b..202b037 100644 > > > > --- a/arch/arm64/kernel/cpufeature.c > > > > +++ b/arch/arm64/kernel/cpufeature.c > > > > @@ -862,6 +862,13 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, > > > > return __kpti_forced > 0; > > > > } > > > > > > > > + /* Don't force KPTI for CPUs that are not vulnerable */ > > > > + switch (read_cpuid_id() & MIDR_CPU_MODEL_MASK) { > > > > + case MIDR_CAVIUM_THUNDERX2: > > > > + case MIDR_BRCM_VULCAN: > > > > + return false; > > > > + } > > > > + > > > > /* Useful for KASLR robustness */ > > > > if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) > > > > return true; > > > > > > > > > > KPTI is also an improvement for KASLR. Why would you deprive a user of > > > the choice to further secure their system? > > > > The user has a choice with kpti= at the kernel command line, so we are > > not depriving the user of a choice. KASLR is expected to be enabled by > > distributions, and KPTI will be enabled by default as well. > > > > On systems that are not vulnerable to variant 3, this is an unnecessary > > overhead. > > KASLR can be bypassed on CPUs that are not vulnerable to variant 3 simply > by timing how long accesses to kernel addresses from EL0 take -- please read > the original KAISER paper for details about that attack on x86. kpti > mitigates that. If you don't care about KASLR, don't enable it (arguably > it's useless without kpti). The code above assumes that all ARM CPUs (now and future) will be vulnerable to timing attacks that can bypass KASLR. I don't think that is a correct assumption to make. If ThunderX2 is shown to be vulnerable to any timing based attack we can certainly move the MIDR check after the check for the CONFIG_RANDOMIZE_BASE. But I don't think that is the case now, if you have any PoC code to check this I can run on the processor and make the change. It is pretty clear that we need a whitelist check either before or after the CONFIG_RANDOMIZE_BASE check. The kaiser paper seems to say that ARM TTBR0/1 made it more immune, and the prefetch paper(if I understand correctly) showed that prefetch on some ARM cores can be used for timing attack. This is probably and area where you will have better information, so any specific pointers would be appreciated - especially ones showing that all ARM CPUs are susceptible. Thanks, JC.