X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=lttng-syscalls.c;h=5501997c48fdd73f730fc59e9ac7ecd84dc6fe50;hb=f64d76a51b5e20a8c402d1eca921c63fdc5ce9ec;hp=cba0016007d95c190fc4a4987c0f727e8a7cefeb;hpb=d42918696623476bb957eae99718e10f7959b320;p=lttng-modules.git diff --git a/lttng-syscalls.c b/lttng-syscalls.c index cba00160..5501997c 100644 --- a/lttng-syscalls.c +++ b/lttng-syscalls.c @@ -91,6 +91,7 @@ struct mmap_arg_struct; #define PARAMS(args...) args /* Handle unknown syscalls */ +#undef TRACE_SYSTEM #define TRACE_SYSTEM syscalls_unknown #include "instrumentation/syscalls/headers/syscalls_unknown.h" #undef TRACE_SYSTEM @@ -374,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; @@ -388,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; @@ -398,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; } @@ -502,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]; @@ -528,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; @@ -542,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; @@ -552,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; } @@ -1036,6 +1037,8 @@ int lttng_syscall_filter_disable(struct lttng_channel *chan, WARN_ON_ONCE(!chan->sc_table); if (!chan->sc_filter) { + if (!chan->syscall_all) + return -EEXIST; filter = kzalloc(sizeof(struct lttng_syscall_filter), GFP_KERNEL); if (!filter) @@ -1048,6 +1051,14 @@ int lttng_syscall_filter_disable(struct lttng_channel *chan, } if (!name) { + /* Fail if all syscalls are already disabled. */ + if (bitmap_empty(filter->sc, NR_syscalls) + && bitmap_empty(filter->sc_compat, + NR_compat_syscalls)) { + ret = -EEXIST; + goto error; + } + /* Disable all system calls */ bitmap_clear(filter->sc, 0, NR_syscalls); bitmap_clear(filter->sc_compat, 0, NR_compat_syscalls); @@ -1060,18 +1071,18 @@ int lttng_syscall_filter_disable(struct lttng_channel *chan, goto error; } if (syscall_nr >= 0) { - if (!test_bit(syscall_nr, chan->sc_filter->sc)) { + if (!test_bit(syscall_nr, filter->sc)) { ret = -EEXIST; goto error; } - bitmap_clear(chan->sc_filter->sc, syscall_nr, 1); + bitmap_clear(filter->sc, syscall_nr, 1); } if (compat_syscall_nr >= 0) { - if (!test_bit(compat_syscall_nr, chan->sc_filter->sc_compat)) { + if (!test_bit(compat_syscall_nr, filter->sc_compat)) { ret = -EEXIST; goto error; } - bitmap_clear(chan->sc_filter->sc_compat, compat_syscall_nr, 1); + bitmap_clear(filter->sc_compat, compat_syscall_nr, 1); } apply_filter: if (!chan->sc_filter) @@ -1220,12 +1231,12 @@ long lttng_channel_syscall_mask(struct lttng_channel *channel, for (bit = 0; bit < ARRAY_SIZE(sc_table); bit++) { bt_bitfield_write_be(tmp_mask, char, bit, 1, - test_bit(bit, filter->sc)); + filter ? test_bit(bit, filter->sc) : 1); } for (; bit < sc_tables_len; bit++) { bt_bitfield_write_be(tmp_mask, char, bit, 1, - test_bit(bit - ARRAY_SIZE(sc_table), - filter->sc_compat)); + filter ? test_bit(bit - ARRAY_SIZE(sc_table), + filter->sc_compat) : 1); } if (copy_to_user(usyscall_mask->mask, tmp_mask, bitmask_len)) ret = -EFAULT;