Skip to content

Commit f68022a

Browse files
kristina-martsenkokees
authored andcommitted
lkdtm: cfi: Make PAC test work with GCC 7 and 8
The CFI test uses the branch-protection=none compiler attribute to disable PAC return address protection on a function. While newer GCC versions support this attribute, older versions (GCC 7 and 8) instead supported the sign-return-address=none attribute, leading to a build failure when the test is built with older compilers. Fix it by checking which attribute is supported and using the correct one. Fixes: 2e53b87 ("lkdtm: Add CFI_BACKWARD to test ROP mitigations") Reported-by: Daniel Díaz <[email protected]> Signed-off-by: Kristina Martsenko <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/all/CAEUSe78kDPxQmQqCWW-_9LCgJDFhAeMoVBFnX9QLx18Z4uT4VQ@mail.gmail.com/
1 parent 00dd027 commit f68022a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/misc/lkdtm/cfi.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ static void lkdtm_CFI_FORWARD_PROTO(void)
5454
# ifdef CONFIG_ARM64_BTI_KERNEL
5555
# define __no_pac "branch-protection=bti"
5656
# else
57-
# define __no_pac "branch-protection=none"
57+
# ifdef CONFIG_CC_HAS_BRANCH_PROT_PAC_RET
58+
# define __no_pac "branch-protection=none"
59+
# else
60+
# define __no_pac "sign-return-address=none"
61+
# endif
5862
# endif
5963
# define __no_ret_protection __noscs __attribute__((__target__(__no_pac)))
6064
#else

0 commit comments

Comments
 (0)