ARM: fault: Implement copy_from_kernel_nofault_allowed()
PATCH 1/1 ARM: fault: Implement copy_from_kernel_nofault_allowed()
Under PAN emulation when dumping backtraces from things like the LKDTM EXEC_USERSPACE test[1], a double fault (which would hang a CPU) would happen because of dump_instr() attempting to read a userspace address. Make sure copy_from_kernel_nofault() does not attempt this any more.
--- arch/arm/mm/fault.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/mm/fault.c +7 -0
@@ -25,6 +25,13 @@#include "fault.h" +bool copy_from_kernel_nofault_allowed (const void *unsafe_src,size_t size) +{ +unsigned long addr = (unsigned long )unsafe_src; + +return addr >=TASK_SIZE &&ULONG_MAX - addr >= size; +} +#ifdef CONFIG_MMU /*
Signature · 1 line
2.34.1
Quoted 7 lines · Kees Cook
Under PAN emulation when dumping backtraces from things like the LKDTM
EXEC_USERSPACEtest[1], a double fault (which would hang a CPU) would happen because ofdump_instr()attempting to read a userspace address. Make surecopy_from_kernel_nofault()does not attempt this any more.
Quoted 10 lines
Reported-by Mark Brown <[email protected]>Suggested-by "Russell King (Oracle)" <[email protected]>Cc Russell King <[email protected]>Cc Ard Biesheuvel <[email protected]>Cc Wang Kefeng <[email protected]>Cc Andrew Morton <[email protected]>Cc Ben Hutchings <[email protected]>Signed-off-by Kees Cook <[email protected]>
Quoted 25 lines
--- arch/arm/mm/fault.c | 7 +++++++ 1 file changed, 7 insertions(+)arch/arm/mm/fault.c +7
-1@@ -25,6 +25,13 @@#include "fault.h" +bool copy_from_kernel_nofault_allowed (const void *unsafe_src,size_t size) +{ +unsigned long addr = (unsigned long )unsafe_src; + +return addr >=TASK_SIZE &&ULONG_MAX - addr >= size; +} +#ifdef CONFIG_MMU /* -- 2.34.1
Quoted 5 lines · Kees Cook
Under PAN emulation when dumping backtraces from things like the LKDTM
EXEC_USERSPACEtest[1], a double fault (which would hang a CPU) would happen because ofdump_instr()attempting to read a userspace address. Make surecopy_from_kernel_nofault()does not attempt this any more.
This appears to fix the original issue:
https://lava.sirena.org.uk/scheduler/job/497571
(though so did your earlier patch) so:
Quoted 6 lines · Kees Cook
Under PAN emulation when dumping backtraces from things like the LKDTM
EXEC_USERSPACEtest[1], a double fault (which would hang a CPU) would happen because ofdump_instr()attempting to read a userspace address. Make surecopy_from_kernel_nofault()does not attempt this any more.
Quoted 10 lines
Reported-by Mark Brown <[email protected]>Suggested-by "Russell King (Oracle)" <[email protected]>Cc Russell King <[email protected]>Cc Ard Biesheuvel <[email protected]>Cc Wang Kefeng <[email protected]>Cc Andrew Morton <[email protected]>Cc Ben Hutchings <[email protected]>Signed-off-by Kees Cook <[email protected]>
Russell, do you mind if I carry in my tree the 3 ARM patches I sent? They're mostly pretty trivial, and they've been in "Incoming"[1] for 2 weeks but haven't shown up in -next yet. I'd really like them to get some soak time, and for them to reach the v6.9 merge window in time.
Please let me know what you think. :) Thanks!
-Kees
[1] https://www.arm.linux.org.uk/developer/patches/section.php?section=0
Signature · 1 line
Kees Cook
Russell King (Oracle)
maintainerQuoted 18 lines · Kees Cook
Quoted 6 lines · Kees Cook
Under PAN emulation when dumping backtraces from things like the LKDTM
EXEC_USERSPACEtest[1], a double fault (which would hang a CPU) would happen because ofdump_instr()attempting to read a userspace address. Make surecopy_from_kernel_nofault()does not attempt this any more.Quoted 10 lines
Reported-by Mark Brown <[email protected]>Suggested-by "Russell King (Oracle)" <[email protected]>Cc Russell King <[email protected]>Cc Ard Biesheuvel <[email protected]>Cc Wang Kefeng <[email protected]>Cc Andrew Morton <[email protected]>Cc Ben Hutchings <[email protected]>Signed-off-by Kees Cook <[email protected]>
Quoted 4 lines
Russell, do you mind if I carry in my tree the 3 ARM patches I sent? They're mostly pretty trivial, and they've been in "Incoming"[1] for 2 weeks but haven't shown up in -next yet. I'd really like them to get some soak time, and for them to reach the v6.9 merge window in time.
They can't show up in -next at the moment because the machine that hosts my git tree is being moved between data centres. This was originally flagged as a same-day (Tuesday) move, then next day, then it'll be back online on Saturday. That's the last update that we've had.
As I don't believe my GPG key has the necessary signatures on, I don't believe I can get a kernel.org account. I'm not even sure whether my gpg key is even correct for that - and at the moment I just glaze over reading the kernel.org gpg documentation.
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!
Russell King (Oracle)
maintainerQuoted 29 lines · Russell King (Oracle)
Quoted 18 lines · Kees Cook
Quoted 6 lines · Kees Cook
Under PAN emulation when dumping backtraces from things like the LKDTM
EXEC_USERSPACEtest[1], a double fault (which would hang a CPU) would happen because ofdump_instr()attempting to read a userspace address. Make surecopy_from_kernel_nofault()does not attempt this any more.Quoted 10 lines
Reported-by Mark Brown <[email protected]>Suggested-by "Russell King (Oracle)" <[email protected]>Cc Russell King <[email protected]>Cc Ard Biesheuvel <[email protected]>Cc Wang Kefeng <[email protected]>Cc Andrew Morton <[email protected]>Cc Ben Hutchings <[email protected]>Signed-off-by Kees Cook <[email protected]>Quoted 4 lines
Russell, do you mind if I carry in my tree the 3 ARM patches I sent? They're mostly pretty trivial, and they've been in "Incoming"[1] for 2 weeks but haven't shown up in -next yet. I'd really like them to get some soak time, and for them to reach the v6.9 merge window in time.
They can't show up in -next at the moment because the machine that hosts my git tree is being moved between data centres. This was originally flagged as a same-day (Tuesday) move, then next day, then it'll be back online on Saturday. That's the last update that we've had.
Quoted 4 lines
As I don't believe my GPG key has the necessary signatures on, I don't believe I can get a kernel.org account. I'm not even sure whether my gpg key is even correct for that - and at the moment I just glaze over reading the kernel.org gpg documentation.
I'll also point out that over the last two weeks, the first week I was in Cambridge attending a conference at Arm Ltd, and then I went down with full blown flu shortly there-after.
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!