Skip to contentSkip to conversation

selftests/ftrace: adjust offset for kprobe syntax error test

PATCH In review Hari Bathini 3 participants 6 messages Nov 29, 2024 – Dec 5, 2024

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

PATCH v2 1/1 selftests/ftrace: adjust offset for kprobe syntax error test

In 'NOFENTRY_ARGS' test case for syntax check, any offset X of vfs_read+X except function entry offset (0) fits the criterion, even if that offset is not at instruction boundary, as the parser comes before probing. But with "ENDBR64" instruction on x86, offset 4 is treated as function entry. So, X can't be 4 as well. Thus, 8 was used as offset for the test case. On 64-bit powerpc though, any offset <= 16 can be considered function entry depending on build configuration (see arch_kprobe_on_func_entry() for implementation details). So, use vfs_read+20 to accommodate that scenario too.

---

Changes in v2:
* Use 20 as offset for all arches.

 .../selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc +1 -1
index a16c6a6f6055..8f1c58f0c239 100644
@@ -111,7 +111,7 @@ check_error 'p vfs_read $arg* ^$arg*'		# DOUBLE_ARGS
 if !grep -q 'kernel return probes support:' README; then
 check_error 'r vfs_read ^$arg*'			# NOFENTRY_ARGS
 fi
-check_error 'p vfs_read+8 ^$arg*'		# NOFENTRY_ARGS
+check_error 'p vfs_read+20 ^$arg*'		# NOFENTRY_ARGS
 check_error 'p vfs_read ^hoge'			# NO_BTFARG
 check_error 'p kfree ^$arg10'			# NO_BTFARG (exceed the number of parameters)
 check_error 'r kfree ^$retval'			# NO_RETVAL
Signature · 1 line
2.47.0
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 10 lines · On Sat, 30 Nov 2024 01:56:21 +0530 Hari Bathini <[email protected]> wrote:

In 'NOFENTRY_ARGS' test case for syntax check, any offset X of vfs_read+X except function entry offset (0) fits the criterion, even if that offset is not at instruction boundary, as the parser comes before probing. But with "ENDBR64" instruction on x86, offset 4 is treated as function entry. So, X can't be 4 as well. Thus, 8 was used as offset for the test case. On 64-bit powerpc though, any offset <= 16 can be considered function entry depending on build configuration (see arch_kprobe_on_func_entry() for implementation details). So, use vfs_read+20 to accommodate that scenario too.

Quoted 2 lines

Shuah,

Can you take this through your tree?

Thanks,

-- Steve

Quoted 22 lines

---

Changes in v2:
* Use 20 as offset for all arches.

 .../selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc +1 -1
index a16c6a6f6055..8f1c58f0c239 100644
@@ -111,7 +111,7 @@ check_error 'p vfs_read $arg* ^$arg*'		# DOUBLE_ARGS
 if !grep -q 'kernel return probes support:' README; then
 check_error 'r vfs_read ^$arg*'			# NOFENTRY_ARGS
 fi
-check_error 'p vfs_read+8 ^$arg*'		# NOFENTRY_ARGS
+check_error 'p vfs_read+20 ^$arg*'		# NOFENTRY_ARGS
 check_error 'p vfs_read ^hoge'			# NO_BTFARG
 check_error 'p kfree ^$arg10'			# NO_BTFARG (exceed the number of parameters)
 check_error 'r kfree ^$retval'			# NO_RETVAL
maintainer
#2 lore raw
Quoted 13 lines · Steven Rostedt
Quoted 10 lines · On Sat, 30 Nov 2024 01:56:21 +0530 Hari Bathini <[email protected]> wrote:

In 'NOFENTRY_ARGS' test case for syntax check, any offset X of vfs_read+X except function entry offset (0) fits the criterion, even if that offset is not at instruction boundary, as the parser comes before probing. But with "ENDBR64" instruction on x86, offset 4 is treated as function entry. So, X can't be 4 as well. Thus, 8 was used as offset for the test case. On 64-bit powerpc though, any offset <= 16 can be considered function entry depending on build configuration (see arch_kprobe_on_func_entry() for implementation details). So, use vfs_read+20 to accommodate that scenario too.

Quoted 8 lines
Quoted 2 lines

Shuah,

Can you take this through your tree?

Yes I can take it. I do have question about whether this is a fix - sounds like it is from the change log.

Clearly stating that it is a fix will help so it can be picked up for stables.

thanks,
-- Shuah

maintainer
#3 lore raw
Quoted 21 lines · On Tue, 3 Dec 2024 18:01:06 -0700 Shuah Khan <[email protected]> wrote:
Quoted 20 lines · Steven Rostedt
Quoted 10 lines · On Sat, 30 Nov 2024 01:56:21 +0530 Hari Bathini <[email protected]> wrote:

In 'NOFENTRY_ARGS' test case for syntax check, any offset X of vfs_read+X except function entry offset (0) fits the criterion, even if that offset is not at instruction boundary, as the parser comes before probing. But with "ENDBR64" instruction on x86, offset 4 is treated as function entry. So, X can't be 4 as well. Thus, 8 was used as offset for the test case. On 64-bit powerpc though, any offset <= 16 can be considered function entry depending on build configuration (see arch_kprobe_on_func_entry() for implementation details). So, use vfs_read+20 to accommodate that scenario too.

Quoted 2 lines

Shuah,

Quoted 7 lines
Quoted 1 line

Can you take this through your tree?

Yes I can take it. I do have question about whether this is a fix - sounds like it is from the change log.

Clearly stating that it is a fix will help so it can be picked up for stables.

I would say it's a fix, as the test currently fails in certain scenarios for powerpc.

You can add:

Fixes 4231f30fcc34a ("selftests/ftrace: Add BTF arguments test cases")

-- Steve

maintainer
#4 lore raw
Quoted 32 lines · Steven Rostedt
Quoted 21 lines · On Tue, 3 Dec 2024 18:01:06 -0700 Shuah Khan <[email protected]> wrote:
Quoted 20 lines · Steven Rostedt
Quoted 10 lines · On Sat, 30 Nov 2024 01:56:21 +0530 Hari Bathini <[email protected]> wrote:

In 'NOFENTRY_ARGS' test case for syntax check, any offset X of vfs_read+X except function entry offset (0) fits the criterion, even if that offset is not at instruction boundary, as the parser comes before probing. But with "ENDBR64" instruction on x86, offset 4 is treated as function entry. So, X can't be 4 as well. Thus, 8 was used as offset for the test case. On 64-bit powerpc though, any offset <= 16 can be considered function entry depending on build configuration (see arch_kprobe_on_func_entry() for implementation details). So, use vfs_read+20 to accommodate that scenario too.

Quoted 2 lines

Shuah,

Quoted 7 lines
Quoted 1 line

Can you take this through your tree?

Yes I can take it. I do have question about whether this is a fix - sounds like it is from the change log.

Clearly stating that it is a fix will help so it can be picked up for stables.

Quoted 7 lines

I would say it's a fix, as the test currently fails in certain scenarios for powerpc.

You can add:

Fixes 4231f30fcc34a ("selftests/ftrace: Add BTF arguments test cases")

I applied this to linux-kselftest fixes - will send it up for rc2 or rc3

thanks,
-- Shuah

maintainer
#5 lore raw
Quoted 1 line · On Thu, 5 Dec 2024 09:06:43 -0700 Shuah Khan <[email protected]> wrote:

I applied this to linux-kselftest fixes - will send it up for rc2 or rc3

Thanks Shuah,

-- Steve