lkdtm: cfi: Make PAC test work with GCC 7 and 8
authorKristina Martsenko <kristina.martsenko@arm.com>
Fri, 9 Dec 2022 17:34:41 +0000 (17:34 +0000)
committerKees Cook <keescook@chromium.org>
Thu, 15 Dec 2022 00:05:09 +0000 (16:05 -0800)
commitf68022ae0aeb0803450e05abc0e984027c33ef1b
treea81e2da4f4a3a084029bbc12b96112c39c47d1ae
parent00dd027f721e0458418f7750d8a5a664ed3e5994
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: 2e53b877dc12 ("lkdtm: Add CFI_BACKWARD to test ROP mitigations")
Reported-by: Daniel Díaz <daniel.diaz@linaro.org>
Signed-off-by: Kristina Martsenko <kristina.martsenko@arm.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/all/CAEUSe78kDPxQmQqCWW-_9LCgJDFhAeMoVBFnX9QLx18Z4uT4VQ@mail.gmail.com/
drivers/misc/lkdtm/cfi.c