From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A00BC4345F for ; Wed, 1 May 2024 14:59:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDC376B008C; Wed, 1 May 2024 10:59:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C8C4D6B0093; Wed, 1 May 2024 10:59:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B2D596B0095; Wed, 1 May 2024 10:59:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9813B6B008C for ; Wed, 1 May 2024 10:59:03 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4D3061207BA for ; Wed, 1 May 2024 14:59:03 +0000 (UTC) X-FDA: 82070134566.16.626109C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id A40DB140022 for ; Wed, 1 May 2024 14:59:01 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HYSPzSqH; spf=pass (imf09.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714575541; a=rsa-sha256; cv=none; b=SC1+76dJK1JTR0Ku3Zwqm78GHV3i9HVUrfsp1YN6ERZWxj32FoBHDf6Tvh8x9hzrgWZmCo iY6jysQljtOz1rY9Tnz5WO4oTC+PcaT+AbWNrx9rwpJporQrdIRGIe2bL6aVpHIYHAsmZC JV3Doxg7NBsnyiWjyUnoKN87pzDeko4= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HYSPzSqH; spf=pass (imf09.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714575541; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zJ5mHiJrqtax+z+JlyAvBEr+4O1aUi0140+MG/9FzRI=; b=vseQ7doiN0RQyR4d3uO4YhkuVxIGjmBPEM++SpgMguzC4mETiz21fc6fpUqf1y3TqRQSKW sIfWLpH7Fk+yjbOOyFPMDS4bLOdpEqAESmAZqie8kV6XsHyq/8C5o7GkH3kck4IPSo0VT2 GNEmxEMZJxX6QlVkFhI1ASCUtNPGvTc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BCABB61846; Wed, 1 May 2024 14:59:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37583C4AF18; Wed, 1 May 2024 14:58:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714575540; bh=397yuEegza1YdxCHGmXo6Fr1V3efYfawXEgbly0+WSI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HYSPzSqHFLggbq/xDWYyuhjhUA3byLwI0cx20K+Ar9H0VFMume+4mA27mZufxXN/J VKgOoUDQemQOr7L3Ygs+Gga6YEZcBqDMORKkDNDsWFVWM6k74eSypUDVzcnPqME0d1 On1AuvdGl3WZuSpo3YqkwaV3plOdeqN3b9AFy5bqX+qHtznRQtYeLOe4geDiyoj6Wr +pVoO67wG+b53CM0KBXBz45w+0LkBJMbzFSDEyL3EJ7qRUk97dtX9zUBeIueBeFdgN m92gi+XSOseCE6xMOh+VvwTCIDrfyAMnReFeSM0HHb1iBks0/k4qQowBV2E/n7X1od zuI3FXuNKBwMA== Date: Wed, 1 May 2024 17:57:27 +0300 From: Mike Rapoport To: Kees Cook Cc: Steven Rostedt , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , linux-mm@kvack.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Tony Luck , "Guilherme G. Piccoli" , linux-hardening@vger.kernel.org, Guenter Roeck , Ross Zwisler , wklin@google.com, Vineeth Remanan Pillai , Joel Fernandes , Suleiman Souhlal , Linus Torvalds , Catalin Marinas , Will Deacon Subject: Re: [POC][RFC][PATCH 1/2] mm/x86: Add wildcard * option as memmap=nn*align:name Message-ID: References: <20240409210254.660888920@goodmis.org> <20240409211351.075320273@goodmis.org> <202404091521.B63E85D@keescook> <20240409191156.5f92a15c@gandalf.local.home> <202404091638.2F98764A41@keescook> <20240412181940.3e1d99f7@gandalf.local.home> <202404151017.FC002AA5@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202404151017.FC002AA5@keescook> X-Stat-Signature: iemnckdjzxdxz98iizawg6a5dutmf4di X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A40DB140022 X-HE-Tag: 1714575541-4700 X-HE-Meta: U2FsdGVkX19T/MELIQ7K94J4Bi5JT9OgG1BCK33tWkmf5F7we5jwciJhiseaf1mz1CetjkjZaWGUjOb63NEZKoYWYH/jYhgUxfgDk0wS0Z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vp5nRyslqgWHD0U0dclQQLdTIJwTfPZLmvysJYQ7o/eHvi4lfMVx4oOP5m9Os9XXCWO55jZQSqVX3EGJ56Sq3PPO0u693z/MrJ5vNDxmyNBX7TQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Mon, Apr 15, 2024 at 10:22:53AM -0700, Kees Cook wrote: > On Fri, Apr 12, 2024 at 06:19:40PM -0400, Steven Rostedt wrote: > > On Fri, 12 Apr 2024 23:59:07 +0300 > > Mike Rapoport wrote: > > > > > On Tue, Apr 09, 2024 at 04:41:24PM -0700, Kees Cook wrote: > > > > On Tue, Apr 09, 2024 at 07:11:56PM -0400, Steven Rostedt wrote: > > > > > On Tue, 9 Apr 2024 15:23:07 -0700 > > > > > Kees Cook wrote: > > > > > > > > > > > Do we need to involve e820 at all? I think it might be possible to just > > > > > > have pstore call request_mem_region() very early? Or does KASLR make > > > > > > that unstable? > > > > > > > > > > Yeah, would that give the same physical memory each boot, and can we > > > > > guarantee that KASLR will not map the kernel over the previous location? > > > > > > > > Hm, no, for physical memory it needs to get excluded very early, which > > > > means e820. > > > > > > Whatever memory is reserved in arch/x86/kernel/e820.c, that happens after > > > kaslr, so to begin with, a new memmap parameter should be also added to > > > parse_memmap in arch/x86/boot/compressed/kaslr.c to ensure the same > > > physical address will be available after KASLR. > > > > But doesn't KASLR only affect virtual memory not physical memory? > > KASLR for x86 (and other archs, like arm64) do both physical and virtual > base randomization. > > > This just makes sure the physical memory it finds will not be used by the > > system. Then ramoops does the mapping via vmap() I believe, to get a > > virtual address to access the physical address. > > I was assuming, since you were in the e820 code, that it was > manipulating that before KASLR chose a location. But if not, yeah, Mike > is right -- you need to make sure this is getting done before > decompress_kernel(). Right now kaslr can handle up to 4 memmap regions and parse_memmap() in arch/x86/boot/compressed/kaslr.c should be updated for a new memmap type. But I think it's better to add a new kernel parameter as I suggested in another email and teach mem_avoid_memmap() in kaslr.c to deal with it, as well as with crashkernel=size@offset, btw. > -- > Kees Cook -- Sincerely yours, Mike.