Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crashdump-x86.c:Add a check for the crash kernel range in exclude_region()
@ 2024-03-21 11:33 chenhaixiang
  2024-04-23 10:18 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: chenhaixiang @ 2024-03-21 11:33 UTC (permalink / raw)
  To: kexec; +Cc: louhongxiang, fangchuangchuang, wangbin224, bhe, chenhaixiang3

In some cases, such as start < mstart < mend < end when exclude_region(),
this results in crash_memory_range[i].end becoming less than
crash_memory_range[i].start, leading to incorrect address ranges.
Adding a range check should be necessary.

Signed-off-by: chenhaixiang chenhaixiang3@huawei.com
---
 kexec/arch/i386/crashdump-x86.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index a01031e..30e9a41 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -447,6 +447,14 @@ static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end)
 			else
 				crash_memory_range[i].start = end + 1;
 		}
+		if (crash_memory_range[i].end < crash_memory_range[i].start) {
+			/* Crash memory range is unreasonable. */
+			fprintf(stderr, "Error: Crash memory range is unreasonable.\n");
+			dbgprintf("exclude_region: crash_memory_range[%d]\n"
+				"start = %016llx,end =  %016llx\n",
+				i, crash_memory_range[i].start, crash_memory_range[i].end);
+                        return -1;
+		}
 	}
 	/* Insert split memory region, if any. */
 	if (tidx >= 0) {
-- 
2.33.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] crashdump-x86.c:Add a check for the crash kernel range in exclude_region()
  2024-03-21 11:33 [PATCH] crashdump-x86.c:Add a check for the crash kernel range in exclude_region() chenhaixiang
@ 2024-04-23 10:18 ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2024-04-23 10:18 UTC (permalink / raw)
  To: chenhaixiang; +Cc: kexec, louhongxiang, fangchuangchuang, wangbin224, bhe

On Thu, Mar 21, 2024 at 07:33:17PM +0800, chenhaixiang wrote:
> In some cases, such as start < mstart < mend < end when exclude_region(),
> this results in crash_memory_range[i].end becoming less than
> crash_memory_range[i].start, leading to incorrect address ranges.
> Adding a range check should be necessary.
> 
> Signed-off-by: chenhaixiang chenhaixiang3@huawei.com

Hi,

Given the discussion at [1] I am assuming this patch should not go in.
Please correct me if I am wrong.

[1] https://lore.kernel.org/all/8606fd02d6de4eb3b7c80e4ce3449458@huawei.com/

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-23 10:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-21 11:33 [PATCH] crashdump-x86.c:Add a check for the crash kernel range in exclude_region() chenhaixiang
2024-04-23 10:18 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox