Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp488237lqo; Thu, 16 May 2024 11:55:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU1F9gs9VW5UCQNb6X013W3FmlOEa52GTmVZelua2zDF+CKQiCSkqVB6dDEWmaQ/TgJX9bQT+ikv4U/JQsktrB7BCQ8/T/SmWUA/wiTZw== X-Google-Smtp-Source: AGHT+IGcPs3VnVxfQ+mR4X15r6R2Zf9trTbNYzdFOY3d1bMoAIjXM59lOCyxfeJxVG0xQmjGgq+u X-Received: by 2002:a17:906:48cc:b0:a59:cdc9:6fdf with SMTP id a640c23a62f3a-a5a2d54c0c9mr1207687166b.4.1715885714637; Thu, 16 May 2024 11:55:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715885714; cv=pass; d=google.com; s=arc-20160816; b=ZLMg514dOBhN8VUYet9QGBVMwD5S2MFdTlaiMV0jPkgxX0hhHmuGzX8TvaeBPAl3+B LPol7YxjCJPURzb2teddiTc8lYSnYn9rdBJjxcRQKPHfLOQPp7H+RuULbnz1PABrh+x5 HN0clF6lV6yMMBlyWw70QaUZgCD28rIZvw8L1Q/hkheCjfAaXiQDDNN9Xoq9YrNrLpeO UfV6qC6baIPscEvI3JXLUt0/yIX5tLl3ioX08brKD5J4t2fj9ORHHALqpHhIhrPzJzzw IRiTPLxTko3c1M+8PD8kGm3ZrA4m2keTwWYdk8U612v1LkapaNe3AYbek23ydIwgd2zU gSyQ== 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=fLvVPaGthcsDeYUgK994Dv4j8E5kvcQxmFSF+94OK3U=; fh=Y17nGX8h1Ova3xElOe1KxpWK69XqYOBr7aQys3mv5dY=; b=uq9vJ2W7WpZsfLALO4rosyPXjPA84N+Bq8CHPCSG/ksffW5PpoVSqbfHM/skfhmOqd xwISxkFJqw4UZYzx9TcjUR3TxEx5ZUc5rfrQMnUVsEx7QmeptInLgmZkye7W8UkpSRc0 58ZmI/iT+wlVtctWS407Dg6KwDKlTup37p/lOMaLwrs79tPyWbIu1PE3/2zAPPhy/d/c wCiyhpszl2+0puK7RjSvQ5OTW5mDMfNS5GI5/3L8qJQDkJyyWn4Cl0Y+1KV8N6H4/QNW yUhq0lppnWdZyPctXihPojnlvwQrb2xsBA617PEyVuoz5qiLqzN5FalXG68wJNCH2WGS 6XLA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TaacrotE; 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-181486-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181486-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17be8be0si898387866b.858.2024.05.16.11.55.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 11:55:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181486-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TaacrotE; 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-181486-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181486-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5E2DF1F21962 for ; Thu, 16 May 2024 18:55:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F9E3156F3D; Thu, 16 May 2024 18:55:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="TaacrotE" Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 46570156F29 for ; Thu, 16 May 2024 18:55:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715885706; cv=none; b=Lk68FrJ5HZq3CFn/r9sPWlqrztfdGzkHHxjviXXqpw3pNn1hp5efnQTF6ENAVRzdtEw/90bbDv+CXmBVl/nb5T1aTNmn943Uv8nr/JIsk/9iRq1eQ45S9/+d5NRkdCT0WdjoPcxZQKBZKGGJMtQMC2aIJGnKGq1pvFYubBuRKpo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715885706; c=relaxed/simple; bh=cn+rbKU4Nj4tQx9dF4d/u1kehcthPaTDE6iwoDSE9v4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=K4cuuZE1nQ+VicuV8vOVxqSMXeHF7vKpJ3LRSl8ijFtwGa+aI03Wg117EaTPUs28dWGpZGHOgTFh8oIV8ZOC8Y3dDTZOlTYIXh3joD3nZYhQCOQ39cNNjgoNKROvtLZ9xcOKGE11gpqYsOraw8fJmiqQB0zAyhcr4Ei4nslAklQ= 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=TaacrotE; arc=none smtp.client-ip=209.85.210.173 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-pf1-f173.google.com with SMTP id d2e1a72fcca58-6f472d550cbso523120b3a.1 for ; Thu, 16 May 2024 11:55:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1715885703; x=1716490503; 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=fLvVPaGthcsDeYUgK994Dv4j8E5kvcQxmFSF+94OK3U=; b=TaacrotE3yRI2+W1PfJbx76HN2QVcQn1ZSQgnd+TV0/v6LMASLZ02GHbeFlOsMGW5V /gYhFcWsXOrqPQSBoN7tt59QmZ0pFfI4jJ9DOBuDdBJW12227KcqAv9fg9jmtwJpDick ftLD+Eyhbb+P6eROO593YJlnLhDJfqoXCFwzY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715885703; x=1716490503; 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=fLvVPaGthcsDeYUgK994Dv4j8E5kvcQxmFSF+94OK3U=; b=OaQ482zX647P3NO8dRfpdKV13QWk3xaH+5pu4Z0LEVpfebfz2vL4yhTXLBts5F2Obx UtAk4yw3MsppBWnRxiK8sodEteP3N5qseUAP3Nslh0Zx1Spvi5a79/GynzezzzVfzSH6 jcWFmha0ac/yNhPKk4IxlFXY3yLJgdg5pT6kVNSc5rzWyaVTvIk084r+4lJxlobgEoIs pM5MJLy4miNhzR3ibwypvaG+HuQvoibywilsFajJHY4WODntSuSJVziYGcDLJO4ILL4k fQ69fpIb4MhZ6I/LTZhg0LAtrBDDHn+AU6YhpSKHexdKDmT++Z3iRw+kIAqjgbz/PQIz nlMg== X-Forwarded-Encrypted: i=1; AJvYcCW5mqzp3KXd6b2udSf8mLlnoDUO5X2K2TB2yi8Fstmol4NRh5ymFeWVxjNoh91M7LgfcDHtyCZGTt2jNcGi0dol9dDhzeEoGc3752bu X-Gm-Message-State: AOJu0YzTvEQ935HimhVFYej3x8tRfxwBWF3DgZjc6h1Vm8r2Sojp53bh PMpWHDgbM7Tc2jYvCn0NXl2R/tz7MwyGmw4tUfVsP+6schMK1P8jngWnbDS2fA== X-Received: by 2002:a05:6a00:1916:b0:6ea:9252:435 with SMTP id d2e1a72fcca58-6f4e038539cmr30136708b3a.30.1715885703535; Thu, 16 May 2024 11:55:03 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2b060f9sm13399031b3a.182.2024.05.16.11.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 11:55:02 -0700 (PDT) Date: Thu, 16 May 2024 11:55:01 -0700 From: Kees Cook To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Ard Biesheuvel , Ben Chaney , stable@vger.kernel.org Subject: Re: [PATCH] x86/efistub: Omit physical KASLR when memory reservations exist Message-ID: <202405161154.01864575AD@keescook> References: <20240516090541.4164270-2-ardb+git@google.com> 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: <20240516090541.4164270-2-ardb+git@google.com> On Thu, May 16, 2024 at 11:05:42AM +0200, Ard Biesheuvel wrote: > From: Ard Biesheuvel > > The legacy decompressor has elaborate logic to ensure that the > randomized physical placement of the decompressed kernel image does not > conflict with any memory reservations, including ones specified on the > command line using mem=, memmap=, efi_fake_mem= or hugepages=, which are > taken into account by the kernel proper at a later stage. > > When booting in EFI mode, it is the firmware's job to ensure that the > chosen range does not conflict with any memory reservations that it > knows about, and this is trivially achieved by using the firmware's > memory allocation APIs. > > That leaves reservations specified on the command line, though, which > the firmware knows nothing about, as these regions have no other special > significance to the platform. Since commit > > a1b87d54f4e4 ("x86/efistub: Avoid legacy decompressor when doing EFI boot") > > these reservations are not taken into account when randomizing the > physical placement, which may result in conflicts where the memory > cannot be reserved by the kernel proper because its own executable image > resides there. > > To avoid having to duplicate or reuse the existing complicated logic, > disable physical KASLR entirely when such overrides are specified. These > are mostly diagnostic tools or niche features, and physical KASLR (as > opposed to virtual KASLR, which is much more important as it affects the > memory addresses observed by code executing in the kernel) is something > we can live without. > > Closes: https://lkml.kernel.org/r/FA5F6719-8824-4B04-803E-82990E65E627%40akamai.com > Reported-by: Ben Chaney > Fixes: a1b87d54f4e4 ("x86/efistub: Avoid legacy decompressor when doing EFI boot") > Cc: # v6.1+ > Signed-off-by: Ard Biesheuvel Yup, all good by me: Reviewed-by: Kees Cook -- Kees Cook