From: Kees Cook Date: Wed, 27 Apr 2022 00:12:26 +0000 (-0700) Subject: lkdtm: cfi: Fix type width for masking PAC bits X-Git-Tag: v5.19~348^2~102 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=77acbdc0f314b7040afcc02be267fe71161f4ac7;p=mirror_ubuntu-kernels.git lkdtm: cfi: Fix type width for masking PAC bits The masking for PAC bits wasn't handling 32-bit architectures correctly. Replace the u64 cast with uintptr_t. 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 Cc: Arnd Bergmann Reported-by: kernel test robot Reported-by: Geert Uytterhoeven Tested-by: Geert Uytterhoeven Tested-by: Randy Dunlap Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20220427001226.1224704-1-keescook@chromium.org Signed-off-by: Greg Kroah-Hartman --- 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