Skip to contentSkip to conversation

ARM: Remove address checking for MMUless devices

PATCH In review Yanjun Yang 5 participants 8 messages Jun 11, 2024 – Jul 1, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: Remove address checking for MMUless devices

Commit 169f9102f9198b ("ARM: 9350/1: fault:
Implement copy_from_kernel_nofault_allowed()") added the function to check address before use. However, for devices without MMU, addr > TASK_SIZE will always fail. This patch move this function after the #ifdef CONFIG_MMU statement.

Also reported at https://bugzilla.kernel.org/show_bug.cgi?id=218953

---
 arch/arm/mm/fault.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mm/fault.c +2 -2
index 67c425341a95..ab01b51de559 100644
@@ -25,6 +25,8 @@
 
 #include "fault.h"
 
+#ifdef CONFIG_MMU
+
 bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
 {
 	unsigned long addr = (unsigned long)unsafe_src;
@@ -32,8 +34,6 @@ bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
 	return addr >= TASK_SIZE && ULONG_MAX - addr >= size;
 }
 
-#ifdef CONFIG_MMU
-
 /*
  * This is useful to dump out the page tables associated with
  * 'addr' in mm 'mm'.
Signature · 7 lines
2.45.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw

Hi,
Apologies for not CCing the relevant maintainers in my previous email.

Quoted 39 lines · Yanjun Yang

Commit 169f9102f9198b ("ARM: 9350/1: fault:
Implement copy_from_kernel_nofault_allowed()") added the function to check address before use. However, for devices without MMU, addr > TASK_SIZE will always fail. This patch move this function after the #ifdef CONFIG_MMU statement.

Also reported at https://bugzilla.kernel.org/show_bug.cgi?id=218953

---
 arch/arm/mm/fault.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mm/fault.c +2 -3
index 67c425341a95..ab01b51de559 100644
@@ -25,6 +25,8 @@
 
 #include "fault.h"
 
+#ifdef CONFIG_MMU
+
 bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
 {
        unsigned long addr = (unsigned long)unsafe_src;
@@ -32,8 +34,6 @@ bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
        return addr >= TASK_SIZE && ULONG_MAX - addr >= size;
 }
 
-#ifdef CONFIG_MMU
-
 /*
  * This is useful to dump out the page tables associated with
  * 'addr' in mm 'mm'.
--

2.45.2

#2 lore raw
Quoted 10 lines · Yanjun Yang

Hi,
Apologies for not CCing the relevant maintainers in my previous email.

Quoted 5 lines · Yanjun Yang

Commit 169f9102f9198b ("ARM: 9350/1: fault:
Implement copy_from_kernel_nofault_allowed()") added the function to check address before use. However, for devices without MMU, addr > TASK_SIZE will always fail.

Is that true? Doesn't it depend on the physical memory layout of the platform in question?

Quoted 6 lines

This patch move this function after the #ifdef

Quoted 5 lines

CONFIG_MMU statement.

Also reported at https://bugzilla.kernel.org/show_bug.cgi?id=218953

Quoted 29 lines
Quoted 29 lines
---
 arch/arm/mm/fault.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mm/fault.c +2 -3
index 67c425341a95..ab01b51de559 100644
@@ -25,6 +25,8 @@
 
 #include "fault.h"
 
+#ifdef CONFIG_MMU
+
 bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
 {
        unsigned long addr = (unsigned long)unsafe_src;
@@ -32,8 +34,6 @@ bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
        return addr >= TASK_SIZE && ULONG_MAX - addr >= size;
 }
 
-#ifdef CONFIG_MMU
-
 /*
  * This is useful to dump out the page tables associated with
  * 'addr' in mm 'mm'.
--

2.45.2

#3 lore raw
Quoted 8 lines · Ard Biesheuvel
Quoted 6 lines · Yanjun Yang

Hi,
Apologies for not CCing the relevant maintainers in my previous email.

Quoted 1 line · Yanjun Yang
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

Commit 169f9102f9198b ("ARM: 9350/1: fault:
Implement copy_from_kernel_nofault_allowed()") added the function to check address before use. However, for devices without MMU, addr > TASK_SIZE will always fail.

Is that true? Doesn't it depend on the physical memory layout of the platform in question?

I only checked the ARM architecture, in arch/arm/include/asm/memory.h TASK_SIZE is
defined as 0xffffffff when CONFIG_MMU is not defined. Following is the code snippet.
/*
* The limitation of user task size can grow up to the end of free ram region.
* It is difficult to define and perhaps will never meet the original meaning
* of this define that was meant to.
* Fortunately, there is no reference for this in noMMU mode, for now. */
#define TASK_SIZE UL(0xffffffff)

Quoted 38 lines
Quoted 6 lines

This patch move this function after the #ifdef

Quoted 5 lines

CONFIG_MMU statement.

Also reported at https://bugzilla.kernel.org/show_bug.cgi?id=218953

Quoted 29 lines
Quoted 29 lines
---
 arch/arm/mm/fault.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mm/fault.c +2 -3
index 67c425341a95..ab01b51de559 100644
@@ -25,6 +25,8 @@
 
 #include "fault.h"
 
+#ifdef CONFIG_MMU
+
 bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
 {
        unsigned long addr = (unsigned long)unsafe_src;
@@ -32,8 +34,6 @@ bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
        return addr >= TASK_SIZE && ULONG_MAX - addr >= size;
 }
 
-#ifdef CONFIG_MMU
-
 /*
  * This is useful to dump out the page tables associated with
  * 'addr' in mm 'mm'.
--

2.45.2

#4 lore raw
Quoted 19 lines · Yanjun Yang
Quoted 8 lines · Ard Biesheuvel
Quoted 6 lines · Yanjun Yang

Hi,
Apologies for not CCing the relevant maintainers in my previous email.

Quoted 1 line · Yanjun Yang
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

Commit 169f9102f9198b ("ARM: 9350/1: fault:
Implement copy_from_kernel_nofault_allowed()") added the function to check address before use. However, for devices without MMU, addr > TASK_SIZE will always fail.

Is that true? Doesn't it depend on the physical memory layout of the platform in question?

Quoted 12 lines

I only checked the ARM architecture, in arch/arm/include/asm/memory.h TASK_SIZE is
defined as 0xffffffff when CONFIG_MMU is not defined. Following is the code snippet.
/*
* The limitation of user task size can grow up to the end of free ram region.
* It is difficult to define and perhaps will never meet the original meaning
* of this define that was meant to.
* Fortunately, there is no reference for this in noMMU mode, for now. */
#define TASK_SIZE UL(0xffffffff)

OK, I stand corrected. Thanks for the explanation.

#5 lore raw
In reply to Yanjun Yang
Quoted 9 lines · Yanjun Yang

Apologies for not CCing the relevant maintainers in my previous email.

Quoted 6 lines · Yanjun Yang

Commit 169f9102f9198b ("ARM: 9350/1: fault:
Implement copy_from_kernel_nofault_allowed()") added the function to check address before use. However, for devices without MMU, addr > TASK_SIZE will always fail. This patch move this function after the #ifdef CONFIG_MMU statement.

What happened to this fix regression for a 6.9 regression? From here it looks like it fell through the cracks, but I might be missing something.

Quoted 1 line
Quoted 1 line

Also reported at https://bugzilla.kernel.org/show_bug.cgi?id=218953

Side note: this afaics ideally should be:

Ciao, Thorsten

Quoted 31 lines
Quoted 30 lines
---
 arch/arm/mm/fault.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mm/fault.c +2 -3
index 67c425341a95..ab01b51de559 100644
@@ -25,6 +25,8 @@
 
 #include "fault.h"
 
+#ifdef CONFIG_MMU
+
 bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
 {
        unsigned long addr = (unsigned long)unsafe_src;
@@ -32,8 +34,6 @@ bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
        return addr >= TASK_SIZE && ULONG_MAX - addr >= size;
 }
 
-#ifdef CONFIG_MMU
-
 /*
  * This is useful to dump out the page tables associated with
  * 'addr' in mm 'mm'.
--

2.45.2

#6 lore raw
Quoted 5 lines · Linux regression tracking (Thorsten Leemhuis)
Quoted 4 lines · Yanjun Yang

Apologies for not CCing the relevant maintainers in my previous email.

Quoted 1 line · Yanjun Yang
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

Commit 169f9102f9198b ("ARM: 9350/1: fault:
Implement copy_from_kernel_nofault_allowed()") added the function to check address before use. However, for devices without MMU, addr > TASK_SIZE will always fail. This patch move this function after the #ifdef CONFIG_MMU statement.

What happened to this fix regression for a 6.9 regression? From here it looks like it fell through the cracks, but I might be missing something.

This patch can be sent through rmk's ARM patch tracker, but if it's urgent, I could take it via my tree? It has Ard's Ack.

Signature · 1 line
Kees Cook
#7 lore raw
Quoted 12 lines · Kees Cook
Quoted 11 lines · Linux regression tracking (Thorsten Leemhuis)
Quoted 9 lines · Yanjun Yang

Apologies for not CCing the relevant maintainers in my previous email.

Quoted 6 lines · Yanjun Yang

Commit 169f9102f9198b ("ARM: 9350/1: fault:
Implement copy_from_kernel_nofault_allowed()") added the function to check address before use. However, for devices without MMU, addr > TASK_SIZE will always fail. This patch move this function after the #ifdef CONFIG_MMU statement.

Quoted 5 lines
Quoted 2 lines

What happened to this fix regression for a 6.9 regression? From here it looks like it fell through the cracks, but I might be missing something.

This patch can be sent through rmk's ARM patch tracker, but if it's urgent, I could take it via my tree? It has Ard's Ack.

I've been so busy with a high priority work issue that I've not been aware of this email thread until I saw it tonight (because I haven't been able to read much email!)

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!