[PATCH] powerpc/kexec_file: Use inclusive range checks in add_usable_mem()

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

COLD28d

5 messages, 3 authors, 28d ago · open the first message on its own page

[PATCH] powerpc/kexec_file: Use inclusive range checks in add_usable_mem()

From: Thorsten Blum <hidden>
Date: 2026-08-09 16:25:21

add_usable_mem() adds usable memory ranges for the kdump kernel.

The ranges are inclusive, but the partial overlap check uses exclusive
comparisons. This skips ranges with base == loc_end or end == loc_base.
Use inclusive comparisons instead.

Fixes: 7c64e21a1c5a ("powerpc/kexec_file: Restrict memory usage of kdump kernel")
Signed-off-by: Thorsten Blum <redacted>
---
 arch/powerpc/kexec/file_load_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
index 8c72e12ea44e..f9e872693ca7 100644
--- a/arch/powerpc/kexec/file_load_64.c
+++ b/arch/powerpc/kexec/file_load_64.c
@@ -113,7 +113,7 @@ static int add_usable_mem(struct umem_info *um_info, u64 base, u64 end)
 		loc_end = um_info->ranges[i].end;
 		if (loc_base >= base && loc_end <= end)
 			add = true;
-		else if (base < loc_end && end > loc_base) {
+		else if (base <= loc_end && end >= loc_base) {
 			if (loc_base < base)
 				loc_base = base;
 			if (loc_end > end)

Re: [PATCH] powerpc/kexec_file: Use inclusive range checks in add_usable_mem()

From: Sourabh Jain <hidden>
Date: 2026-08-11 06:22:23


On 09/08/26 21:54, Thorsten Blum wrote:
quoted hunk
add_usable_mem() adds usable memory ranges for the kdump kernel.

The ranges are inclusive, but the partial overlap check uses exclusive
comparisons. This skips ranges with base == loc_end or end == loc_base.
Use inclusive comparisons instead.

Fixes: 7c64e21a1c5a ("powerpc/kexec_file: Restrict memory usage of kdump kernel")
Signed-off-by: Thorsten Blum <redacted>
---
  arch/powerpc/kexec/file_load_64.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
index 8c72e12ea44e..f9e872693ca7 100644
--- a/arch/powerpc/kexec/file_load_64.c
+++ b/arch/powerpc/kexec/file_load_64.c
@@ -113,7 +113,7 @@ static int add_usable_mem(struct umem_info *um_info, u64 base, u64 end)
  		loc_end = um_info->ranges[i].end;
  		if (loc_base >= base && loc_end <= end)
  			add = true;
-		else if (base < loc_end && end > loc_base) {
+		else if (base <= loc_end && end >= loc_base) {
This is interesting. The updated condition basically handles exactly a
one-byte overlap on either side of the usable memory ranges. In practice,
it is very unlikely that we would have such usable memory and LMB ranges.

Thorsten, have you encountered any problem that led you to propose this fix?

- Sourabh Jain
  			if (loc_base < base)
  				loc_base = base;
  			if (loc_end > end)

Re: [PATCH] powerpc/kexec_file: Use inclusive range checks in add_usable_mem()

From: Thorsten Blum <hidden>
Date: 2026-08-11 10:55:54

On Tue, Aug 11, 2026 at 11:51:46AM +0530, Sourabh Jain wrote:
On 09/08/26 21:54, Thorsten Blum wrote:
quoted
add_usable_mem() adds usable memory ranges for the kdump kernel.

The ranges are inclusive, but the partial overlap check uses exclusive
comparisons. This skips ranges with base == loc_end or end == loc_base.
Use inclusive comparisons instead.

Fixes: 7c64e21a1c5a ("powerpc/kexec_file: Restrict memory usage of kdump kernel")
Signed-off-by: Thorsten Blum <redacted>
---
  arch/powerpc/kexec/file_load_64.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
index 8c72e12ea44e..f9e872693ca7 100644
--- a/arch/powerpc/kexec/file_load_64.c
+++ b/arch/powerpc/kexec/file_load_64.c
@@ -113,7 +113,7 @@ static int add_usable_mem(struct umem_info *um_info, u64 base, u64 end)
  		loc_end = um_info->ranges[i].end;
  		if (loc_base >= base && loc_end <= end)
  			add = true;
-		else if (base < loc_end && end > loc_base) {
+		else if (base <= loc_end && end >= loc_base) {
This is interesting. The updated condition basically handles exactly a
one-byte overlap on either side of the usable memory ranges. In practice,
it is very unlikely that we would have such usable memory and LMB ranges.

Thorsten, have you encountered any problem that led you to propose this fix?
Found by inspection only and I agree that this is unlikely in practice,
which is why I didn't cc stable. Same for the other patch [1].

Thanks for the review.

[1] https://lore.kernel.org/r/20260810145827.157972-3-thorsten.blum@linux.dev/

Re: [PATCH] powerpc/kexec_file: Use inclusive range checks in add_usable_mem()

From: Sourabh Jain <hidden>
Date: 2026-08-12 03:17:42


On 11/08/26 16:25, Thorsten Blum wrote:
On Tue, Aug 11, 2026 at 11:51:46AM +0530, Sourabh Jain wrote:
quoted
On 09/08/26 21:54, Thorsten Blum wrote:
quoted
add_usable_mem() adds usable memory ranges for the kdump kernel.

The ranges are inclusive, but the partial overlap check uses exclusive
comparisons. This skips ranges with base == loc_end or end == loc_base.
Use inclusive comparisons instead.

Fixes: 7c64e21a1c5a ("powerpc/kexec_file: Restrict memory usage of kdump kernel")
Signed-off-by: Thorsten Blum <redacted>
---
   arch/powerpc/kexec/file_load_64.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
index 8c72e12ea44e..f9e872693ca7 100644
--- a/arch/powerpc/kexec/file_load_64.c
+++ b/arch/powerpc/kexec/file_load_64.c
@@ -113,7 +113,7 @@ static int add_usable_mem(struct umem_info *um_info, u64 base, u64 end)
   		loc_end = um_info->ranges[i].end;
   		if (loc_base >= base && loc_end <= end)
   			add = true;
-		else if (base < loc_end && end > loc_base) {
+		else if (base <= loc_end && end >= loc_base) {
This is interesting. The updated condition basically handles exactly a
one-byte overlap on either side of the usable memory ranges. In practice,
it is very unlikely that we would have such usable memory and LMB ranges.

Thorsten, have you encountered any problem that led you to propose this fix?
Found by inspection only and I agree that this is unlikely in practice,
which is why I didn't cc stable. Same for the other patch [1].

Thanks for the review.

[1] https://lore.kernel.org/r/20260810145827.157972-3-thorsten.blum@linux.dev/
The changes look good to me. Feel free to add:

Reviewed-by: Sourabh Jain <redacted>

Re: [PATCH] powerpc/kexec_file: Use inclusive range checks in add_usable_mem()

From: Madhavan Srinivasan <maddy@linux.ibm.com>
Date: 2026-09-09 06:19:48

On Sun, 09 Aug 2026 18:24:01 +0200, Thorsten Blum wrote:
add_usable_mem() adds usable memory ranges for the kdump kernel.

The ranges are inclusive, but the partial overlap check uses exclusive
comparisons. This skips ranges with base == loc_end or end == loc_base.
Use inclusive comparisons instead.


[...]
Applied to powerpc/fixes.

[1/1] powerpc/kexec_file: Use inclusive range checks in add_usable_mem()
      https://git.kernel.org/powerpc/c/c6755be4838d6ccd641effbcdc3d917b82631ff9

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help