[PATCH v2 2/2] kexec: Fix potential out of bounds in crash_exclude_mem_range()

2023-12-19 Thread fuqiang wang
When the split does not occur on the last array member, the current code will not return an error. So the correct array out-of-bounds check should be mem->nr_ranges >= mem->max_nr_ranges. When the OOB happen, the cmem->ranges[] have changed, so return early to avoid it. Signed-off-by: fuqiang wan

[PATCH v2 1/2] x86/kexec: Fix potential out of bounds in crash_setup_memmap_entries()

2023-12-19 Thread fuqiang wang
In memmap_exclude_ranges(), there will exclude elfheader from crashk_res. In the current x86 architecture code, the elfheader is always allocated at crashk_res.start. It seems that there won't be a split a new range. But it depends on the allocation position of elfheader in crashk_res. To avoid pot

[PATCH v2 0/2] kexec: fix potential cmem->ranges out of bounds

2023-12-19 Thread fuqiang wang
This series tries to fix the potential cmem->ranges out of bounds. On the v1 version, there are still some issues that need to be discussed, as follows: 1) Whether we need have the cmem->ranges[] partly changed, or keep it unchanged when OOB happened. Previously discussed link:[1]. 2) Set cmem->

Re: [PATCH v4 5/7] kexec_file, ricv: print out debugging message if required

2023-12-19 Thread Baoquan He
On 12/19/23 at 02:44pm, Conor Dooley wrote: > On Wed, Dec 13, 2023 at 01:57:45PM +0800, Baoquan He wrote: > > Then when specifying '-d' for kexec_file_load interface, loaded > > locations of kernel/initrd/cmdline etc can be printed out to help debug. > > > > Here replace pr_debug() with the newly

[PATCH v2] x86/kexec: use pr_err() instead of kexec_dprintk() when an error occurs

2023-12-19 Thread Yuntao Wang
When detecting an error, the current code uses kexec_dprintk() to output log message. This is not quite appropriate as kexec_dprintk() is mainly used for outputting debugging messages, rather than error messages. Replace kexec_dprintk() with pr_err(). This also makes the output method for this err

Re: [PATCH] x86/kexec: use pr_err() instead of kexec_dprintk() when an error occurs

2023-12-19 Thread Andrew Morton
On Tue, 19 Dec 2023 15:29:01 +0800 Yuntao Wang wrote: > When an error is detected, use pr_err() instead of kexec_dprintk() to > output log message. > > In addition, remove the unnecessary return from set_page_address(). The above describes what the code does, which is already quite clear from lo

[PATCH] crash_core: optimize crash_exclude_mem_range()

2023-12-19 Thread Yuntao Wang
Because memory ranges in mem->ranges are stored in ascending order, when we detect `p_end < start`, we can break the for loop early, as the subsequent memory ranges must also be outside the range we are looking for. Signed-off-by: Yuntao Wang --- Hi Andrew, Patch "[PATCH 2/2] crash_core: fix out

Re: [PATCH 2/2] crash_core: fix out-of-bounds access check in crash_exclude_mem_range()

2023-12-19 Thread Yuntao Wang
On Tue, 19 Dec 2023 22:22:47 +0800, Baoquan He wrote: > On 12/19/23 at 12:31pm, Yuntao Wang wrote: > > On Tue, 19 Dec 2023 11:32:02 +0800, Baoquan He wrote: > > > Hi Yuntao, > > > > > > On 12/19/23 at 10:02am, Yuntao Wang wrote: > > > > On Mon, 18 Dec 2023 09:29:02 -0800, Andrew Morton > > > >

Re: [RFC 0/3] kdump: Check mem_map of CMA area in kdump

2023-12-19 Thread Philipp Rudo
Hi Pingfan, On Mon, 18 Dec 2023 13:23:22 +0800 Pingfan Liu wrote: > From: Pingfan Liu > > > First of all, this series is only for proof of concept. It only passes > compilation. > > For years, CMA is proposed to be used as crashkernel reserved memory. > But DIO prevent us to follow it since

Re: [PATCH v4 5/7] kexec_file, ricv: print out debugging message if required

2023-12-19 Thread Conor Dooley
On Wed, Dec 13, 2023 at 01:57:45PM +0800, Baoquan He wrote: > Then when specifying '-d' for kexec_file_load interface, loaded > locations of kernel/initrd/cmdline etc can be printed out to help debug. > > Here replace pr_debug() with the newly added kexec_dprintk() in kexec_file > loading related

Re: [PATCH 2/2] crash_core: fix out-of-bounds access check in crash_exclude_mem_range()

2023-12-19 Thread Baoquan He
On 12/19/23 at 12:31pm, Yuntao Wang wrote: > On Tue, 19 Dec 2023 11:32:02 +0800, Baoquan He wrote: > > Hi Yuntao, > > > > On 12/19/23 at 10:02am, Yuntao Wang wrote: > > > On Mon, 18 Dec 2023 09:29:02 -0800, Andrew Morton > > > wrote: > > > > > > > On Mon, 18 Dec 2023 16:19:15 +0800 Yuntao Wang

Re: [PATCH] kexec: avoid out of bounds in crash_exclude_mem_range()

2023-12-19 Thread fuqiang wang
在 2023/12/19 18:39, Yuntao Wang 写道: On Tue, 19 Dec 2023 16:55:16 +0800, fuqiang wang wrote: Thank you very much for your patient comment. This change does indeed improve readability. But as a combination of these two, how do you feel about moving crash_setup_memmap_entries() behind vzalloc()

Re: [PATCH] kexec: avoid out of bounds in crash_exclude_mem_range()

2023-12-19 Thread Yuntao Wang
On Tue, 19 Dec 2023 16:55:16 +0800, fuqiang wang wrote: > Thank you very much for your patient comment. This change does indeed improve > readability. But as a combination of these two, how do you feel about moving > crash_setup_memmap_entries() behind vzalloc(). I don't quite understand what y

Re: [PATCH v14 5/6] powerpc: add crash CPU hotplug support

2023-12-19 Thread Hari Bathini
Hi Sourabh On 11/12/23 2:00 pm, Sourabh Jain wrote: Due to CPU/Memory hotplug or online/offline events the elfcorehdr (which describes the CPUs and memory of the crashed kernel) and FDT (Flattened Device Tree) of kdump image becomes outdated. Consequently, attempting dump collection with an outd

Re: [PATCH] kexec: avoid out of bounds in crash_exclude_mem_range()

2023-12-19 Thread fuqiang wang
在 2023/12/19 13:29, Yuntao Wang 写道: On Tue, 19 Dec 2023 11:50:32 +0800, fuqiang wang wrote: 在 2023/12/19 10:47, Yuntao Wang 写道: Hi fuqiang, Yesterday, I posted two patches that happen to address the bugs you an Baoquan are currently discussing here, I wasn't aware that you both were also w

Re: [PATCH] kexec: do syscore_shutdown() in kernel_kexec

2023-12-19 Thread b...@redhat.com
On 12/19/23 at 07:41am, Gowans, James wrote: > On Tue, 2023-12-19 at 12:22 +0800, Baoquan He wrote: > > Add Andrew to CC as Andrew helps to pick kexec/kdump patches. > > Ah, thanks, I didn't realise that Andrew pulls in the kexec patches. > > > > On 12/13/23 at 08:40am, James Gowans wrote: > > ..