Skip to contentSkip to conversation

selftests/seccomp: fix pointer type mismatch in UPROBE test

PATCH Superseded Nirbhay Sharma 4 participants 9 messages Oct 25, 2025 – Dec 3, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/seccomp: fix pointer type mismatch in UPROBE test

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.

---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/seccomp/seccomp_bpf.c +2 -1
index 874f17763536..e13ffe18ef95 100644
@@ -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)
Signature · 1 line
2.48.1
#1 lore raw
Quoted 3 lines · 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))),

just probed_uprobe right?

Quoted 4 lines

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

Quoted 28 lines

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.

---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/seccomp/seccomp_bpf.c +2 -1
index 874f17763536..e13ffe18ef95 100644
@@ -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)
Signature · 1 line
2.48.1
#2 lore raw

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).

#3 lore raw
In reply to Jiri Olsa

Hi Jiri,

Thank you for the review and for catching that inaccuracy!

Quoted 1 line · Jiri Olsa

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.

Quoted 1 line

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

#4 lore raw

PATCH v2 1/1 selftests/seccomp: fix pointer type mismatch in UPROBE test

In reply to Jiri Olsa

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).

---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/seccomp/seccomp_bpf.c +2 -1
index 874f17763536..e13ffe18ef95 100644
@@ -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)
Signature · 1 line
2.48.1
Reviewed-by on v2 1/1
#5 lore raw
Quoted 6 lines · 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:

Just as a curiosity to share: I found a few tangential issues and reported them as https://gcc.gnu.org/PR122427.

Quoted 11 lines

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).

Quoted 19 lines
---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/seccomp/seccomp_bpf.c +2 -1
index 874f17763536..e13ffe18ef95 100644
@@ -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)
#6 lore raw
In reply to Nirbhay Sharma
Quoted 13 lines · 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.

Quoted 5 lines

This error appears with compilers that enable Control Flow Integrity (CFI) protection via -fcf-protection, such as Clang 19.1.2 (default on Fedora).

thanks,
jirka

Quoted 21 lines
---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/seccomp/seccomp_bpf.c +2 -1
index 874f17763536..e13ffe18ef95 100644
@@ -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)
Signature · 1 line
2.48.1
#7 lore raw
In reply to Nirbhay Sharma
Quoted 27 lines · 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).

---
  tools/testing/selftests/seccomp/seccomp_bpf.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/seccomp/seccomp_bpf.c +0 -0
index 874f17763536..e13ffe18ef95 100644

tools/testing/selftests/seccomp/seccomp_bpf.c FIXTURE_SETUP(UPROBE) · line 5179

Quoted 9 lines
tools/testing/selftests/seccomp/seccomp_bpf.c +2 -1
@@ -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

maintainer
#8 lore raw
Quoted 40 lines · Nirbhay Sharma
Quoted 27 lines · 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).

---
  tools/testing/selftests/seccomp/seccomp_bpf.c | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/seccomp/seccomp_bpf.c +0 -0
index 874f17763536..e13ffe18ef95 100644

tools/testing/selftests/seccomp/seccomp_bpf.c FIXTURE_SETUP(UPROBE) · line 5177

Quoted 7 lines
tools/testing/selftests/seccomp/seccomp_bpf.c +2 -1
@@ -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,

Quoted 6 lines

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.

Hi Kees,

Is it okay to take this patch through my tree?

thanks,
-- Shuah