X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=lttng-syscalls.c;h=748c6002fc4a79ef3d2692bf997ac0820e60cbc2;hb=c2b1261d224b8e02a30b62f214d7c8b2478f629c;hp=a4a8ed44cd9c76dbc38d0ce8e319182b9f52392e;hpb=72a527538699ab5c72bfb0080a975f04209328b9;p=lttng-modules.git diff --git a/lttng-syscalls.c b/lttng-syscalls.c index a4a8ed44..748c6002 100644 --- a/lttng-syscalls.c +++ b/lttng-syscalls.c @@ -29,11 +29,14 @@ #include #include #include +#include +#include #include #include #include "lib/bitfield.h" #include "wrapper/tracepoint.h" +#include "wrapper/file.h" #include "lttng-events.h" #ifndef CONFIG_COMPAT @@ -375,7 +378,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 +392,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 +402,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 +506,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 +532,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 +546,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 +556,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; } @@ -1230,16 +1233,70 @@ long lttng_channel_syscall_mask(struct lttng_channel *channel, filter = channel->sc_filter; for (bit = 0; bit < ARRAY_SIZE(sc_table); bit++) { - bt_bitfield_write_be(tmp_mask, char, bit, 1, - filter ? test_bit(bit, filter->sc) : 1); + bool state; + + if (channel->sc_table) { + if (filter) + state = test_bit(bit, filter->sc); + else + state = 1; + } else { + state = 0; + } + bt_bitfield_write_be(tmp_mask, char, bit, 1, state); } for (; bit < sc_tables_len; bit++) { - bt_bitfield_write_be(tmp_mask, char, bit, 1, - filter ? test_bit(bit - ARRAY_SIZE(sc_table), - filter->sc_compat) : 1); + bool state; + + if (channel->compat_sc_table) { + if (filter) + state = test_bit(bit - ARRAY_SIZE(sc_table), + filter->sc_compat); + else + state = 1; + } else { + state = 0; + } + bt_bitfield_write_be(tmp_mask, char, bit, 1, state); } if (copy_to_user(usyscall_mask->mask, tmp_mask, bitmask_len)) ret = -EFAULT; kfree(tmp_mask); return ret; } + +int lttng_abi_syscall_list(void) +{ + struct file *syscall_list_file; + int file_fd, ret; + + file_fd = lttng_get_unused_fd(); + if (file_fd < 0) { + ret = file_fd; + goto fd_error; + } + + syscall_list_file = anon_inode_getfile("[lttng_syscall_list]", + <tng_syscall_list_fops, + NULL, O_RDWR); + if (IS_ERR(syscall_list_file)) { + ret = PTR_ERR(syscall_list_file); + goto file_error; + } + ret = lttng_syscall_list_fops.open(NULL, syscall_list_file); + if (ret < 0) + goto open_error; + fd_install(file_fd, syscall_list_file); + if (file_fd < 0) { + ret = file_fd; + goto fd_error; + } + return file_fd; + +open_error: + fput(syscall_list_file); +file_error: + put_unused_fd(file_fd); +fd_error: + return ret; +}