Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1584255lqp; Mon, 15 Apr 2024 10:28:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU6CNBe2FLklYJ5Dc5eKTFxY3qwRuV8HzMJcXIRhdWE9m3IPdh9LLOtv0PtqYIZAdcmQV0S0FVpbRAWZiRv81G6UJJpA9xedSmWdE2ehw== X-Google-Smtp-Source: AGHT+IHcUa9fNCWRWyyeneWZF78k26tvU3sJO20L0OfuNqzrQd7CWs3M9XExSjbvtr1FAGljKqgE X-Received: by 2002:a05:6a00:847:b0:6e7:8322:ff8e with SMTP id q7-20020a056a00084700b006e78322ff8emr12710127pfk.30.1713202120016; Mon, 15 Apr 2024 10:28:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713202120; cv=pass; d=google.com; s=arc-20160816; b=pi0JQHUW5gEa7APS6x6IgEe15gUkCDcBlWQVOhx08dSa7VzOguYZJUdYvgYrhF/IeD 7ySIciTetgP2i64ltQTxHEZGEGcHNMVoYDiBbHCFf/oF/2T75ubGktphGmQBpJznuNUj /lqnRUmIvDnv4wkIc3Yit0tV03FhvyDwAVer3SP/4MBpx1b5f/gjCk/+m4Pj+MR4oNj8 2uZnqllJxihL39yUUyW0uPLsvq5DAWqsXZcFprE/uwpf3Ub8w/LndOCtgdBunh9y6Fle +oLRT5c6E+TR08SkYe3okuJnojHHLUOZW/0SdaZ6/FvQpPpSqAmhzttHHgRECcFJcGNc 0m0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7LGAaJZA3Ieswr80lcknUKfoXzL8DxCdWx6U4KMKhO8=; fh=3PvOunvK8pJe2ygUmj6diV9QsfONay3YvQYmLx82O60=; b=C5xV/wXj8ZE/daSXotQnfPeIX69FhAF8W2JPSBAfKIVn4hvmnaL9uvrvzKbMzh/Gv+ /rwgDTqiDEo0MMhKoPfJiXwxJb6LzbQTF4qqzerjd3iIZxxvjhVTMzaNaR5Fz7erbVpf 21WHgL594uNlLH2VxV5FlJPDJqAfd/TzhMDkrr6fd6TIkz9X7BHHEfpE0FiF9y3tHlIu Cm4LSzH3yw4NnGwJk9Icwt/v3z0+W+S0VyAaZuUt5zYtXdXTubuBYQ01Uh6X+annMRc8 D2R0khY4J3nepb9OSIIIAY/3By5THK95WohqF2mnWdU8imUieUZvWZ0C7D9EPZJr688j pK4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="n1/7fwws"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-145655-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e17-20020a056a0000d100b006eac6f4d760si8129208pfj.362.2024.04.15.10.28.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:28:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145655-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="n1/7fwws"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-145655-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B95A0B21545 for ; Mon, 15 Apr 2024 17:23:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1E0F839F3; Mon, 15 Apr 2024 17:22:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="n1/7fwws" Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD81E8289E for ; Mon, 15 Apr 2024 17:22:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713201777; cv=none; b=m/6VyFt2jU3UNgXM8wIrQzFKqOWOxGTn998RxflvkQL5qQxEb35wVAuzCI6DtR8lU1Z1c6Kwms6M2mVXdzw6B8T95rpo+kdvZ+TahiSSNjQQF+5xAROLv4x6L1AQ1UIzBBGUgNHV75qU8JuwJfyb8jqjWbeD4ygqhCt/mHRc6wY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713201777; c=relaxed/simple; bh=cVYE2ehOGt9AZu4lK44Xq/DDtOiFLWELDzP2xoxBwKk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=USS22RqUP7ZHpcT/VycsShzPIHhOOrCYjprYyKUpVXqshtaKlj/XUpDdxORin/bfMbNP1iD7hsr3eP76TYBbt0feI5v8AYJIpnhGMEPcfnEdOyxUhySuGT+ysGn8dRHX5vP6OL+KaINESnP/mSaDL6SQVjpzExH2V3zj4Hsl/58= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=n1/7fwws; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1e2178b2cf2so32238535ad.0 for ; Mon, 15 Apr 2024 10:22:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713201775; x=1713806575; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=7LGAaJZA3Ieswr80lcknUKfoXzL8DxCdWx6U4KMKhO8=; b=n1/7fwwsz1foICewoRUWdT5xs8fB6NPWFGr0ktjY/VuOuhmhiUJFzqUk7Hh0CxPvax E5YisngVBin3djrd6DDhs4QCGQ3QzkFrCWfEDkLyfrJo6Rw1syIkQ4vSTaxW32o1JVNp BsyNyTkN7IyXA2SxPVivq380Pagf5FO7bMGXs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713201775; x=1713806575; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7LGAaJZA3Ieswr80lcknUKfoXzL8DxCdWx6U4KMKhO8=; b=Obc2Tp9ttxnnuT6bge1Y4RAfUAqCv/1iXwAEst7gWE475Tz6d8e8GpS2QtJyWzC06i HiEGCQvZ3F6QmLdfZrXtsJVOenVI4mtsXOXcl9k7jyFUIx+YXQR9IUVEyev4ADhWdmCd omhLQjc43xcEjT+On4/CdfEvVTnjSijWloVSjPlYCN6fiteCaHiXeZf32vxMZVHDBtpE W+PcWMrH725PoG++s654a2COlNkfGc4sDWV3XHPUMfF+euo/cJRZqgHLsIvyaTZaGOEk +AFEVOmmsbsazKG/Ia5Nu2EOgydFKdMX1uHVngOi3eFw1XaTf9qwAOEObi9YyJzRxcom 2/GA== X-Forwarded-Encrypted: i=1; AJvYcCUVscx8fyjPTdV01+UR+bOg7fOSAJ5YXKE7Krf4iSQt13jBIT5tdMhINiiLBTVfsxUi0A6Ex9UcC969UqWu9j3X9CRS7Wcrkjf+PZV7 X-Gm-Message-State: AOJu0YwWeZFMpplAaziL622pwvp2x/orhYTDe9szgOQt+ZeEbNPVst3J DOCKukKVXRY+t9HY6Cp9AkZv3N3CQ24tsKo6NnwJKFdlKkCFpMB/8OQ4+g91XA== X-Received: by 2002:a17:902:e807:b0:1e4:1eea:a3ae with SMTP id u7-20020a170902e80700b001e41eeaa3aemr13173797plg.5.1713201775022; Mon, 15 Apr 2024 10:22:55 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id b9-20020a170902d50900b001dee4a22c2bsm8144525plg.34.2024.04.15.10.22.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:22:54 -0700 (PDT) Date: Mon, 15 Apr 2024 10:22:53 -0700 From: Kees Cook To: Steven Rostedt Cc: Mike Rapoport , 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: <202404151017.FC002AA5@keescook> 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240412181940.3e1d99f7@gandalf.local.home> 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(). -- Kees Cook