From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.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 CBFBD3D9035 for ; Fri, 10 Jul 2026 07:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783670033; cv=none; b=a6GD4ln3Qktmt2iIJNuDNf3GnzAbPXRBTqvJEX3rJKtY4ceNUc+FcsLuhsCE6c8uXhdq0vRc78s5rlSGYfqsEyh3onh2WHj2F0vezPIseiF6pHaNMGSYdGPnzB2bA2+luKeDC+Tm0itikkVQsPCcslfhDTr2S92Kednr8p0bDDo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783670033; c=relaxed/simple; bh=9nB98nl/emeHf40LioHP7zEjOmyig9dUt6oHIdtAQ0o=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=idVC9VMIXH6ZgxPO6zYaCfHaCootrqUr700kZtpYemVw2xKUPkezE8FaGS4yUwIWZteUAf84kxW0sYjik+D/UHf7SJpjW2aWCw4HPHvBpxkl1L5z1DBAG1YHIXM+qnhj2xfkUPz3oAru/qzQf/oG+JdluVsd3zrl1O6ApV1a0dU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=qDBhBXcw; arc=none smtp.client-ip=209.85.128.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qDBhBXcw" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-80cebd41372so8865147b3.3 for ; Fri, 10 Jul 2026 00:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783670031; x=1784274831; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:date:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=3MvQlBKjkny8mMC2lU5kct7N4ZDfA+zPYCI7ZPzWCME=; b=qDBhBXcw3lRAChyICl7sirpruFyUXxfAITjVUANiT9mkE+bxkN0uym9YwPpvpLKcNw X5Rpm5Ro4QwDSCXUJX4ztWYt9iGsEDu4dXIJWWEsjmgrqIGPF1FRbILrnw5zdQi3VCBC MkVi33Ps+Nt46gG7K6GRXNgNdQfT7+sQDN5KNXsgsKLQLvvLsWgJdQ5pSzonype7KMsR LLBxaqHn5celLr00tT+8DM9k/HaNWnhNv70akDTF9ubnZusfs2U2/XfUUjk9MrGBw9cu xwWPO0J2uIwjzONCeIXH3//NqHgF+4ca3h8B8GtycqnZpRjuFEunXp8L4pQbQKv28/BK 8AYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783670031; x=1784274831; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=3MvQlBKjkny8mMC2lU5kct7N4ZDfA+zPYCI7ZPzWCME=; b=Q6+Rfx7h/04juIuwtKSE/FnGy6Q46g9F3DLHLvFL6M8B3ptyz5Q1y0AUudrTjYUEkd xo1jf7hjgj87F3khyexj76b+hb9eY/HTXjUuJypO5JgAw+WNl6T3PkdzM7IMBnKV+x4x YXgsexqM06cYPeZeS8JzhUXPphe6eQDxe63kIq8SRz6XTyCl8MDrrUds4Ijhk239b67l kXuuxByiavWTZ1xCLNBtaxZ6yU9pKYrcARvSyt1y7fLXl5FECB8t4c1+UYoQOYEUlKS+ sez6YBcIaept70LNRXDTYB7mONW3/6pQNTyqGW+eO3XZSWaEaDRm6cD1qXYuQ3gb3ROX FnHA== X-Forwarded-Encrypted: i=1; AHgh+RqWwRysD5PFX38lor2+hPd3Vq3aX8ZeEWxlCLc666I266OAAj6eRRZ9yVzjdtrKJz6CJS4tVnrnBEoAaEY=@vger.kernel.org X-Gm-Message-State: AOJu0YyCNlUARKwAo7NAQC5QgQA2pdz1qFk9uVkssvwmfmg+PX9rGbbz as7UOvyPSxlxvaVDp2DDtEso23MpF9t0bjNOMsldeYsd/g1Loj0DncIR X-Gm-Gg: AfdE7cm3qKvyOyyM3ZqeXtxx+X2r4L7Hhx8OsWGnyl0y6HdXX0KXrpmA4oDFpqxGx6C 4OHeup0O9BKTt4bLZQNFSoTLqfjfgl2Uj1YKprwIugjJw70U1cU9gLI4nWOLv9By3M/9c35AcQ2 rwUhP4RpH6KYWRAAuPyxsWzK3rVcbXIDLnVz5lc/bk9qT6cALPjew55RBA9vgf+mAEIVJr1jstz HvQwOEPbYNMdYFhrbGSxu0lbENLWWg023bTEh60nEO+kj35kcm6NrYUOlH3PSp/v4MLUwMQz/Uo E/dzFTA3Xg1iYstN0fF2grWcIKQUIsxlPefxi1UY8fQyGTsMAHaeJUs9uGrqMFsHG35foyOejix LMtt0Dw+YbHBHeCPFQPIuovvzxYQypcZvFIVfTYyevucEjHn+6M8krf+wjEwEHifzCCji3i05c0 yr7g6hkkj7qaSbLtbgET7Zak5FU0N7hifeKK1r6Yn12A== X-Received: by 2002:a05:690c:13:b0:7dc:aa85:5c67 with SMTP id 00721157ae682-81dbbe375afmr77927097b3.11.1783670030838; Fri, 10 Jul 2026 00:53:50 -0700 (PDT) Received: from localhost (tpcc3a204.netvigator.com. [219.76.18.204]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81e6c212f14sm39077757b3.42.2026.07.10.00.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2026 00:53:50 -0700 (PDT) From: Coiby Xu X-Google-Original-From: Coiby Xu Date: Fri, 10 Jul 2026 15:53:34 +0800 To: Sourabh Jain Cc: kexec@lists.infradead.org, Andrew Morton , Baoquan He , Dave Young , Mike Rapoport , Pasha Tatashin , Pratyush Yadav , Coiby Xu , open list Subject: Re: [PATCH v2 7/9] crash_dump: Improve readability of config_keys_restore_store Message-ID: References: <20260501234342.2518281-1-coiby.xu@gmail.com> <20260501234342.2518281-8-coiby.xu@gmail.com> <23784559-1e11-4e14-bf23-6ffebd7b2d30@linux.ibm.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: <23784559-1e11-4e14-bf23-6ffebd7b2d30@linux.ibm.com> On Wed, May 06, 2026 at 08:03:44PM +0530, Sourabh Jain wrote: > > >On 02/05/26 05:13, Coiby Xu wrote: >>config_keys_restore_store currently doesn't validate the user input >>before restoring dm-crypt keys. Although it's not necessary for the case >>of vmcore dumping, it's better to do it for the sake of consistency and >>code readability. Also check the return code of >>restore_dm_crypt_keys_to_thread_keyring. >> >>Fixes: 62f17d9df692 ("crash_dump: retrieve dm crypt keys in kdump kernel") >>Signed-off-by: Coiby Xu >>--- >> kernel/crash_dump_dm_crypt.c | 10 +++++++--- >> 1 file changed, 7 insertions(+), 3 deletions(-) >> >>diff --git a/kernel/crash_dump_dm_crypt.c b/kernel/crash_dump_dm_crypt.c >>index 545d712428d3..36e51807d94f 100644 >>--- a/kernel/crash_dump_dm_crypt.c >>+++ b/kernel/crash_dump_dm_crypt.c >>@@ -358,12 +358,16 @@ static ssize_t config_keys_restore_show(struct config_item *item, char *page) >> static ssize_t config_keys_restore_store(struct config_item *item, >> const char *page, size_t count) >> { >>- if (!restore) >>- restore_dm_crypt_keys_to_thread_keyring(); >>+ bool val; >>- if (kstrtobool(page, &restore)) >>+ if (kstrtobool(page, &val)) >> return -EINVAL; >>+ if (val && !restore) { >>+ if (!restore_dm_crypt_keys_to_thread_keyring()) >>+ restore = true; >>+ } > >Nit: >I think it would be good to warn the user if they try to >restore it when it has already been restored. Thanks for the suggestion! I'll apply it to v3. > > >- Sourabh Jain >>+ >> return count; >> } > -- Best regards, Coiby