[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241128115319.305523-1-chen.dylane@gmail.com>
Date: Thu, 28 Nov 2024 19:53:19 +0800
From: Tao Chen <chen.dylane@...il.com>
To: rostedt@...dmis.org,
mhiramat@...nel.org,
mathieu.desnoyers@...icios.com
Cc: linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org,
chen.dylane@...il.com
Subject: [PATCH] tracing: Add WARN_ON_ONCE for syscall_nr check
Now, x86_64 kernel not support to trace syscall for ia32 syscall.
As a result, there is no any trace output when tracing a ia32 task.
Like unreg_event_syscall_enter, add a WARN_ON_ONCE judgment for
syscall_nr in perf_syscall_enter and ftrace_syscall_enter to give
some message.
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(void)
{
int ret = open("tmp.txt", 0);
return 0;
}
gcc -m32 open32 open.c
echo 1 > /sys/kernel/debug/tracing/events/syscalls/sys_enter_open/enable
./open32
[ 109.214595] ------------[ cut here ]------------
[ 109.215625] WARNING: CPU: 0 PID: 170 at
kernel/trace/trace_syscalls.c:304 ftrace_syscall_enter+0x55/0x1c0
[ 109.217111] Modules linked in:
[ 109.218190] CPU: 0 UID: 0 PID: 170 Comm: open32 Not tainted
6.12.0-rc4-virtme #10]
Signed-off-by: Tao Chen <chen.dylane@...il.com>
---
kernel/trace/trace_syscalls.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 785733245ead..19c3335e7d84 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -300,7 +300,7 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
int size;
syscall_nr = trace_get_syscall_nr(current, regs);
- if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
+ if (WARN_ON_ONCE(syscall_nr < 0 || syscall_nr >= NR_syscalls))
return;
/* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE) */
@@ -339,7 +339,7 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
int syscall_nr;
syscall_nr = trace_get_syscall_nr(current, regs);
- if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
+ if (WARN_ON_ONCE(syscall_nr < 0 || syscall_nr >= NR_syscalls))
return;
/* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE()) */
@@ -585,7 +585,7 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
int size;
syscall_nr = trace_get_syscall_nr(current, regs);
- if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
+ if (WARN_ON_ONCE(syscall_nr < 0 || syscall_nr >= NR_syscalls))
return;
if (!test_bit(syscall_nr, enabled_perf_enter_syscalls))
return;
@@ -687,7 +687,7 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
int size;
syscall_nr = trace_get_syscall_nr(current, regs);
- if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
+ if (WARN_ON_ONCE(syscall_nr < 0 || syscall_nr >= NR_syscalls))
return;
if (!test_bit(syscall_nr, enabled_perf_exit_syscalls))
return;
--
2.43.0
Powered by blists - more mailing lists