Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'trace-v5.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull tracing fixes and cleanups from Steven Rostedt:
"This contains a series of last minute clean ups, small fixes and error
checks"

* tag 'trace-v5.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
tracing/probe: Verify alloc_trace_*probe() result
tracing/probe: Check event/group naming rule at parsing
tracing/probe: Check the size of argument name and body
tracing/probe: Check event name length correctly
tracing/probe: Check maxactive error cases
tracing: kdb: Fix ftdump to not sleep
trace/probes: Remove kernel doc style from non kernel doc comment
tracing/probes: Make reserved_field_names static

+45 -26
+1 -1
include/linux/ring_buffer.h
··· 128 128 unsigned long *lost_events); 129 129 130 130 struct ring_buffer_iter * 131 - ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu); 131 + ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu, gfp_t flags); 132 132 void ring_buffer_read_prepare_sync(void); 133 133 void ring_buffer_read_start(struct ring_buffer_iter *iter); 134 134 void ring_buffer_read_finish(struct ring_buffer_iter *iter);
+3 -2
kernel/trace/ring_buffer.c
··· 4191 4191 * ring_buffer_read_prepare - Prepare for a non consuming read of the buffer 4192 4192 * @buffer: The ring buffer to read from 4193 4193 * @cpu: The cpu buffer to iterate over 4194 + * @flags: gfp flags to use for memory allocation 4194 4195 * 4195 4196 * This performs the initial preparations necessary to iterate 4196 4197 * through the buffer. Memory is allocated, buffer recording ··· 4209 4208 * This overall must be paired with ring_buffer_read_finish. 4210 4209 */ 4211 4210 struct ring_buffer_iter * 4212 - ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu) 4211 + ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu, gfp_t flags) 4213 4212 { 4214 4213 struct ring_buffer_per_cpu *cpu_buffer; 4215 4214 struct ring_buffer_iter *iter; ··· 4217 4216 if (!cpumask_test_cpu(cpu, buffer->cpumask)) 4218 4217 return NULL; 4219 4218 4220 - iter = kmalloc(sizeof(*iter), GFP_KERNEL); 4219 + iter = kmalloc(sizeof(*iter), flags); 4221 4220 if (!iter) 4222 4221 return NULL; 4223 4222
+4 -2
kernel/trace/trace.c
··· 4079 4079 if (iter->cpu_file == RING_BUFFER_ALL_CPUS) { 4080 4080 for_each_tracing_cpu(cpu) { 4081 4081 iter->buffer_iter[cpu] = 4082 - ring_buffer_read_prepare(iter->trace_buffer->buffer, cpu); 4082 + ring_buffer_read_prepare(iter->trace_buffer->buffer, 4083 + cpu, GFP_KERNEL); 4083 4084 } 4084 4085 ring_buffer_read_prepare_sync(); 4085 4086 for_each_tracing_cpu(cpu) { ··· 4090 4089 } else { 4091 4090 cpu = iter->cpu_file; 4092 4091 iter->buffer_iter[cpu] = 4093 - ring_buffer_read_prepare(iter->trace_buffer->buffer, cpu); 4092 + ring_buffer_read_prepare(iter->trace_buffer->buffer, 4093 + cpu, GFP_KERNEL); 4094 4094 ring_buffer_read_prepare_sync(); 4095 4095 ring_buffer_read_start(iter->buffer_iter[cpu]); 4096 4096 tracing_iter_reset(iter, cpu);
+4 -2
kernel/trace/trace_kdb.c
··· 51 51 if (cpu_file == RING_BUFFER_ALL_CPUS) { 52 52 for_each_tracing_cpu(cpu) { 53 53 iter.buffer_iter[cpu] = 54 - ring_buffer_read_prepare(iter.trace_buffer->buffer, cpu); 54 + ring_buffer_read_prepare(iter.trace_buffer->buffer, 55 + cpu, GFP_ATOMIC); 55 56 ring_buffer_read_start(iter.buffer_iter[cpu]); 56 57 tracing_iter_reset(&iter, cpu); 57 58 } 58 59 } else { 59 60 iter.cpu_file = cpu_file; 60 61 iter.buffer_iter[cpu_file] = 61 - ring_buffer_read_prepare(iter.trace_buffer->buffer, cpu_file); 62 + ring_buffer_read_prepare(iter.trace_buffer->buffer, 63 + cpu_file, GFP_ATOMIC); 62 64 ring_buffer_read_start(iter.buffer_iter[cpu_file]); 63 65 tracing_iter_reset(&iter, cpu_file); 64 66 }
+11 -12
kernel/trace/trace_kprobe.c
··· 35 35 .match = trace_kprobe_match, 36 36 }; 37 37 38 - /** 38 + /* 39 39 * Kprobe event core functions 40 40 */ 41 41 struct trace_kprobe { ··· 221 221 222 222 tk->rp.maxactive = maxactive; 223 223 224 - if (!event || !is_good_name(event)) { 224 + if (!event || !group) { 225 225 ret = -EINVAL; 226 226 goto error; 227 227 } ··· 230 230 tk->tp.call.name = kstrdup(event, GFP_KERNEL); 231 231 if (!tk->tp.call.name) 232 232 goto error; 233 - 234 - if (!group || !is_good_name(group)) { 235 - ret = -EINVAL; 236 - goto error; 237 - } 238 233 239 234 tk->tp.class.system = kstrdup(group, GFP_KERNEL); 240 235 if (!tk->tp.class.system) ··· 619 624 if (event) 620 625 event++; 621 626 622 - if (is_return && isdigit(argv[0][1])) { 627 + if (isdigit(argv[0][1])) { 628 + if (!is_return) { 629 + pr_info("Maxactive is not for kprobe"); 630 + return -EINVAL; 631 + } 623 632 if (event) 624 633 len = event - &argv[0][1] - 1; 625 634 else ··· 633 634 memcpy(buf, &argv[0][1], len); 634 635 buf[len] = '\0'; 635 636 ret = kstrtouint(buf, 0, &maxactive); 636 - if (ret) { 637 - pr_info("Failed to parse maxactive.\n"); 637 + if (ret || !maxactive) { 638 + pr_info("Invalid maxactive number\n"); 638 639 return ret; 639 640 } 640 641 /* kretprobes instances are iterated over via a list. The ··· 693 694 tk = alloc_trace_kprobe(group, event, addr, symbol, offset, maxactive, 694 695 argc, is_return); 695 696 if (IS_ERR(tk)) { 696 - pr_info("Failed to allocate trace_probe.(%d)\n", 697 - (int)PTR_ERR(tk)); 698 697 ret = PTR_ERR(tk); 698 + /* This must return -ENOMEM otherwise there is a bug */ 699 + WARN_ON_ONCE(ret != -ENOMEM); 699 700 goto out; 700 701 } 701 702
+18 -2
kernel/trace/trace_probe.c
··· 13 13 14 14 #include "trace_probe.h" 15 15 16 - const char *reserved_field_names[] = { 16 + static const char *reserved_field_names[] = { 17 17 "common_type", 18 18 "common_flags", 19 19 "common_preempt_count", ··· 159 159 char *buf) 160 160 { 161 161 const char *slash, *event = *pevent; 162 + int len; 162 163 163 164 slash = strchr(event, '/'); 164 165 if (slash) { ··· 172 171 return -E2BIG; 173 172 } 174 173 strlcpy(buf, event, slash - event + 1); 174 + if (!is_good_name(buf)) { 175 + pr_info("Group name must follow the same rules as C identifiers\n"); 176 + return -EINVAL; 177 + } 175 178 *pgroup = buf; 176 179 *pevent = slash + 1; 180 + event = *pevent; 177 181 } 178 - if (strlen(event) == 0) { 182 + len = strlen(event); 183 + if (len == 0) { 179 184 pr_info("Event name is not specified\n"); 185 + return -EINVAL; 186 + } else if (len > MAX_EVENT_NAME_LEN) { 187 + pr_info("Event name is too long\n"); 188 + return -E2BIG; 189 + } 190 + if (!is_good_name(event)) { 191 + pr_info("Event name must follow the same rules as C identifiers\n"); 180 192 return -EINVAL; 181 193 } 182 194 return 0; ··· 562 548 563 549 body = strchr(arg, '='); 564 550 if (body) { 551 + if (body - arg > MAX_ARG_NAME_LEN || body == arg) 552 + return -EINVAL; 565 553 parg->name = kmemdup_nul(arg, body - arg, GFP_KERNEL); 566 554 body++; 567 555 } else {
+1
kernel/trace/trace_probe.h
··· 32 32 #define MAX_TRACE_ARGS 128 33 33 #define MAX_ARGSTR_LEN 63 34 34 #define MAX_ARRAY_LEN 64 35 + #define MAX_ARG_NAME_LEN 32 35 36 #define MAX_STRING_SIZE PATH_MAX 36 37 37 38 /* Reserved field names */
+3 -5
kernel/trace/trace_uprobe.c
··· 273 273 { 274 274 struct trace_uprobe *tu; 275 275 276 - if (!event || !is_good_name(event)) 277 - return ERR_PTR(-EINVAL); 278 - 279 - if (!group || !is_good_name(group)) 276 + if (!event || !group) 280 277 return ERR_PTR(-EINVAL); 281 278 282 279 tu = kzalloc(SIZEOF_TRACE_UPROBE(nargs), GFP_KERNEL); ··· 521 524 522 525 tu = alloc_trace_uprobe(group, event, argc, is_return); 523 526 if (IS_ERR(tu)) { 524 - pr_info("Failed to allocate trace_uprobe.(%d)\n", (int)PTR_ERR(tu)); 525 527 ret = PTR_ERR(tu); 528 + /* This must return -ENOMEM otherwise there is a bug */ 529 + WARN_ON_ONCE(ret != -ENOMEM); 526 530 goto fail_address_parse; 527 531 } 528 532 tu->offset = offset;