lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CCA9495F3D18EFF3+40304116-c894-4b4b-9f9f-e0398bc4deac@uniontech.com>
Date: Wed, 5 Nov 2025 12:32:42 +0800
From: Qiang Ma <maqianga@...ontech.com>
To: Baoquan He <bhe@...hat.com>
Cc: akpm@...ux-foundation.org, kexec@...ts.infradead.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/4] kexec: add kexec_core flag to control debug
 printing


在 2025/11/5 11:09, Baoquan He 写道:
> On 11/03/25 at 02:34pm, Qiang Ma wrote:
>> The commit a85ee18c7900 ("kexec_file: print out debugging message
>> if required") has added general code printing in kexec_file_load(),
>> but not in kexec_load().
>>
>> Since kexec_load and kexec_file_load are not triggered
>> simultaneously, we can unify the debug flag of kexec and kexec_file
>> as kexec_core_dbg_print.
> After reconsidering this, I regret calling it kexec_core_dbg_print.
> That sounds a printing only happening in kexec_core. Maybe
> kexec_dbg_print is better. Because here kexec refers to a generic
> concept, but not limited to kexec_load interface only. Just my personal
> thinking.
This sounds reasonable. The next version will be renamed kexec_dbg_print.
>
> Other than the naming, the whole patch looks good to me. Thanks.
>
>> Next, we need to do four things:
>>
>> 1. rename kexec_file_dbg_print to kexec_core_dbg_print
>> 2. Add KEXEC_DEBUG
>> 3. Initialize kexec_core_dbg_print for kexec
>> 4. Set the reset of kexec_file_dbg_print to kimage_free
>>
>> Signed-off-by: Qiang Ma <maqianga@...ontech.com>
>> ---
>>   include/linux/kexec.h      | 9 +++++----
>>   include/uapi/linux/kexec.h | 1 +
>>   kernel/kexec.c             | 1 +
>>   kernel/kexec_core.c        | 4 +++-
>>   kernel/kexec_file.c        | 4 +---
>>   5 files changed, 11 insertions(+), 8 deletions(-)
>>
>> diff --git a/include/linux/kexec.h b/include/linux/kexec.h
>> index ff7e231b0485..cad8b5c362af 100644
>> --- a/include/linux/kexec.h
>> +++ b/include/linux/kexec.h
>> @@ -455,10 +455,11 @@ bool kexec_load_permitted(int kexec_image_type);
>>   
>>   /* List of defined/legal kexec flags */
>>   #ifndef CONFIG_KEXEC_JUMP
>> -#define KEXEC_FLAGS    (KEXEC_ON_CRASH | KEXEC_UPDATE_ELFCOREHDR | KEXEC_CRASH_HOTPLUG_SUPPORT)
>> +#define KEXEC_FLAGS    (KEXEC_ON_CRASH | KEXEC_UPDATE_ELFCOREHDR | KEXEC_CRASH_HOTPLUG_SUPPORT | \
>> +			KEXEC_DEBUG)
>>   #else
>>   #define KEXEC_FLAGS    (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT | KEXEC_UPDATE_ELFCOREHDR | \
>> -			KEXEC_CRASH_HOTPLUG_SUPPORT)
>> +			KEXEC_CRASH_HOTPLUG_SUPPORT | KEXEC_DEBUG)
>>   #endif
>>   
>>   /* List of defined/legal kexec file flags */
>> @@ -525,10 +526,10 @@ static inline int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, g
>>   static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { }
>>   #endif
>>   
>> -extern bool kexec_file_dbg_print;
>> +extern bool kexec_core_dbg_print;
>>   
>>   #define kexec_dprintk(fmt, arg...) \
>> -        do { if (kexec_file_dbg_print) pr_info(fmt, ##arg); } while (0)
>> +	do { if (kexec_core_dbg_print) pr_info(fmt, ##arg); } while (0)
>>   
>>   extern void *kimage_map_segment(struct kimage *image, unsigned long addr, unsigned long size);
>>   extern void kimage_unmap_segment(void *buffer);
>> diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h
>> index 55749cb0b81d..819c600af125 100644
>> --- a/include/uapi/linux/kexec.h
>> +++ b/include/uapi/linux/kexec.h
>> @@ -14,6 +14,7 @@
>>   #define KEXEC_PRESERVE_CONTEXT	0x00000002
>>   #define KEXEC_UPDATE_ELFCOREHDR	0x00000004
>>   #define KEXEC_CRASH_HOTPLUG_SUPPORT 0x00000008
>> +#define KEXEC_DEBUG		0x00000010
>>   #define KEXEC_ARCH_MASK		0xffff0000
>>   
>>   /*
>> diff --git a/kernel/kexec.c b/kernel/kexec.c
>> index 9bb1f2b6b268..c7a869d32f87 100644
>> --- a/kernel/kexec.c
>> +++ b/kernel/kexec.c
>> @@ -42,6 +42,7 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry,
>>   	if (!image)
>>   		return -ENOMEM;
>>   
>> +	kexec_core_dbg_print = !!(flags & KEXEC_DEBUG);
>>   	image->start = entry;
>>   	image->nr_segments = nr_segments;
>>   	memcpy(image->segment, segments, nr_segments * sizeof(*segments));
>> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
>> index fa00b239c5d9..865f2b14f23b 100644
>> --- a/kernel/kexec_core.c
>> +++ b/kernel/kexec_core.c
>> @@ -53,7 +53,7 @@ atomic_t __kexec_lock = ATOMIC_INIT(0);
>>   /* Flag to indicate we are going to kexec a new kernel */
>>   bool kexec_in_progress = false;
>>   
>> -bool kexec_file_dbg_print;
>> +bool kexec_core_dbg_print;
>>   
>>   /*
>>    * When kexec transitions to the new kernel there is a one-to-one
>> @@ -576,6 +576,8 @@ void kimage_free(struct kimage *image)
>>   	kimage_entry_t *ptr, entry;
>>   	kimage_entry_t ind = 0;
>>   
>> +	kexec_core_dbg_print = false;
>> +
>>   	if (!image)
>>   		return;
>>   
>> diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
>> index eb62a9794242..4a24aadbad02 100644
>> --- a/kernel/kexec_file.c
>> +++ b/kernel/kexec_file.c
>> @@ -138,8 +138,6 @@ void kimage_file_post_load_cleanup(struct kimage *image)
>>   	 */
>>   	kfree(image->image_loader_data);
>>   	image->image_loader_data = NULL;
>> -
>> -	kexec_file_dbg_print = false;
>>   }
>>   
>>   #ifdef CONFIG_KEXEC_SIG
>> @@ -314,7 +312,7 @@ kimage_file_alloc_init(struct kimage **rimage, int kernel_fd,
>>   	if (!image)
>>   		return -ENOMEM;
>>   
>> -	kexec_file_dbg_print = !!(flags & KEXEC_FILE_DEBUG);
>> +	kexec_core_dbg_print = !!(flags & KEXEC_FILE_DEBUG);
>>   	image->file_mode = 1;
>>   
>>   #ifdef CONFIG_CRASH_DUMP
>> -- 
>> 2.20.1
>>
>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ