* [PATCH] selftests/seccomp: fix pointer type mismatch in UPROBE test @ 2025-10-25 18:49 Nirbhay Sharma 2025-10-25 21:18 ` Jiri Olsa 0 siblings, 1 reply; 8+ messages in thread From: Nirbhay Sharma @ 2025-10-25 18:49 UTC (permalink / raw) To: Kees Cook, Shuah Khan Cc: Andy Lutomirski, Will Drewry, linux-kselftest, linux-kernel, bpf, khalid, david.hunter.linux, linux-kernel-mentees, Nirbhay Sharma Fix compilation error in UPROBE_setup caused by pointer type mismatch in ternary expression. The probed_uretprobe and probed_uprobe function pointers have different type attributes (__attribute__((nocf_check))), which causes the conditional operator to fail with: seccomp_bpf.c:5175:74: error: pointer type mismatch in conditional expression [-Wincompatible-pointer-types] Cast both function pointers to 'const void *' to match the expected parameter type of get_uprobe_offset(), resolving the type mismatch while preserving the function selection logic. Signed-off-by: Nirbhay Sharma <nirbhay.lkd@gmail.com> --- tools/testing/selftests/seccomp/seccomp_bpf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index 874f17763536..e13ffe18ef95 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -5172,7 +5172,8 @@ FIXTURE_SETUP(UPROBE) ASSERT_GE(bit, 0); } - offset = get_uprobe_offset(variant->uretprobe ? probed_uretprobe : probed_uprobe); + offset = get_uprobe_offset(variant->uretprobe ? + (const void *)probed_uretprobe : (const void *)probed_uprobe); ASSERT_GE(offset, 0); if (variant->uretprobe) -- 2.48.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] selftests/seccomp: fix pointer type mismatch in UPROBE test 2025-10-25 18:49 [PATCH] selftests/seccomp: fix pointer type mismatch in UPROBE test Nirbhay Sharma @ 2025-10-25 21:18 ` Jiri Olsa 2025-10-26 0:25 ` Sam James ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Jiri Olsa @ 2025-10-25 21:18 UTC (permalink / raw) To: Nirbhay Sharma Cc: Kees Cook, Shuah Khan, Andy Lutomirski, Will Drewry, linux-kselftest, linux-kernel, bpf, khalid, david.hunter.linux, linux-kernel-mentees On Sun, Oct 26, 2025 at 12:19:04AM +0530, Nirbhay Sharma wrote: > Fix compilation error in UPROBE_setup caused by pointer type mismatch > in ternary expression. The probed_uretprobe and probed_uprobe function > pointers have different type attributes (__attribute__((nocf_check))), just probed_uprobe right? > which causes the conditional operator to fail with: > > seccomp_bpf.c:5175:74: error: pointer type mismatch in conditional > expression [-Wincompatible-pointer-types] curious what compiler do you see that with? gcc-15 is silent, the change looks good to me thanks, jirka > > Cast both function pointers to 'const void *' to match the expected > parameter type of get_uprobe_offset(), resolving the type mismatch > while preserving the function selection logic. > > Signed-off-by: Nirbhay Sharma <nirbhay.lkd@gmail.com> > --- > tools/testing/selftests/seccomp/seccomp_bpf.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c > index 874f17763536..e13ffe18ef95 100644 > --- a/tools/testing/selftests/seccomp/seccomp_bpf.c > +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c > @@ -5172,7 +5172,8 @@ FIXTURE_SETUP(UPROBE) > ASSERT_GE(bit, 0); > } > > - offset = get_uprobe_offset(variant->uretprobe ? probed_uretprobe : probed_uprobe); > + offset = get_uprobe_offset(variant->uretprobe ? > + (const void *)probed_uretprobe : (const void *)probed_uprobe); > ASSERT_GE(offset, 0); > > if (variant->uretprobe) > -- > 2.48.1 > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] selftests/seccomp: fix pointer type mismatch in UPROBE test 2025-10-25 21:18 ` Jiri Olsa @ 2025-10-26 0:25 ` Sam James 2025-10-26 8:58 ` Nirbhay Sharma 2025-10-26 9:12 ` [PATCH v2] " Nirbhay Sharma 2 siblings, 0 replies; 8+ messages in thread From: Sam James @ 2025-10-26 0:25 UTC (permalink / raw) To: olsajiri Cc: bpf, david.hunter.linux, kees, khalid, linux-kernel-mentees, linux-kernel, linux-kselftest, luto, nirbhay.lkd, shuah, wad I tried to reproduce it with a small testcase and I could reproduce the error with -fcf-protection and not without (where I get a warning that the nocf_check attribute is ignored b/c of no flag). ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] selftests/seccomp: fix pointer type mismatch in UPROBE test 2025-10-25 21:18 ` Jiri Olsa 2025-10-26 0:25 ` Sam James @ 2025-10-26 8:58 ` Nirbhay Sharma 2025-10-26 9:12 ` [PATCH v2] " Nirbhay Sharma 2 siblings, 0 replies; 8+ messages in thread From: Nirbhay Sharma @ 2025-10-26 8:58 UTC (permalink / raw) To: Jiri Olsa Cc: Kees Cook, Shuah Khan, Andy Lutomirski, Will Drewry, linux-kselftest, linux-kernel, bpf, khalid, david.hunter.linux, linux-kernel-mentees Hi Jiri, Thank you for the review and for catching that inaccuracy! On 10/26/25 2:48 AM, Jiri Olsa wrote: > just probed_uprobe right? Yes, you're absolutely correct. Only probed_uprobe has the __attribute__((nocf_check)) attribute. I apologize for the confusion in my original commit message. I'll fix this in v2. > curious what compiler do you see that with? I am seeing this error with Clang 19.1.2 on Fedora, which enables -fcf-protection=full by default. As Sam confirmed, the error occurs specifically when CFI protection is enabled via -fcf-protection. GCC without this flag treats it as a warning or ignores the nocf_check attribute entirely. I'll send v2 with the corrected commit message. Thanks again for the review! Best regards, Nirbhay ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] selftests/seccomp: fix pointer type mismatch in UPROBE test 2025-10-25 21:18 ` Jiri Olsa 2025-10-26 0:25 ` Sam James 2025-10-26 8:58 ` Nirbhay Sharma @ 2025-10-26 9:12 ` Nirbhay Sharma 2025-10-26 10:44 ` Sam James ` (2 more replies) 2 siblings, 3 replies; 8+ messages in thread From: Nirbhay Sharma @ 2025-10-26 9:12 UTC (permalink / raw) To: Kees Cook, Shuah Khan Cc: Andy Lutomirski, Will Drewry, Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, linux-kselftest, linux-kernel, bpf, llvm, khalid, david.hunter.linux, linux-kernel-mentees, Jiri Olsa, sam, Nirbhay Sharma Fix compilation error in UPROBE_setup caused by pointer type mismatch in the ternary expression when compiled with -fcf-protection. The probed_uprobe function pointer has the __attribute__((nocf_check)) attribute, which causes the conditional operator to fail when combined with the regular probed_uretprobe function pointer: seccomp_bpf.c:5175:74: error: pointer type mismatch in conditional expression [-Wincompatible-pointer-types] Cast both function pointers to 'const void *' to match the expected parameter type of get_uprobe_offset(), resolving the type mismatch while preserving the function selection logic. This error appears with compilers that enable Control Flow Integrity (CFI) protection via -fcf-protection, such as Clang 19.1.2 (default on Fedora). Signed-off-by: Nirbhay Sharma <nirbhay.lkd@gmail.com> --- tools/testing/selftests/seccomp/seccomp_bpf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index 874f17763536..e13ffe18ef95 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -5172,7 +5172,8 @@ FIXTURE_SETUP(UPROBE) ASSERT_GE(bit, 0); } - offset = get_uprobe_offset(variant->uretprobe ? probed_uretprobe : probed_uprobe); + offset = get_uprobe_offset(variant->uretprobe ? + (const void *)probed_uretprobe : (const void *)probed_uprobe); ASSERT_GE(offset, 0); if (variant->uretprobe) -- 2.48.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] selftests/seccomp: fix pointer type mismatch in UPROBE test 2025-10-26 9:12 ` [PATCH v2] " Nirbhay Sharma @ 2025-10-26 10:44 ` Sam James 2025-10-27 8:14 ` Jiri Olsa 2025-11-25 11:20 ` Nirbhay Sharma 2 siblings, 0 replies; 8+ messages in thread From: Sam James @ 2025-10-26 10:44 UTC (permalink / raw) To: Nirbhay Sharma Cc: Kees Cook, Shuah Khan, Andy Lutomirski, Will Drewry, Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, linux-kselftest, linux-kernel, bpf, llvm, khalid, david.hunter.linux, linux-kernel-mentees, Jiri Olsa Nirbhay Sharma <nirbhay.lkd@gmail.com> writes: > Fix compilation error in UPROBE_setup caused by pointer type mismatch > in the ternary expression when compiled with -fcf-protection. The > probed_uprobe function pointer has the __attribute__((nocf_check)) > attribute, which causes the conditional operator to fail when combined > with the regular probed_uretprobe function pointer: > Just as a curiosity to share: I found a few tangential issues and reported them as https://gcc.gnu.org/PR122427. > seccomp_bpf.c:5175:74: error: pointer type mismatch in conditional > expression [-Wincompatible-pointer-types] > > Cast both function pointers to 'const void *' to match the expected > parameter type of get_uprobe_offset(), resolving the type mismatch > while preserving the function selection logic. > > This error appears with compilers that enable Control Flow Integrity > (CFI) protection via -fcf-protection, such as Clang 19.1.2 (default > on Fedora). > Reviewed-by: Sam James <sam@gentoo.org> > Signed-off-by: Nirbhay Sharma <nirbhay.lkd@gmail.com> > --- > tools/testing/selftests/seccomp/seccomp_bpf.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c > index 874f17763536..e13ffe18ef95 100644 > --- a/tools/testing/selftests/seccomp/seccomp_bpf.c > +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c > @@ -5172,7 +5172,8 @@ FIXTURE_SETUP(UPROBE) > ASSERT_GE(bit, 0); > } > > - offset = get_uprobe_offset(variant->uretprobe ? probed_uretprobe : probed_uprobe); > + offset = get_uprobe_offset(variant->uretprobe ? > + (const void *)probed_uretprobe : (const void *)probed_uprobe); > ASSERT_GE(offset, 0); > > if (variant->uretprobe) ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] selftests/seccomp: fix pointer type mismatch in UPROBE test 2025-10-26 9:12 ` [PATCH v2] " Nirbhay Sharma 2025-10-26 10:44 ` Sam James @ 2025-10-27 8:14 ` Jiri Olsa 2025-11-25 11:20 ` Nirbhay Sharma 2 siblings, 0 replies; 8+ messages in thread From: Jiri Olsa @ 2025-10-27 8:14 UTC (permalink / raw) To: Nirbhay Sharma Cc: Kees Cook, Shuah Khan, Andy Lutomirski, Will Drewry, Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, linux-kselftest, linux-kernel, bpf, llvm, khalid, david.hunter.linux, linux-kernel-mentees, Jiri Olsa, sam On Sun, Oct 26, 2025 at 02:42:33PM +0530, Nirbhay Sharma wrote: > Fix compilation error in UPROBE_setup caused by pointer type mismatch > in the ternary expression when compiled with -fcf-protection. The > probed_uprobe function pointer has the __attribute__((nocf_check)) > attribute, which causes the conditional operator to fail when combined > with the regular probed_uretprobe function pointer: > > seccomp_bpf.c:5175:74: error: pointer type mismatch in conditional > expression [-Wincompatible-pointer-types] > > Cast both function pointers to 'const void *' to match the expected > parameter type of get_uprobe_offset(), resolving the type mismatch > while preserving the function selection logic. > > This error appears with compilers that enable Control Flow Integrity > (CFI) protection via -fcf-protection, such as Clang 19.1.2 (default > on Fedora). > > Signed-off-by: Nirbhay Sharma <nirbhay.lkd@gmail.com> Reviwed-by: Jiri Olsa <jolsa@kernel.org> thanks, jirka > --- > tools/testing/selftests/seccomp/seccomp_bpf.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c > index 874f17763536..e13ffe18ef95 100644 > --- a/tools/testing/selftests/seccomp/seccomp_bpf.c > +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c > @@ -5172,7 +5172,8 @@ FIXTURE_SETUP(UPROBE) > ASSERT_GE(bit, 0); > } > > - offset = get_uprobe_offset(variant->uretprobe ? probed_uretprobe : probed_uprobe); > + offset = get_uprobe_offset(variant->uretprobe ? > + (const void *)probed_uretprobe : (const void *)probed_uprobe); > ASSERT_GE(offset, 0); > > if (variant->uretprobe) > -- > 2.48.1 > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] selftests/seccomp: fix pointer type mismatch in UPROBE test 2025-10-26 9:12 ` [PATCH v2] " Nirbhay Sharma 2025-10-26 10:44 ` Sam James 2025-10-27 8:14 ` Jiri Olsa @ 2025-11-25 11:20 ` Nirbhay Sharma 2 siblings, 0 replies; 8+ messages in thread From: Nirbhay Sharma @ 2025-11-25 11:20 UTC (permalink / raw) To: Kees Cook, Shuah Khan Cc: Andy Lutomirski, Will Drewry, Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, linux-kselftest, linux-kernel, bpf, llvm, khalid, david.hunter.linux, linux-kernel-mentees, Jiri Olsa, sam On 10/26/25 2:42 PM, Nirbhay Sharma wrote: > Fix compilation error in UPROBE_setup caused by pointer type mismatch > in the ternary expression when compiled with -fcf-protection. The > probed_uprobe function pointer has the __attribute__((nocf_check)) > attribute, which causes the conditional operator to fail when combined > with the regular probed_uretprobe function pointer: > > seccomp_bpf.c:5175:74: error: pointer type mismatch in conditional > expression [-Wincompatible-pointer-types] > > Cast both function pointers to 'const void *' to match the expected > parameter type of get_uprobe_offset(), resolving the type mismatch > while preserving the function selection logic. > > This error appears with compilers that enable Control Flow Integrity > (CFI) protection via -fcf-protection, such as Clang 19.1.2 (default > on Fedora). > > Signed-off-by: Nirbhay Sharma <nirbhay.lkd@gmail.com> > --- > tools/testing/selftests/seccomp/seccomp_bpf.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c > index 874f17763536..e13ffe18ef95 100644 > --- a/tools/testing/selftests/seccomp/seccomp_bpf.c > +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c > @@ -5172,7 +5172,8 @@ FIXTURE_SETUP(UPROBE) > ASSERT_GE(bit, 0); > } > > - offset = get_uprobe_offset(variant->uretprobe ? probed_uretprobe : probed_uprobe); > + offset = get_uprobe_offset(variant->uretprobe ? > + (const void *)probed_uretprobe : (const void *)probed_uprobe); > ASSERT_GE(offset, 0); > > if (variant->uretprobe) Hi all, I'm following up on this patch that fixes the pointer type mismatch in UPROBE_setup when building with -fcf-protection. It resolves the incompatible-pointer-types error seen with Clang 19. Please let me know if there are any comments or some changes needed. Thanks, Nirbhay Sharma ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-11-25 11:20 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-10-25 18:49 [PATCH] selftests/seccomp: fix pointer type mismatch in UPROBE test Nirbhay Sharma 2025-10-25 21:18 ` Jiri Olsa 2025-10-26 0:25 ` Sam James 2025-10-26 8:58 ` Nirbhay Sharma 2025-10-26 9:12 ` [PATCH v2] " Nirbhay Sharma 2025-10-26 10:44 ` Sam James 2025-10-27 8:14 ` Jiri Olsa 2025-11-25 11:20 ` Nirbhay Sharma
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox