Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp929134lqt; Fri, 7 Jun 2024 03:03:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWfcbX9bV/1F1Y7ZtCYiXWDFYUHwqQdsPhBTPvGfyiYeM8sj7lNSGvVOF3UoydwiAOl8Gf4j0lgFV0CwwVWcvvHauFLQ261m3gc1+KUtw== X-Google-Smtp-Source: AGHT+IEhiVcw4Un93FzOmAybq2jameC4bNyr7NvMEF4GPhhPaYl+Dcjhz3jDE7IRCanglmiiqIoj X-Received: by 2002:a05:6e02:1fe7:b0:374:aba7:741a with SMTP id e9e14a558f8ab-3758032e284mr24034475ab.17.1717754599856; Fri, 07 Jun 2024 03:03:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717754599; cv=pass; d=google.com; s=arc-20160816; b=TcJvRtZJL/ZPOzjSHSt9B0uR0IdrxYfabzKLiVy/wg22LAfUXQHY14lIHs9/ChwF6c ojZM/p18xWEzBBHkIHvQlgrbwXXGTt8PRGmlCrFItJkwitEtI+047AfNsd2GvLDCcJW+ ViHAAFfVNpHsdYjgqCoPqerMVh1s679aGS9ZZvAp6CGti8vS6RjA6jNVl5CzKgtKRov6 TbsEqbA7s/Gb8mMQ2knRxsOH9EvcPtegIMi416L5ongd4GVLFJ6SiW/ScW4ADY3qqhvi cI9BZV1pMO6bmo6JooocigJw4X3q+E+9wDEFV6RWo+wQlazRH6/hkvA7ZlZ5rywO/Ze3 RTWw== 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=eYY4ZJyi1ZBeDq5DjfhbsKQZnYv0J07Ec85K0cG2tqA=; fh=JWKTcHPX39ZSy+xSWQ17mloJs2b022GMkxLy8/dz1LQ=; b=oYl/KOmDwgsm1rVinrjw+KEK+jEvnR68xX/mI0R4Ik/zoo/6MLEpWz1w7l4cTcxmbY EKckqMj08aRN9K9p+cNUfhT9zJJgG1hOJLZnKfmi/w1BGBohKnVAFMHo9nh4BN8JX8F2 r4BRcWidcb00hS+5qPqGx67oLDncVOQ2mq60hEbwbOEw0IWt+ed3GCM16uJoJ3wmG0YQ MDrGm5hEUiwt8Yvnm38IDQm0tG+NG8ecN/7whGftr+WGFVPM+yL5gVFzj5wY4TU7S7lu aw5P6Nyhf3U5L/k3WHzagTtfsyNtows5XKKzDbRfGdA9tJeP/LUPneMQzz4vMqETz0Hv ce9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gt92rqS5; 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-205762-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205762-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de21788aa7si2742521a12.188.2024.06.07.03.03.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 03:03:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205762-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=@redhat.com header.s=mimecast20190719 header.b=gt92rqS5; 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-205762-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205762-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 27F48B22D06 for ; Fri, 7 Jun 2024 09:58:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 291CA13C69E; Fri, 7 Jun 2024 09:58:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gt92rqS5" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 D365413C69B for ; Fri, 7 Jun 2024 09:58:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717754294; cv=none; b=sZC5tdmarNXFsGCFqfbsej7rjs2TrxnAAaRmb1NPbmrbTUMSKw8ydQKq460EzsziybwwcFYQWyEQ4BfoJfG9SinEaHeq0d5e5EZwIoMwRtrPqYlHdbD3f9HdO+9DawQH/5Dr3zCbrehZFhAP3xGhlh6a7WpJf8L4SLXV/alMWRQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717754294; c=relaxed/simple; bh=OUp4arWnBEk08gC3O38TwKeJW7NLAT5ABWE4KhMq2rY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gzR0/UTJA2kvFQ7brObqEMRoECipctMm+XsrDUqz8mCSmfm5j13nye6s0gRp3OHygTQbbRYTca+J/pdvXPYkb7nXCJ01bu58xclDX3AAGum8ClvWu5Erctn1NsQFqlKeHzoWki29zcmyR6psWjH/9Zi6Y8oYPtE1jhnvRW5SOGc= 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=gt92rqS5; arc=none smtp.client-ip=170.10.129.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=1717754291; 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=eYY4ZJyi1ZBeDq5DjfhbsKQZnYv0J07Ec85K0cG2tqA=; b=gt92rqS5fAqMqqfANKegtkqoq6tpEdLrj4w3bporF2xbtpTnJThNtXaTSjFSQx9DoDzuB8 VE0iU9i8L1mFxMujbWlmh4pc8eMtbJXkiTo3kPWo52WZ7hR0NTR0L7Fn1kgX6ItWh+HkF3 ggSk30qFd/bWphY2Kj8pXN5t2PsmJg4= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-9-ietjylPLPgGuBOoONC0jvQ-1; Fri, 07 Jun 2024 05:57:58 -0400 X-MC-Unique: ietjylPLPgGuBOoONC0jvQ-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8C10A1955E7F; Fri, 7 Jun 2024 09:57:56 +0000 (UTC) Received: from localhost (unknown [10.72.113.124]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7F42E19560AB; Fri, 7 Jun 2024 09:57:48 +0000 (UTC) Date: Fri, 7 Jun 2024 17:57:38 +0800 From: Baoquan He To: Coiby Xu Cc: kexec@lists.infradead.org, Ondrej Kozina , Milan Broz , Thomas Staudt , Daniel P =?iso-8859-1?Q?=2E_Berrang=E9?= , 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 v4 6/7] x86/crash: pass dm crypt keys to kdump kernel Message-ID: References: <20240523050451.788754-1-coxu@redhat.com> <20240523050451.788754-7-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 Content-Disposition: inline In-Reply-To: <20240523050451.788754-7-coxu@redhat.com> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 On 05/23/24 at 01:04pm, Coiby Xu wrote: > 1st kernel will build up the kernel command parameter dmcryptkeys as > similar to elfcorehdr to pass the memory address of the stored info of > dm crypt key to kdump kernel. > > Signed-off-by: Coiby Xu > --- > arch/x86/kernel/crash.c | 15 ++++++++++++++- > arch/x86/kernel/kexec-bzimage64.c | 7 +++++++ > 2 files changed, 21 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c > index f06501445cd9..74b3844ae53c 100644 > --- a/arch/x86/kernel/crash.c > +++ b/arch/x86/kernel/crash.c > @@ -266,6 +266,7 @@ static int memmap_exclude_ranges(struct kimage *image, struct crash_mem *cmem, > unsigned long long mend) > { > unsigned long start, end; > + int r; ~? r is only to contain the returned value? Then you can call it ret as many do in kernel code. > > cmem->ranges[0].start = mstart; > cmem->ranges[0].end = mend; > @@ -274,7 +275,19 @@ static int memmap_exclude_ranges(struct kimage *image, struct crash_mem *cmem, > /* Exclude elf header region */ > start = image->elf_load_addr; > end = start + image->elf_headers_sz - 1; > - return crash_exclude_mem_range(cmem, start, end); > + r = crash_exclude_mem_range(cmem, start, end); > + > + if (r) > + return r; > + > + /* Exclude dm crypt keys region */ > + if (image->dm_crypt_keys_addr) { > + start = image->dm_crypt_keys_addr; > + end = start + image->dm_crypt_keys_sz - 1; > + return crash_exclude_mem_range(cmem, start, end); > + } You need adjust the array length of cmem->ranges[], I believe you will cause the array overflow because the keys are randomly set and mostly will be in the middle of crashkernel region. > + > + return r; > } > > /* Prepare memory map for crash dump kernel */