* [PATCH] lkdtm: cfi: Fix type width for masking PAC bits
@ 2022-04-27 0:12 Kees Cook
2022-04-27 7:14 ` Geert Uytterhoeven
2022-04-27 22:39 ` Randy Dunlap
0 siblings, 2 replies; 3+ messages in thread
From: Kees Cook @ 2022-04-27 0:12 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Kees Cook, kernel test robot, Geert Uytterhoeven, Arnd Bergmann,
Dan Li, linux-kernel, linux-hardening
The masking for PAC bits wasn't handling 32-bit architectures correctly.
Replace the u64 cast with uintptr_t.
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Link: https://lore.kernel.org/lkml/CAMuHMdVz-J-1ZQ08u0bsQihDkcRmEPrtX5B_oRJ+Ns5jrasnUw@mail.gmail.com
Fixes: 2e53b877dc12 ("lkdtm: Add CFI_BACKWARD to test ROP mitigations")
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/misc/lkdtm/cfi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/lkdtm/cfi.c b/drivers/misc/lkdtm/cfi.c
index 804965a480b7..666a7f4bc137 100644
--- a/drivers/misc/lkdtm/cfi.c
+++ b/drivers/misc/lkdtm/cfi.c
@@ -59,7 +59,7 @@ static void lkdtm_CFI_FORWARD_PROTO(void)
#endif
#define no_pac_addr(addr) \
- ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
+ ((__force __typeof__(addr))((uintptr_t)(addr) | PAGE_OFFSET))
/* The ultimate ROP gadget. */
static noinline __no_ret_protection
--
2.32.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lkdtm: cfi: Fix type width for masking PAC bits
2022-04-27 0:12 [PATCH] lkdtm: cfi: Fix type width for masking PAC bits Kees Cook
@ 2022-04-27 7:14 ` Geert Uytterhoeven
2022-04-27 22:39 ` Randy Dunlap
1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2022-04-27 7:14 UTC (permalink / raw)
To: Kees Cook
Cc: Greg Kroah-Hartman, kernel test robot, Arnd Bergmann, Dan Li,
Linux Kernel Mailing List, linux-hardening
Hi Kees,
On Wed, Apr 27, 2022 at 2:12 AM Kees Cook <keescook@chromium.org> wrote:
> The masking for PAC bits wasn't handling 32-bit architectures correctly.
> Replace the u64 cast with uintptr_t.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Link: https://lore.kernel.org/lkml/CAMuHMdVz-J-1ZQ08u0bsQihDkcRmEPrtX5B_oRJ+Ns5jrasnUw@mail.gmail.com
> Fixes: 2e53b877dc12 ("lkdtm: Add CFI_BACKWARD to test ROP mitigations")
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Kees Cook <keescook@chromium.org>
Thank you, that fixes the m68k allmodconfig build, so
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
> --- a/drivers/misc/lkdtm/cfi.c
> +++ b/drivers/misc/lkdtm/cfi.c
> @@ -59,7 +59,7 @@ static void lkdtm_CFI_FORWARD_PROTO(void)
> #endif
>
> #define no_pac_addr(addr) \
> - ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
> + ((__force __typeof__(addr))((uintptr_t)(addr) | PAGE_OFFSET))
Not related to this patch, but "| PAGE_OFFSET" is not identical
to "+ PAGE_OFFSET" for large kernel sizes.
More specifically, I'm thinking about platforms where "large" would
be >= 32 MiB:
arch/mips/include/asm/mach-ar7/spaces.h:#define PAGE_OFFSET
_AC(0x94000000, UL)
or >= 128 MiB:
arch/x86/Kconfig: default 0x78000000 if VMSPLIT_2G_OPT
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] lkdtm: cfi: Fix type width for masking PAC bits
2022-04-27 0:12 [PATCH] lkdtm: cfi: Fix type width for masking PAC bits Kees Cook
2022-04-27 7:14 ` Geert Uytterhoeven
@ 2022-04-27 22:39 ` Randy Dunlap
1 sibling, 0 replies; 3+ messages in thread
From: Randy Dunlap @ 2022-04-27 22:39 UTC (permalink / raw)
To: Kees Cook, Greg Kroah-Hartman
Cc: kernel test robot, Geert Uytterhoeven, Arnd Bergmann, Dan Li,
linux-kernel, linux-hardening
On 4/26/22 17:12, Kees Cook wrote:
> The masking for PAC bits wasn't handling 32-bit architectures correctly.
> Replace the u64 cast with uintptr_t.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Link: https://lore.kernel.org/lkml/CAMuHMdVz-J-1ZQ08u0bsQihDkcRmEPrtX5B_oRJ+Ns5jrasnUw@mail.gmail.com
> Fixes: 2e53b877dc12 ("lkdtm: Add CFI_BACKWARD to test ROP mitigations")
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Kees Cook <keescook@chromium.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
fwiw
Thanks.
> ---
> drivers/misc/lkdtm/cfi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/lkdtm/cfi.c b/drivers/misc/lkdtm/cfi.c
> index 804965a480b7..666a7f4bc137 100644
> --- a/drivers/misc/lkdtm/cfi.c
> +++ b/drivers/misc/lkdtm/cfi.c
> @@ -59,7 +59,7 @@ static void lkdtm_CFI_FORWARD_PROTO(void)
> #endif
>
> #define no_pac_addr(addr) \
> - ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
> + ((__force __typeof__(addr))((uintptr_t)(addr) | PAGE_OFFSET))
>
> /* The ultimate ROP gadget. */
> static noinline __no_ret_protection
--
~Randy
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-27 22:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-27 0:12 [PATCH] lkdtm: cfi: Fix type width for masking PAC bits Kees Cook
2022-04-27 7:14 ` Geert Uytterhoeven
2022-04-27 22:39 ` Randy Dunlap
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.