Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1005768lqt; Fri, 7 Jun 2024 05:39:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXXwY97HG8L3VoUyEqo1KhswqHoiUi3vcC+fzPrw2mn2pnryZ7gqMeD/E4i3pCHBWoou7CH772QTYLDB+pEI5YmTZc9PbaxjTX+J/46ew== X-Google-Smtp-Source: AGHT+IF/+aV4hHkZSpAQl1aU5Yfi/xX3nTEETFga15oUAjJDeapCTcLoZldS1VGNrlPvA1CJOmSD X-Received: by 2002:a17:906:2b97:b0:a6e:f68c:a1cd with SMTP id a640c23a62f3a-a6ef68ca2femr17569566b.62.1717763953344; Fri, 07 Jun 2024 05:39:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717763953; cv=pass; d=google.com; s=arc-20160816; b=y9+Rtu0+uH5y1zTnGGPgxLYWEjSn3dNCR/ONFdBvTF+FZ7G4CHGtG4jAqtklhW5saA PnMgH19HZOd+kWx3wC6157cIXn+b+Z40rRD4IXX1D4RVxvw1dD3FI+a3h0pr6i2W8PVi ysxRtVv/kBkddPjvxIpk8nlOY8bgA2Jtz3LY/3SmJd2ePs5Z/414cbiOVg/Xxatt1LYi k5GEm7+l7b+HfLxC1vistpvKE3TZHKdlYzVULBlJAjuP1sQavmQ3coDA0wkpB/8cvp4l ki56l1OsJPGRL88xfL1mke8m91f9zmhMXYTSf2Vecnwh6afqWr4WSBouOnCWaMoDoFkA VfWw== 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=FypPKgT3pJsp6KviCFXO/ORbTvZxCPQ2jaD/DLtQnPQ=; fh=KHAwFHM5b80S7/aaKy50RctWAANJBSpIgSK49yjHp/A=; b=I7rdwJH99bEqgNJDD/Cg/AhVjg17ExaDMAZuyeZK9PCIkTt345kYtW2Uy70Cimez+U DabfnbmBCT7ZPXnUVTKNNc20pB7iwNDj44aJpXAHHJC53BuShFTyQ+6pofvfnA2fnChx BuQfDMVqnxNj3DNMwuG4ARaw3dnfECM6ER3lACuw5JkelHJdHf5C7NefoouUDg4MbJAi 4ngNVLZs8Ncnk8usfBlw0KTPrP7wUrjyNLUzAVTHMVAwQ4m5cfq24a3vALvBgx0ba/Qd quxXaMYZ5Fc3msVmDDnwMh/gecMrtQPz3a9IpCCxcwbTs0lwgRIwpfkeI4CwCez/gr0a xAaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Wv+lbW9m; 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-206043-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206043-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6c807081besi181587766b.665.2024.06.07.05.39.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 05:39:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206043-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Wv+lbW9m; 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-206043-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206043-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 67AAC1F28AD2 for ; Fri, 7 Jun 2024 12:30:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38D551946DD; Fri, 7 Jun 2024 12:28:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Wv+lbW9m" 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 E6596194154 for ; Fri, 7 Jun 2024 12:28:21 +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=1717763303; cv=none; b=s40b5iU4OFrOC7ZRngRGJDI8FykRSLRcESW2KQCzHVHWFrMw5rfqhyjZbFMpHhoauCiXxv+3X8EJJz4P3Z6Qof2kYBzXjjMLysPCJS6Ds2laxLTFys46ANqpBtdjTE3qRB8tUMKCDc0nZQVAkUDypV3HJbTZ9TFrEIQnARrOGUs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717763303; c=relaxed/simple; bh=2F/1Pw7fg7p1sCas1pMb+GrJ4VRYXNwcvb/GukSp7IA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=P+ZZql5rcEamJCpJneNcs3p3xnV4cEs3/bTuKUdKxHuYY/LelZRgoXbJOw9gQlIH2SkzwgPocLEZTBiW958WZgVX1ovFXZNPes9GmAoEGp/zLmy9ztSr3v1FWVYmq7N2Ao36yln+A/RNodmMvKnw/vvLVOSll+DO2wM54xNxucw= 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=Wv+lbW9m; 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=1717763301; 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=FypPKgT3pJsp6KviCFXO/ORbTvZxCPQ2jaD/DLtQnPQ=; b=Wv+lbW9mJWyv+0ca23oXV535j4WiY4KeWE1sE7A2O8GrgOwFFaq3ZyqKyAU785Vai1tjm2 tW/0IFrn8GqMVWs4R1N8UdEoBGgMhaOiTF7ssq74ChJc8TTBCFD5BJTiTQnIyWMNkKEVDR qAza59gjwBcAp4S39I1LXmxHD/bGReY= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-125-hIVw5t40P4iTQmAlYOWObA-1; Fri, 07 Jun 2024 08:28:19 -0400 X-MC-Unique: hIVw5t40P4iTQmAlYOWObA-1 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-6fb22ecd976so1413942b3a.1 for ; Fri, 07 Jun 2024 05:28:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717763299; x=1718368099; 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=FypPKgT3pJsp6KviCFXO/ORbTvZxCPQ2jaD/DLtQnPQ=; b=FfYWJNqJgnxincwJrmGrKYAAbhFm7xkJHTOVZivC0mbKASxND1z5ev/Nkq91tunDQi CacS8GvYj9jn+OqjTq1I3FCi7uMynFD0/mu+177eXhXD4SXiAoBVnm9FIFRNnIOF3xRV tA/5ZkvMqNtLMs/JIAPCEiAGwvjBJSk8FS1ieRagTZDhvXpdjrAIzUziSLGbnB/5Q9Jb XUZvyEB/rpzP9+9F3RSt2ctkDnUUs1fyhA3T4mAhLGkU7d2m6rxLzodMcZPXTu/CZo35 vVtsYiR5is3200JL1NCp9Xbpc4rsbuTL2fSQpsB947wGmdn0elQIcw/IdeqFICtkTZKu mXtg== X-Forwarded-Encrypted: i=1; AJvYcCX9SUZcezBIsXEAvRIlaELosL6zv1TCl+ccRrI1BhSTTp5MW9deZHe9ZWYecGOQwmksaFbn/M0i68qOPHWxcYLZ4sluRB1VUlHjhQ2I X-Gm-Message-State: AOJu0YwWJgveK3xYygwirOSXofj0wT2voDYNqta4ubDQn6iOUpT3Ddyf Hjdx6kNYSrguYW18lpnEoIZXGEj8r/vNPQ+1+u6hslG6eXcVBe1mQ0IPm3BT2yBbzh8rV4mSMgJ VxFpoWcq/w4QK7k9MJouOBCmy9zPFD1pZpOP2sXgH8stfT7/kNVPJQR2s2FQ77A== X-Received: by 2002:a05:6a00:23c2:b0:6ed:825b:30c0 with SMTP id d2e1a72fcca58-703f88de73amr7817551b3a.15.1717763297900; Fri, 07 Jun 2024 05:28:17 -0700 (PDT) X-Received: by 2002:a05:6a00:23c2:b0:6ed:825b:30c0 with SMTP id d2e1a72fcca58-703f88de73amr7817489b3a.15.1717763297022; Fri, 07 Jun 2024 05:28:17 -0700 (PDT) Received: from localhost ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-703fd3a3a87sm2486990b3a.82.2024.06.07.05.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 05:28:16 -0700 (PDT) Date: Fri, 7 Jun 2024 20:27:07 +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 , Vivek Goyal , Kees Cook , "Gustavo A. R. Silva" , "open list:KERNEL HARDENING (not covered by other areas):Keyword:b__counted_byb" Subject: Re: [PATCH v4 2/7] crash_dump: make dm crypt keys persist for the kdump kernel Message-ID: References: <20240523050451.788754-1-coxu@redhat.com> <20240523050451.788754-3-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, Jun 04, 2024 at 04:51:03PM +0800, Baoquan He wrote: >Hi Coiby, Hi Baoquan, > >On 05/23/24 at 01:04pm, Coiby Xu wrote: >> A sysfs /sys/kernel/crash_dm_crypt_keys is provided for user space to make >> the dm crypt keys persist for the kdump kernel. User space can send the >> following commands, >> - "init KEY_NUM" >> Initialize needed structures >> - "record KEY_DESC" >> Record a key description. The key must be a logon key. >> >> User space can also read this API to learn about current state. > >From the subject, can I think the luks keys will persist forever? or >only for a while? Yes, you are right. The keys need to stay in kdump reserved memory. > If need and can only keep it for a while, can you >mention it and tell why and how it will be used. Because you add a lot >of codes, but only simply mention the sysfs, that doesn't make sense. Thanks for raising the concern! I've added Documentation/ABI/testing/crash_dm_crypt_keys and copy some text in the cover letter to this patch in v5. > >> >> Signed-off-by: Coiby Xu >> --- >> include/linux/crash_core.h | 5 +- >> kernel/Kconfig.kexec | 8 +++ >> kernel/Makefile | 1 + >> kernel/crash_dump_dm_crypt.c | 113 +++++++++++++++++++++++++++++++++++ >> kernel/ksysfs.c | 22 +++++++ >> 5 files changed, 148 insertions(+), 1 deletion(-) >> create mode 100644 kernel/crash_dump_dm_crypt.c >> >> diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h >> index 44305336314e..6bff1c24efa3 100644 >> --- a/include/linux/crash_core.h >> +++ b/include/linux/crash_core.h >> @@ -34,7 +34,10 @@ static inline void arch_kexec_protect_crashkres(void) { } >> static inline void arch_kexec_unprotect_crashkres(void) { } >> #endif [...] >> +static int init(const char *buf) > ~~~~ A more interesting name with more description? Thanks for the suggestion! I've added some comments for this function in v5. But I can't come up with a better name after looking at current kernel code. You are welcome to suggest any better name:) >> +static int process_cmd(const char *buf, size_t count) > ~~~~ >If nobody use the count, why do you add it? Good catch! Yes, this is no need to use count in v4. But v5 now needs it to avoid buffer overflow. -- Best regards, Coiby