[PATCH] powerpc/32s: Fix module loading failure when VMALLOC_END is over 0xf0000000

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

STALE2179d LANDED

Landed in mainline as 541cebb51f34 on 2020-08-21.

2 messages, 2 authors, 2020-08-27 · open the first message on its own page

[PATCH] powerpc/32s: Fix module loading failure when VMALLOC_END is over 0xf0000000

From: Christophe Leroy <hidden>
Date: 2020-08-21 07:15:31

In is_module_segment(), when VMALLOC_END is over 0xf0000000,
ALIGN(VMALLOC_END, SZ_256M) has value 0.

In that case, addr >= ALIGN(VMALLOC_END, SZ_256M) is always
true then is_module_segment() always returns false.

Use (ALIGN(VMALLOC_END, SZ_256M) - 1) which will have
value 0xffffffff and will be suitable for the comparison.

Reported-by: Andreas Schwab <redacted>
Signed-off-by: Christophe Leroy <redacted>
Fixes: c49643319715 ("powerpc/32s: Only leave NX unset on segments used for modules")
---
 arch/powerpc/mm/book3s32/mmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/mm/book3s32/mmu.c b/arch/powerpc/mm/book3s32/mmu.c
index 82ae9e06a773..d426eaf76bb0 100644
--- a/arch/powerpc/mm/book3s32/mmu.c
+++ b/arch/powerpc/mm/book3s32/mmu.c
@@ -194,12 +194,12 @@ static bool is_module_segment(unsigned long addr)
 #ifdef MODULES_VADDR
 	if (addr < ALIGN_DOWN(MODULES_VADDR, SZ_256M))
 		return false;
-	if (addr >= ALIGN(MODULES_END, SZ_256M))
+	if (addr > ALIGN(MODULES_END, SZ_256M) - 1)
 		return false;
 #else
 	if (addr < ALIGN_DOWN(VMALLOC_START, SZ_256M))
 		return false;
-	if (addr >= ALIGN(VMALLOC_END, SZ_256M))
+	if (addr > ALIGN(VMALLOC_END, SZ_256M) - 1)
 		return false;
 #endif
 	return true;
-- 
2.25.0

Re: [PATCH] powerpc/32s: Fix module loading failure when VMALLOC_END is over 0xf0000000

From: Michael Ellerman <hidden>
Date: 2020-08-27 07:46:58

On Fri, 21 Aug 2020 07:15:25 +0000 (UTC), Christophe Leroy wrote:
In is_module_segment(), when VMALLOC_END is over 0xf0000000,
ALIGN(VMALLOC_END, SZ_256M) has value 0.

In that case, addr >= ALIGN(VMALLOC_END, SZ_256M) is always
true then is_module_segment() always returns false.

Use (ALIGN(VMALLOC_END, SZ_256M) - 1) which will have
value 0xffffffff and will be suitable for the comparison.
Applied to powerpc/fixes.

[1/1] powerpc/32s: Fix module loading failure when VMALLOC_END is over 0xf0000000
      https://git.kernel.org/powerpc/c/541cebb51f3422d4f2c6cb95c1e5cc3dcc9e5021

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