From: Mathieu Desnoyers Date: Mon, 29 Sep 2014 17:29:12 +0000 (-0400) Subject: Fix: hander negative get_syscall_nr return value X-Git-Tag: v2.6.0-rc1~18 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=74f7b56a78514d321aaf8b3fffae174999070f71;p=lttng-modules.git Fix: hander negative get_syscall_nr return value Signed-off-by: Mathieu Desnoyers --- diff --git a/instrumentation/syscalls/headers/syscalls_unknown.h b/instrumentation/syscalls/headers/syscalls_unknown.h index 6ff640e4..7868f85f 100644 --- a/instrumentation/syscalls/headers/syscalls_unknown.h +++ b/instrumentation/syscalls/headers/syscalls_unknown.h @@ -10,10 +10,10 @@ #define TP_PROBE_CB(_template) &syscall_entry_probe LTTNG_TRACEPOINT_EVENT(syscall_entry_unknown, - TP_PROTO(unsigned int id, unsigned long *args), + TP_PROTO(int id, unsigned long *args), TP_ARGS(id, args), TP_STRUCT__entry( - __field(unsigned int, id) + __field(int, id) __array(unsigned long, args, UNKNOWN_SYSCALL_NRARGS) ), TP_fast_assign( @@ -23,10 +23,10 @@ LTTNG_TRACEPOINT_EVENT(syscall_entry_unknown, TP_printk() ) LTTNG_TRACEPOINT_EVENT(compat_syscall_entry_unknown, - TP_PROTO(unsigned int id, unsigned long *args), + TP_PROTO(int id, unsigned long *args), TP_ARGS(id, args), TP_STRUCT__entry( - __field(unsigned int, id) + __field(int, id) __array(unsigned long, args, UNKNOWN_SYSCALL_NRARGS) ), TP_fast_assign( @@ -40,10 +40,10 @@ LTTNG_TRACEPOINT_EVENT(compat_syscall_entry_unknown, #define TP_PROBE_CB(_template) &syscall_exit_probe LTTNG_TRACEPOINT_EVENT(syscall_exit_unknown, - TP_PROTO(unsigned int id, long ret, unsigned long *args), + TP_PROTO(int id, long ret, unsigned long *args), TP_ARGS(id, ret, args), TP_STRUCT__entry( - __field(unsigned int, id) + __field(int, id) __field(long, ret) __array(unsigned long, args, UNKNOWN_SYSCALL_NRARGS) ), @@ -55,10 +55,10 @@ LTTNG_TRACEPOINT_EVENT(syscall_exit_unknown, TP_printk() ) LTTNG_TRACEPOINT_EVENT(compat_syscall_exit_unknown, - TP_PROTO(unsigned int id, long ret, unsigned long *args), + TP_PROTO(int id, long ret, unsigned long *args), TP_ARGS(id, ret, args), TP_STRUCT__entry( - __field(unsigned int, id) + __field(int, id) __field(long, ret) __array(unsigned long, args, UNKNOWN_SYSCALL_NRARGS) ), diff --git a/lttng-syscalls.c b/lttng-syscalls.c index a4a8ed44..5501997c 100644 --- a/lttng-syscalls.c +++ b/lttng-syscalls.c @@ -375,7 +375,7 @@ void syscall_entry_probe(void *__data, struct pt_regs *regs, long id) filter = rcu_dereference(chan->sc_filter); if (filter) { - if (id >= NR_compat_syscalls + if (id < 0 || id >= NR_compat_syscalls || !test_bit(id, filter->sc_compat)) { /* System call filtered out. */ return; @@ -389,7 +389,7 @@ void syscall_entry_probe(void *__data, struct pt_regs *regs, long id) filter = rcu_dereference(chan->sc_filter); if (filter) { - if (id >= NR_syscalls + if (id < 0 || id >= NR_syscalls || !test_bit(id, filter->sc)) { /* System call filtered out. */ return; @@ -399,7 +399,7 @@ void syscall_entry_probe(void *__data, struct pt_regs *regs, long id) table_len = ARRAY_SIZE(sc_table); unknown_event = chan->sc_unknown; } - if (unlikely(id >= table_len)) { + if (unlikely(id < 0 || id >= table_len)) { syscall_entry_unknown(unknown_event, regs, id); return; } @@ -503,7 +503,7 @@ void syscall_entry_probe(void *__data, struct pt_regs *regs, long id) } static void syscall_exit_unknown(struct lttng_event *event, - struct pt_regs *regs, unsigned int id, long ret) + struct pt_regs *regs, int id, long ret) { unsigned long args[UNKNOWN_SYSCALL_NRARGS]; @@ -529,7 +529,7 @@ void syscall_exit_probe(void *__data, struct pt_regs *regs, long ret) filter = rcu_dereference(chan->sc_filter); if (filter) { - if (id >= NR_compat_syscalls + if (id < 0 || id >= NR_compat_syscalls || !test_bit(id, filter->sc_compat)) { /* System call filtered out. */ return; @@ -543,7 +543,7 @@ void syscall_exit_probe(void *__data, struct pt_regs *regs, long ret) filter = rcu_dereference(chan->sc_filter); if (filter) { - if (id >= NR_syscalls + if (id < 0 || id >= NR_syscalls || !test_bit(id, filter->sc)) { /* System call filtered out. */ return; @@ -553,7 +553,7 @@ void syscall_exit_probe(void *__data, struct pt_regs *regs, long ret) table_len = ARRAY_SIZE(sc_exit_table); unknown_event = chan->sc_exit_unknown; } - if (unlikely(id >= table_len)) { + if (unlikely(id < 0 || id >= table_len)) { syscall_exit_unknown(unknown_event, regs, id, ret); return; }