Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp381070lqb; Fri, 24 May 2024 00:46:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXm2ku23lyHnQqc/xhyluiEdY4C+fRTRhKFjH287jxAWIdDNOFyacV3WVh74IRx2VQqvC0X7gClIZK/4m9o0S+5j4wRc2txWMup48g5XQ== X-Google-Smtp-Source: AGHT+IGNp/6Hg0SOKXQocOgINAODDrYRxPRuEw3bXptRw1/KTsLy2ZdcnQnPBr0hcYqA4lLBo2jg X-Received: by 2002:a05:6a21:8ccc:b0:1a9:852f:6acf with SMTP id adf61e73a8af0-1b212cc504bmr2243671637.11.1716536770016; Fri, 24 May 2024 00:46:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716536770; cv=pass; d=google.com; s=arc-20160816; b=KqRHSgWBMbfAh0Lu2zzxFLXWbWAIgLvA3Opyxjd/8yBhXVz8onAoAi7jTBptT68tr3 LFIle5JWDNHpQEZ3T6PFrQ169v0f3SHiznJq58b3JfC2WMpTxCswYsFbySnzpGoTUutv 7c8zHz4aHV9Qw8VW7v5QQOEk79eNlwigjL6zePOLBxtF8qM53wLFGLGLKuqISRKiz1hc TnPxDyF06OX3QdUIlAR2FRVgZqFSq9SUR0V4kbc4dsbcHeXAthBeITZm3Zd6UDBzQ6MJ sSnjNbg1iBz14yEv8bU/+WmFiPp9wBoa8dC4nFBOsqOv8DjIHwyyCaeoierWjUyVUqov lzSQ== 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=7pIey9Tt9vhLMK+qG1+4Gr5NV0hqgLZ0e2VrJaCmvI8=; fh=HjSsW9RYWzbS1c+zxYSoJLvjH+kwuuRsHKf8vANOpO4=; b=NTUWDD/UbRJ89vgEZCcLvVee2yNp6vCTyun/tL3g5ui32vYVtnT/5Hw5XyJ5kFLxQq yzTV8RkoI0Z9NENSdOTBhoeaT1oUZWvl9kTE4ShNI8HT7GG5bcANy9uyt1op2gFFBRVg BTtnNzDr7EZywdz1eCdrsOMRy0jo+me0S6QXoUicPtsroVRn3MoCU4aT6nOA6q3H9lKN Vl0SmCjBjv05U5kluyUkcxhUt+qkXmzrIX/qiBarMMH38+gWlqmCOXwCqd/Q/DfiMGO0 CU3fuUM1+P+54wI3fRo4ctGCFak23GpxR9dW/hjvt70soLpN+3Cvc1i2tJRHGTbOdzMP AUvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=V6wEbBBN; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-188413-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188413-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f8fc36f132si1030806b3a.108.2024.05.24.00.46.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 00:46:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-188413-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=V6wEbBBN; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-188413-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188413-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8D96E282146 for ; Fri, 24 May 2024 07:46:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4C90839FE; Fri, 24 May 2024 07:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="V6wEbBBN" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 675AF6FCC for ; Fri, 24 May 2024 07:45:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716536755; cv=none; b=sV0PSJLED/NBNxh2phhtsBql7xLGFfGgHjv34zYXhOWxBMVBRafhXuXNou3Fcq/zbg5xVVR3aSX9ebKBbzkCGbbr4Vxfqh/yWLtHWVjnhh6Qhy9vQWQeuSazjQMadOcwJqJxuXPiYFwk3PiBK93p9u11f+Um+Ouea2tirJQbWT0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716536755; c=relaxed/simple; bh=elPQAisHqjTMgnbiCeYkS3YTy1j6Z9gqGDuwGjDHQWM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YR0O4UFoPOFwbH842jaWSoyi1dPjV6EVgG42ph+lkMfsReBR4zXCSOBf2wa7gtZly69lpQCbr82CxMNS/rfCE2DwvZYAWONvjnN01HQ9+SQanvRbhrgckpK/M19YagW+j5hEh+ye7E97w5oJUnW0Lkas1rjY18Y1r/VHW60TYnE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=V6wEbBBN; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716536752; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7pIey9Tt9vhLMK+qG1+4Gr5NV0hqgLZ0e2VrJaCmvI8=; b=V6wEbBBNbd02JkaeO9cFAfcNEU6Z7lDrIux/XvwWVgy0zZq3k+MvqtdIM99OSCAC+3nYad xspblZrG4uXd/9e+0HhEXInw3CbLTjrLJ/akyfLCkYPvesykoaB1Wp2rQL8eDhVPQrvYTg 39K3oYIeGxi/8fpcpOeCpPa8igkX7cM= Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-648-jY8YJr3SOi-tnkl-a0nl0w-1; Fri, 24 May 2024 03:45:50 -0400 X-MC-Unique: jY8YJr3SOi-tnkl-a0nl0w-1 Received: by mail-ot1-f72.google.com with SMTP id 46e09a7af769-6f105fabe43so2148300a34.0 for ; Fri, 24 May 2024 00:45:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716536750; x=1717141550; 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=7pIey9Tt9vhLMK+qG1+4Gr5NV0hqgLZ0e2VrJaCmvI8=; b=Vj86AZBKtf1qFAXxGy7Di80P/F4GYOPlMbM49wnZLKHz5S3LrdvG6YrPcn88MBovU6 2Vkr68qnXqWmq6GXKPRA1cihqmh8uzif6xJeuN+b+C4eLg7TGrWX96YtimzokT2Gm3rj 5/BbzHXstCMEdUjHJR/vvnV69KweI0gCjgfy2aZXkKsAP2SnzkBpNrKW9IawCFASjBC2 D0Gh4U3Qw89bk7EB2enqvj7EbmjjYHJFQzGaN/hYl/d2bzX/ApDgADfswNRbYeFd8zDw +zrM26yQgz0Ci6fYAkWnOESx/EgK8A1dyFI6ZYQsH/c6mUc5+nhOIYdj+PKhTSWly6Ec WY2w== X-Forwarded-Encrypted: i=1; AJvYcCVko9fTCYfZWB8bNT4R/3v4pAuZNBmPjfozVAeBeq72b17KCM0ZKKMqA/fHWslr8ogI0+3VOcvblhcjassWWON6urqQ2pr+n0ri3Wb8 X-Gm-Message-State: AOJu0YyMJSDUJLM8sQ1c0LOKEkh8QwvY1yrrINgNdOZPAGWlZZti+bwH Quxzmn1o3/ZIslHKWNcihdLOtgoKrylQFS97h8cnyAAwJhFNUV7xCm/980/mQ6WRoW8v7Tkow7/ Xo2NvvcQEcgI+WN8kGf+2Soq3HFirQGZZw8T1mZy4W9xazevv7QFcw3VvoNLmkg== X-Received: by 2002:a05:6830:19d9:b0:6f0:e79e:f1a9 with SMTP id 46e09a7af769-6f8d0a5778cmr1455359a34.4.1716536749949; Fri, 24 May 2024 00:45:49 -0700 (PDT) X-Received: by 2002:a05:6830:19d9:b0:6f0:e79e:f1a9 with SMTP id 46e09a7af769-6f8d0a5778cmr1455330a34.4.1716536749335; Fri, 24 May 2024 00:45:49 -0700 (PDT) Received: from localhost ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-68220d07fa4sm613804a12.18.2024.05.24.00.45.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 00:45:48 -0700 (PDT) Date: Fri, 24 May 2024 15:43:23 +0800 From: Coiby Xu To: Baoquan He Cc: kexec@lists.infradead.org, Ondrej Kozina , Milan Broz , Thomas Staudt , Daniel P =?utf-8?B?LiBCZXJyYW5nw6k=?= , Kairui Song ,  Jan Pazdziora , Pingfan Liu , Dave Young , linux-kernel@vger.kernel.org, x86@kernel.org, Dave Hansen , Vitaly Kuznetsov , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: Re: [PATCH v3 7/7] x86/crash: make the page that stores the dm crypt keys inaccessible Message-ID: References: <20240425100434.198925-1-coxu@redhat.com> <20240425100434.198925-8-coxu@redhat.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; format=flowed Content-Disposition: inline In-Reply-To: On Tue, May 21, 2024 at 11:51:00AM +0800, Baoquan He wrote: >On 04/25/24 at 06:04pm, Coiby Xu wrote: >> This adds an addition layer of protection for the saved copy of dm >> crypt key. Trying to access the saved copy will cause page fault. >> >> Suggested-by: Pingfan Liu >> Signed-off-by: Coiby Xu >> --- >> arch/x86/kernel/machine_kexec_64.c | 21 +++++++++++++++++++++ >> 1 file changed, 21 insertions(+) >> >> diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c >> index b180d8e497c3..fc0a80f4254e 100644 >> --- a/arch/x86/kernel/machine_kexec_64.c >> +++ b/arch/x86/kernel/machine_kexec_64.c >> @@ -545,13 +545,34 @@ static void kexec_mark_crashkres(bool protect) >> kexec_mark_range(control, crashk_res.end, protect); >> } >> >> +static void kexec_mark_dm_crypt_keys(bool protect) >> +{ >> + unsigned long start_paddr, end_paddr; >> + unsigned int nr_pages; >> + >> + if (kexec_crash_image->dm_crypt_keys_addr) { >> + start_paddr = kexec_crash_image->dm_crypt_keys_addr; >> + end_paddr = start_paddr + kexec_crash_image->dm_crypt_keys_sz - 1; >> + nr_pages = (PAGE_ALIGN(end_paddr) - PAGE_ALIGN_DOWN(start_paddr))/PAGE_SIZE; >> + if (protect) >> + set_memory_np((unsigned long)phys_to_virt(start_paddr), nr_pages); >> + else >> + __set_memory_prot( >> + (unsigned long)phys_to_virt(start_paddr), >> + nr_pages, >> + __pgprot(_PAGE_PRESENT | _PAGE_NX | _PAGE_RW)); >> + } >> +} >> + >> void arch_kexec_protect_crashkres(void) >> { >> kexec_mark_crashkres(true); >> + kexec_mark_dm_crypt_keys(true); > >Really? Are all x86 systems having this dm_crypt_keys and need be >handled in kdump? I'm not sure if I understand the above question correctly. But kexec_mark_dm_crypt_keys will only take effect when there are dm_crypt_keys because there is a check on kexec_crash_image->dm_crypt_keys_addr. -- Best regards, Coiby