[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231219163418.108591-1-ytcoode@gmail.com>
Date: Wed, 20 Dec 2023 00:34:18 +0800
From: Yuntao Wang <ytcoode@...il.com>
To: akpm@...ux-foundation.org
Cc: bhe@...hat.com,
bp@...en8.de,
dave.hansen@...ux.intel.com,
dyoung@...hat.com,
hbathini@...ux.ibm.com,
hpa@...or.com,
kexec@...ts.infradead.org,
linux-kernel@...r.kernel.org,
mingo@...hat.com,
seanjc@...gle.com,
tglx@...utronix.de,
tiwai@...e.de,
vgoyal@...hat.com,
x86@...nel.org,
ytcoode@...il.com
Subject: [PATCH] crash_core: optimize crash_exclude_mem_range()
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 <ytcoode@...il.com>
---
Hi Andrew,
Patch "[PATCH 2/2] crash_core: fix out-of-bounds access check in
crash_exclude_mem_range()" can be ignored, use this patch instead.
kernel/crash_core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index 9a219a918638..d425c4a106cd 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -575,9 +575,12 @@ int crash_exclude_mem_range(struct crash_mem *mem,
p_start = mstart;
p_end = mend;
- if (p_start > end || p_end < start)
+ if (p_start > end)
continue;
+ if (p_end < start)
+ break;
+
/* Truncate any area outside of range */
if (p_start < start)
p_start = start;
--
2.43.0
Powered by blists - more mailing lists