* [PATCH] ARM: fault: Implement copy_from_kernel_nofault_allowed()
@ 2024-01-23 1:12 Kees Cook
2024-01-23 13:44 ` Ard Biesheuvel
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Kees Cook @ 2024-01-23 1:12 UTC (permalink / raw)
To: Russell King
Cc: Kees Cook, Mark Brown, Ard Biesheuvel, Wang Kefeng, Andrew Morton,
Ben Hutchings, linux-arm-kernel, Russell King (Oracle),
Hugh Dickins, linux-kernel, linux-hardening
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.
Reported-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/all/202401181125.D48DCB4C@keescook/ [1]
Suggested-by: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Wang Kefeng <wangkefeng.wang@huawei.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
arch/arm/mm/fault.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index e804432e905e..bc5b959b6f90 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] ARM: fault: Implement copy_from_kernel_nofault_allowed()
2024-01-23 1:12 [PATCH] ARM: fault: Implement copy_from_kernel_nofault_allowed() Kees Cook
@ 2024-01-23 13:44 ` Ard Biesheuvel
2024-01-23 19:02 ` Mark Brown
2024-02-21 6:39 ` Kees Cook
2 siblings, 0 replies; 6+ messages in thread
From: Ard Biesheuvel @ 2024-01-23 13:44 UTC (permalink / raw)
To: Kees Cook
Cc: Russell King, Mark Brown, Wang Kefeng, Andrew Morton,
Ben Hutchings, linux-arm-kernel, Russell King (Oracle),
Hugh Dickins, linux-kernel, linux-hardening
On Tue, 23 Jan 2024 at 02:12, Kees Cook <keescook@chromium.org> wrote:
>
> 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.
>
> Reported-by: Mark Brown <broonie@kernel.org>
> Link: https://lore.kernel.org/all/202401181125.D48DCB4C@keescook/ [1]
> Suggested-by: "Russell King (Oracle)" <linux@armlinux.org.uk>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Wang Kefeng <wangkefeng.wang@huawei.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Ben Hutchings <ben@decadent.org.uk>
> Cc: linux-arm-kernel@lists.infradead.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
> ---
> arch/arm/mm/fault.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
> index e804432e905e..bc5b959b6f90 100644
> --- a/arch/arm/mm/fault.c
> +++ b/arch/arm/mm/fault.c
> @@ -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
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] ARM: fault: Implement copy_from_kernel_nofault_allowed()
2024-01-23 1:12 [PATCH] ARM: fault: Implement copy_from_kernel_nofault_allowed() Kees Cook
2024-01-23 13:44 ` Ard Biesheuvel
@ 2024-01-23 19:02 ` Mark Brown
2024-02-21 6:39 ` Kees Cook
2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2024-01-23 19:02 UTC (permalink / raw)
To: Kees Cook
Cc: Russell King, Ard Biesheuvel, Wang Kefeng, Andrew Morton,
Ben Hutchings, linux-arm-kernel, Russell King (Oracle),
Hugh Dickins, linux-kernel, linux-hardening
[-- Attachment #1.1: Type: text/plain, Size: 527 bytes --]
On Mon, Jan 22, 2024 at 05:12:38PM -0800, Kees Cook wrote:
> 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.
This appears to fix the original issue:
https://lava.sirena.org.uk/scheduler/job/497571
(though so did your earlier patch) so:
Tested-by: Mark Brown <broonie@kernel.org>
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: fault: Implement copy_from_kernel_nofault_allowed()
2024-01-23 1:12 [PATCH] ARM: fault: Implement copy_from_kernel_nofault_allowed() Kees Cook
2024-01-23 13:44 ` Ard Biesheuvel
2024-01-23 19:02 ` Mark Brown
@ 2024-02-21 6:39 ` Kees Cook
2024-02-21 11:29 ` Russell King (Oracle)
2 siblings, 1 reply; 6+ messages in thread
From: Kees Cook @ 2024-02-21 6:39 UTC (permalink / raw)
To: Russell King
Cc: Mark Brown, Ard Biesheuvel, Wang Kefeng, Andrew Morton,
Ben Hutchings, linux-arm-kernel, Russell King (Oracle),
Hugh Dickins, linux-kernel, linux-hardening
On Mon, Jan 22, 2024 at 05:12:38PM -0800, Kees Cook wrote:
> 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.
>
> Reported-by: Mark Brown <broonie@kernel.org>
> Link: https://lore.kernel.org/all/202401181125.D48DCB4C@keescook/ [1]
> Suggested-by: "Russell King (Oracle)" <linux@armlinux.org.uk>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Wang Kefeng <wangkefeng.wang@huawei.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Ben Hutchings <ben@decadent.org.uk>
> Cc: linux-arm-kernel@lists.infradead.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
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
--
Kees Cook
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: fault: Implement copy_from_kernel_nofault_allowed()
2024-02-21 6:39 ` Kees Cook
@ 2024-02-21 11:29 ` Russell King (Oracle)
2024-02-21 11:31 ` Russell King (Oracle)
0 siblings, 1 reply; 6+ messages in thread
From: Russell King (Oracle) @ 2024-02-21 11:29 UTC (permalink / raw)
To: Kees Cook
Cc: Mark Brown, Ard Biesheuvel, Wang Kefeng, Andrew Morton,
Ben Hutchings, linux-arm-kernel, Hugh Dickins, linux-kernel,
linux-hardening
On Tue, Feb 20, 2024 at 10:39:15PM -0800, Kees Cook wrote:
> On Mon, Jan 22, 2024 at 05:12:38PM -0800, Kees Cook wrote:
> > 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.
> >
> > Reported-by: Mark Brown <broonie@kernel.org>
> > Link: https://lore.kernel.org/all/202401181125.D48DCB4C@keescook/ [1]
> > Suggested-by: "Russell King (Oracle)" <linux@armlinux.org.uk>
> > Cc: Russell King <linux@armlinux.org.uk>
> > Cc: Ard Biesheuvel <ardb@kernel.org>
> > Cc: Wang Kefeng <wangkefeng.wang@huawei.com>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Ben Hutchings <ben@decadent.org.uk>
> > Cc: linux-arm-kernel@lists.infradead.org
> > Signed-off-by: Kees Cook <keescook@chromium.org>
>
> 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.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: fault: Implement copy_from_kernel_nofault_allowed()
2024-02-21 11:29 ` Russell King (Oracle)
@ 2024-02-21 11:31 ` Russell King (Oracle)
0 siblings, 0 replies; 6+ messages in thread
From: Russell King (Oracle) @ 2024-02-21 11:31 UTC (permalink / raw)
To: Kees Cook
Cc: Mark Brown, Ard Biesheuvel, Wang Kefeng, Andrew Morton,
Ben Hutchings, linux-arm-kernel, Hugh Dickins, linux-kernel,
linux-hardening
On Wed, Feb 21, 2024 at 11:29:38AM +0000, Russell King (Oracle) wrote:
> On Tue, Feb 20, 2024 at 10:39:15PM -0800, Kees Cook wrote:
> > On Mon, Jan 22, 2024 at 05:12:38PM -0800, Kees Cook wrote:
> > > 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.
> > >
> > > Reported-by: Mark Brown <broonie@kernel.org>
> > > Link: https://lore.kernel.org/all/202401181125.D48DCB4C@keescook/ [1]
> > > Suggested-by: "Russell King (Oracle)" <linux@armlinux.org.uk>
> > > Cc: Russell King <linux@armlinux.org.uk>
> > > Cc: Ard Biesheuvel <ardb@kernel.org>
> > > Cc: Wang Kefeng <wangkefeng.wang@huawei.com>
> > > Cc: Andrew Morton <akpm@linux-foundation.org>
> > > Cc: Ben Hutchings <ben@decadent.org.uk>
> > > Cc: linux-arm-kernel@lists.infradead.org
> > > Signed-off-by: Kees Cook <keescook@chromium.org>
> >
> > 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.
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.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-02-21 11:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-23 1:12 [PATCH] ARM: fault: Implement copy_from_kernel_nofault_allowed() Kees Cook
2024-01-23 13:44 ` Ard Biesheuvel
2024-01-23 19:02 ` Mark Brown
2024-02-21 6:39 ` Kees Cook
2024-02-21 11:29 ` Russell King (Oracle)
2024-02-21 11:31 ` Russell King (Oracle)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).