[PATCH v2 7/9] crash_dump: Improve readability of config_keys_restore_store
Coiby Xu
coiby.xu at gmail.com
Fri Jul 10 00:53:34 PDT 2026
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 <coiby.xu at gmail.com>
>>---
>> 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
More information about the kexec
mailing list