X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Flttng-abi.c;h=9b1cceac0d99ce7bd2adc91356fc7fd64ec504bc;hb=62b81e8835877ed8d654990266ceabbc4a2e82d3;hp=cc45389403df8301fe72cd142d22615e315bacc3;hpb=a2a1b5ab74c22450126b5f80fb30db596945f875;p=lttng-modules.git diff --git a/src/lttng-abi.c b/src/lttng-abi.c index cc453894..9b1cceac 100644 --- a/src/lttng-abi.c +++ b/src/lttng-abi.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -649,6 +650,8 @@ long lttng_counter_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (validate_zeroed_padding(local_counter_read.padding, sizeof(local_counter_read.padding))) return -EINVAL; + if (local_counter_read.index.number_dimensions > LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX) + return -EINVAL; /* Cast all indexes into size_t. */ for (i = 0; i < local_counter_read.index.number_dimensions; i++) @@ -684,6 +687,8 @@ long lttng_counter_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (validate_zeroed_padding(local_counter_aggregate.padding, sizeof(local_counter_aggregate.padding))) return -EINVAL; + if (local_counter_aggregate.index.number_dimensions > LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX) + return -EINVAL; /* Cast all indexes into size_t. */ for (i = 0; i < local_counter_aggregate.index.number_dimensions; i++) @@ -715,6 +720,8 @@ long lttng_counter_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (validate_zeroed_padding(local_counter_clear.padding, sizeof(local_counter_clear.padding))) return -EINVAL; + if (local_counter_clear.index.number_dimensions > LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX) + return -EINVAL; /* Cast all indexes into size_t. */ for (i = 0; i < local_counter_clear.index.number_dimensions; i++) @@ -723,7 +730,6 @@ long lttng_counter_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return lttng_kernel_counter_clear(counter, indexes); } default: - WARN_ON_ONCE(1); return -ENOSYS; } } @@ -1010,7 +1016,7 @@ ssize_t lttng_event_notifier_group_notif_read(struct file *filp, char __user *us /* Finish copy of previous record */ if (*ppos != 0) { - if (read_count < count) { + if (count != 0) { len = chan->iter.len_left; read_offset = *ppos; goto skip_get_next; @@ -1090,7 +1096,8 @@ nodata: chan->iter.len_left = 0; put_record: - lib_ring_buffer_put_current_record(buf); + if (*ppos == 0) + lib_ring_buffer_put_current_record(buf); return read_count; } @@ -1332,7 +1339,8 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp, */ return -ENOSYS; } - case LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH_EMPTY: /* Fall-through. */ + case LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH_EMPTY: + lttng_fallthrough; case LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH: { struct lttng_metadata_stream *stream = filp->private_data; @@ -1441,7 +1449,8 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp, */ return -ENOSYS; } - case LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH_EMPTY: /* Fall-through. */ + case LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH_EMPTY: + lttng_fallthrough; case LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH: { struct lttng_metadata_stream *stream = filp->private_data; @@ -1758,8 +1767,10 @@ int lttng_abi_validate_event_param(struct lttng_kernel_abi_event *event_param) switch (event_param->instrumentation) { case LTTNG_KERNEL_ABI_SYSCALL: switch (event_param->u.syscall.entryexit) { - case LTTNG_KERNEL_ABI_SYSCALL_ENTRY: /* Fall-through */ - case LTTNG_KERNEL_ABI_SYSCALL_EXIT: /* Fall-through */ + case LTTNG_KERNEL_ABI_SYSCALL_ENTRY: + lttng_fallthrough; + case LTTNG_KERNEL_ABI_SYSCALL_EXIT: + lttng_fallthrough; case LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT: break; default: @@ -1783,20 +1794,26 @@ int lttng_abi_validate_event_param(struct lttng_kernel_abi_event *event_param) switch (event_param->u.kretprobe.entryexit) { case LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT: break; - case LTTNG_KERNEL_ABI_SYSCALL_ENTRY: /* Fall-through */ - case LTTNG_KERNEL_ABI_SYSCALL_EXIT: /* Fall-through */ + case LTTNG_KERNEL_ABI_SYSCALL_ENTRY: + lttng_fallthrough; + case LTTNG_KERNEL_ABI_SYSCALL_EXIT: + lttng_fallthrough; default: return -EINVAL; } break; - case LTTNG_KERNEL_ABI_TRACEPOINT: /* Fall-through */ - case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */ + case LTTNG_KERNEL_ABI_TRACEPOINT: + lttng_fallthrough; + case LTTNG_KERNEL_ABI_KPROBE: + lttng_fallthrough; case LTTNG_KERNEL_ABI_UPROBE: break; - case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */ - case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */ + case LTTNG_KERNEL_ABI_FUNCTION: + lttng_fallthrough; + case LTTNG_KERNEL_ABI_NOOP: + lttng_fallthrough; default: return -EINVAL; } @@ -1830,18 +1847,23 @@ int lttng_abi_create_event(struct file *channel_file, } switch (event_param->instrumentation) { - case LTTNG_KERNEL_ABI_TRACEPOINT: /* Fall-through */ + case LTTNG_KERNEL_ABI_TRACEPOINT: + lttng_fallthrough; case LTTNG_KERNEL_ABI_SYSCALL: fops = <tng_event_recorder_enabler_fops; break; - case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */ - case LTTNG_KERNEL_ABI_KRETPROBE: /* Fall-through */ + case LTTNG_KERNEL_ABI_KPROBE: + lttng_fallthrough; + case LTTNG_KERNEL_ABI_KRETPROBE: + lttng_fallthrough; case LTTNG_KERNEL_ABI_UPROBE: fops = <tng_event_recorder_event_fops; break; - case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */ - case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */ + case LTTNG_KERNEL_ABI_FUNCTION: + lttng_fallthrough; + case LTTNG_KERNEL_ABI_NOOP: + lttng_fallthrough; default: return -EINVAL; } @@ -1867,7 +1889,8 @@ int lttng_abi_create_event(struct file *channel_file, goto event_error; switch (event_param->instrumentation) { - case LTTNG_KERNEL_ABI_TRACEPOINT: /* Fall-through */ + case LTTNG_KERNEL_ABI_TRACEPOINT: + lttng_fallthrough; case LTTNG_KERNEL_ABI_SYSCALL: { struct lttng_event_enabler *event_enabler; @@ -1887,8 +1910,10 @@ int lttng_abi_create_event(struct file *channel_file, break; } - case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */ - case LTTNG_KERNEL_ABI_KRETPROBE: /* Fall-through */ + case LTTNG_KERNEL_ABI_KPROBE: + lttng_fallthrough; + case LTTNG_KERNEL_ABI_KRETPROBE: + lttng_fallthrough; case LTTNG_KERNEL_ABI_UPROBE: { struct lttng_kernel_event_recorder *event; @@ -1908,8 +1933,10 @@ int lttng_abi_create_event(struct file *channel_file, break; } - case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */ - case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */ + case LTTNG_KERNEL_ABI_FUNCTION: + lttng_fallthrough; + case LTTNG_KERNEL_ABI_NOOP: + lttng_fallthrough; default: ret = -EINVAL; goto event_error; @@ -2043,18 +2070,23 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file, } switch (event_notifier_param->event.instrumentation) { - case LTTNG_KERNEL_ABI_TRACEPOINT: /* Fall-through */ + case LTTNG_KERNEL_ABI_TRACEPOINT: + lttng_fallthrough; case LTTNG_KERNEL_ABI_SYSCALL: fops = <tng_event_notifier_enabler_fops; break; - case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */ - case LTTNG_KERNEL_ABI_KRETPROBE: /* Fall-through */ + case LTTNG_KERNEL_ABI_KPROBE: + lttng_fallthrough; + case LTTNG_KERNEL_ABI_KRETPROBE: + lttng_fallthrough; case LTTNG_KERNEL_ABI_UPROBE: fops = <tng_event_notifier_event_fops; break; - case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */ - case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */ + case LTTNG_KERNEL_ABI_FUNCTION: + lttng_fallthrough; + case LTTNG_KERNEL_ABI_NOOP: + lttng_fallthrough; default: ret = -EINVAL; goto inval_instr; @@ -2086,7 +2118,8 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file, goto event_notifier_error; switch (event_notifier_param->event.instrumentation) { - case LTTNG_KERNEL_ABI_TRACEPOINT: /* Fall-through */ + case LTTNG_KERNEL_ABI_TRACEPOINT: + lttng_fallthrough; case LTTNG_KERNEL_ABI_SYSCALL: { struct lttng_event_notifier_enabler *enabler; @@ -2110,8 +2143,10 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file, break; } - case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */ - case LTTNG_KERNEL_ABI_KRETPROBE: /* Fall-through */ + case LTTNG_KERNEL_ABI_KPROBE: + lttng_fallthrough; + case LTTNG_KERNEL_ABI_KRETPROBE: + lttng_fallthrough; case LTTNG_KERNEL_ABI_UPROBE: { struct lttng_kernel_event_notifier *event_notifier; @@ -2135,8 +2170,10 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file, break; } - case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */ - case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */ + case LTTNG_KERNEL_ABI_FUNCTION: + lttng_fallthrough; + case LTTNG_KERNEL_ABI_NOOP: + lttng_fallthrough; default: ret = -EINVAL; goto event_notifier_error;