Skip to content

Commit 3773b38

Browse files
Ian Munsierostedt
authored andcommitted
tracing/syscalls: Convert redundant syscall_nr checks into WARN_ON
With the ftrace events now checking if the syscall_nr is valid upon initialisation it should no longer be possible to register or unregister a syscall event without a valid syscall_nr since they should not be created. This adds a WARN_ON_ONCE in the register and unregister functions to locate potential regressions in the future. Signed-off-by: Ian Munsie <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
1 parent ba97697 commit 3773b38

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kernel/trace/trace_syscalls.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)
359359
int num;
360360

361361
num = ((struct syscall_metadata *)call->data)->syscall_nr;
362-
if (num < 0 || num >= NR_syscalls)
362+
if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
363363
return -ENOSYS;
364364
mutex_lock(&syscall_trace_lock);
365365
if (!sys_refcount_enter)
@@ -377,7 +377,7 @@ void unreg_event_syscall_enter(struct ftrace_event_call *call)
377377
int num;
378378

379379
num = ((struct syscall_metadata *)call->data)->syscall_nr;
380-
if (num < 0 || num >= NR_syscalls)
380+
if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
381381
return;
382382
mutex_lock(&syscall_trace_lock);
383383
sys_refcount_enter--;
@@ -393,7 +393,7 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)
393393
int num;
394394

395395
num = ((struct syscall_metadata *)call->data)->syscall_nr;
396-
if (num < 0 || num >= NR_syscalls)
396+
if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
397397
return -ENOSYS;
398398
mutex_lock(&syscall_trace_lock);
399399
if (!sys_refcount_exit)
@@ -411,7 +411,7 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
411411
int num;
412412

413413
num = ((struct syscall_metadata *)call->data)->syscall_nr;
414-
if (num < 0 || num >= NR_syscalls)
414+
if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
415415
return;
416416
mutex_lock(&syscall_trace_lock);
417417
sys_refcount_exit--;

0 commit comments

Comments
 (0)