Compare
205cccd06e545694754e1bf8d626ea96e742cd8a..803aa6fc2dbea25ab9d3ed19eca1c96d0ab17445
tracing: Keep the predicate limit separate from program capacity
predicate_parse() adds two to nr_preds to reserve the terminal TRUE
and FALSE entries. It also uses that increased value as the limit for
parsed predicates. If the initial count is smaller than the number
actually parsed, the program can fill the allocation and subsequent
accesses can go past its end.
Keep nr_preds as the predicate limit and use a separate value for the
allocation size. This leaves space for both terminal entries and a
zeroed entry when parsing stops at the limit.
Cc: stable@vger.kernel.org
Fixes: 39f7c41c908b ("tracing/filters: Enable filtering a cpumask field by another cpumask")
Link: https://patch.msgid.link/atELCd1XjKVhrkFL@Taeyangs-MacBook-Pro.local
Signed-off-by: Taeyang Lee <0wn@theori.io>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Taeyang Lee <0wn@theori.io> · 2026-10-15 17:19 UTC · committed by Steven Rostedt
14 files changed,
+117
−105
- drivers/gpio/gpio-mxc.c
- drivers/gpio/gpio-nct6694.c
- drivers/gpio/gpiolib-kunit.c
- drivers/gpio/gpiolib-shared.c
- drivers/gpio/gpiolib.c
- fs/tracefs/event_inode.c
- kernel/trace/Makefile
- kernel/trace/ring_buffer.c
- kernel/trace/trace.c
- kernel/trace/trace_events_filter.c
- kernel/trace/trace_events_hist.c
- kernel/trace/trace_snapshot.c
- kernel/trace/undefsyms_base.c
- tools/gpio/Makefile
modified drivers/gpio/gpio-mxc.c
| @@ -7,7 +7,6 @@ | |||
| 7 | 7 | // Authors: Daniel Mack, Juergen Beisert. | |
| 8 | 8 | // Copyright (C) 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved. | |
| 9 | 9 | ||
| 10 | - | #include <linux/bitops.h> | |
| 11 | 10 | #include <linux/cleanup.h> | |
| 12 | 11 | #include <linux/clk.h> | |
| 13 | 12 | #include <linux/err.h> | |
| @@ -69,11 +68,11 @@ struct mxc_gpio_port { | |||
| 69 | 68 | struct irq_domain *domain; | |
| 70 | 69 | struct gpio_generic_chip gen_gc; | |
| 71 | 70 | struct device *dev; | |
| 72 | - | unsigned long both_edges; | |
| 71 | + | u32 both_edges; | |
| 73 | 72 | struct mxc_gpio_reg_saved gpio_saved_reg; | |
| 74 | 73 | bool power_off; | |
| 74 | + | u32 wakeup_pads; | |
| 75 | 75 | bool is_pad_wakeup; | |
| 76 | - | unsigned long wakeup_pads; | |
| 77 | 76 | u32 pad_type[32]; | |
| 78 | 77 | const struct mxc_gpio_hwdata *hwdata; | |
| 79 | 78 | }; | |
| @@ -169,7 +168,7 @@ static int gpio_set_irq_type(struct irq_data *d, u32 type) | |||
| 169 | 168 | int edge; | |
| 170 | 169 | void __iomem *reg = port->base; | |
| 171 | 170 | ||
| 172 | - | clear_bit(gpio_idx, &port->both_edges); | |
| 171 | + | port->both_edges &= ~(1 << gpio_idx); | |
| 173 | 172 | switch (type) { | |
| 174 | 173 | case IRQ_TYPE_EDGE_RISING: | |
| 175 | 174 | edge = GPIO_INT_RISE_EDGE; | |
| @@ -189,7 +188,7 @@ static int gpio_set_irq_type(struct irq_data *d, u32 type) | |||
| 189 | 188 | edge = GPIO_INT_HIGH_LEV; | |
| 190 | 189 | pr_debug("mxc: set GPIO %d to high trigger\n", gpio_idx); | |
| 191 | 190 | } | |
| 192 | - | set_bit(gpio_idx, &port->both_edges); | |
| 191 | + | port->both_edges |= 1 << gpio_idx; | |
| 193 | 192 | } | |
| 194 | 193 | break; | |
| 195 | 194 | case IRQ_TYPE_LEVEL_LOW: | |
| @@ -260,7 +259,7 @@ static void mxc_gpio_irq_handler(struct mxc_gpio_port *port, u32 irq_stat) | |||
| 260 | 259 | while (irq_stat != 0) { | |
| 261 | 260 | int irqoffset = fls(irq_stat) - 1; | |
| 262 | 261 | ||
| 263 | - | if (test_bit(irqoffset, &port->both_edges)) | |
| 262 | + | if (port->both_edges & (1 << irqoffset)) | |
| 264 | 263 | mxc_flip_edge(port, irqoffset); | |
| 265 | 264 | ||
| 266 | 265 | generic_handle_domain_irq(port->domain, irqoffset); | |
| @@ -331,18 +330,16 @@ static int gpio_set_wake_irq(struct irq_data *d, u32 enable) | |||
| 331 | 330 | ret = enable_irq_wake(port->irq_high); | |
| 332 | 331 | else | |
| 333 | 332 | ret = enable_irq_wake(port->irq); | |
| 333 | + | port->wakeup_pads |= BIT(gpio_idx); | |
| 334 | 334 | } else { | |
| 335 | 335 | if (port->irq_high && (gpio_idx >= 16)) | |
| 336 | 336 | ret = disable_irq_wake(port->irq_high); | |
| 337 | 337 | else | |
| 338 | 338 | ret = disable_irq_wake(port->irq); | |
| 339 | + | port->wakeup_pads &= ~BIT(gpio_idx); | |
| 339 | 340 | } | |
| 340 | - | if (ret) | |
| 341 | - | return ret; | |
| 342 | - | ||
| 343 | - | assign_bit(gpio_idx, &port->wakeup_pads, enable); | |
| 344 | 341 | ||
| 345 | - | return 0; | |
| 342 | + | return ret; | |
| 346 | 343 | } | |
| 347 | 344 | ||
| 348 | 345 | static int mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base) | |
| @@ -477,6 +474,8 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
| 477 | 474 | } else | |
| 478 | 475 | port->mx_irq_handler = mx3_gpio_irq_handler; | |
| 479 | 476 | ||
| 477 | + | mxc_update_irq_chained_handler(port, true); | |
| 478 | + | ||
| 480 | 479 | config.dev = &pdev->dev; | |
| 481 | 480 | config.sz = 4; | |
| 482 | 481 | config.dat = port->base + GPIO_PSR; | |
| @@ -500,6 +499,10 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
| 500 | 499 | else /* silence boot time warning */ | |
| 501 | 500 | port->gen_gc.gc.base = -1; | |
| 502 | 501 | ||
| 502 | + | err = devm_gpiochip_add_data(&pdev->dev, &port->gen_gc.gc, port); | |
| 503 | + | if (err) | |
| 504 | + | goto out_bgio; | |
| 505 | + | ||
| 503 | 506 | irq_base = devm_irq_alloc_descs(&pdev->dev, -1, 0, 32, numa_node_id()); | |
| 504 | 507 | if (irq_base < 0) { | |
| 505 | 508 | err = irq_base; | |
| @@ -520,19 +523,8 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
| 520 | 523 | if (err < 0) | |
| 521 | 524 | goto out_irqdomain_remove; | |
| 522 | 525 | ||
| 523 | - | /* | |
| 524 | - | * Register the GPIO chip last: devm_gpiochip_add_data() makes the | |
| 525 | - | * chip visible to consumers immediately, so the IRQ domain and | |
| 526 | - | * generic irq chip must be ready before any to_irq() call. | |
| 527 | - | */ | |
| 528 | - | err = devm_gpiochip_add_data(&pdev->dev, &port->gen_gc.gc, port); | |
| 529 | - | if (err) | |
| 530 | - | goto out_irqdomain_remove; | |
| 531 | - | ||
| 532 | 526 | list_add_tail(&port->node, &mxc_gpio_ports); | |
| 533 | 527 | ||
| 534 | - | mxc_update_irq_chained_handler(port, true); | |
| 535 | - | ||
| 536 | 528 | platform_set_drvdata(pdev, port); | |
| 537 | 529 | pm_runtime_put_autosuspend(&pdev->dev); | |
| 538 | 530 | ||
modified drivers/gpio/gpio-nct6694.c
| @@ -444,7 +444,7 @@ static int nct6694_gpio_probe(struct platform_device *pdev) | |||
| 444 | 444 | data->gpio.set_config = nct6694_set_config; | |
| 445 | 445 | data->gpio.init_valid_mask = nct6694_init_valid_mask; | |
| 446 | 446 | data->gpio.base = -1; | |
| 447 | - | data->gpio.can_sleep = true; | |
| 447 | + | data->gpio.can_sleep = false; | |
| 448 | 448 | data->gpio.owner = THIS_MODULE; | |
| 449 | 449 | data->gpio.ngpio = NCT6694_NR_GPIO; | |
| 450 | 450 | ||
modified drivers/gpio/gpiolib-kunit.c
| @@ -28,8 +28,6 @@ | |||
| 28 | 28 | ||
| 29 | 29 | #define GPIO_TEST_PROVIDER_NGPIO 4 | |
| 30 | 30 | ||
| 31 | - | KUNIT_DEFINE_ACTION_WRAPPER(gpio_device_put_wrapper, gpio_device_put, struct gpio_device *); | |
| 32 | - | ||
| 33 | 31 | /* | |
| 34 | 32 | * The test provider tracks per-line direction and value so that lines can be | |
| 35 | 33 | * driven as both inputs and outputs - this is needed to exercise input as well | |
| @@ -772,7 +770,6 @@ static void gpio_hog_assert(struct kunit *test, unsigned int offset, | |||
| 772 | 770 | struct property_entry properties[2]; | |
| 773 | 771 | struct platform_device *pdev; | |
| 774 | 772 | struct fwnode_handle *fwnode; | |
| 775 | - | struct gpio_device *gdev; | |
| 776 | 773 | struct gpio_desc *desc; | |
| 777 | 774 | bool bound = true; | |
| 778 | 775 | int ret; | |
| @@ -792,12 +789,10 @@ static void gpio_hog_assert(struct kunit *test, unsigned int offset, | |||
| 792 | 789 | wait_for_device_probe(); | |
| 793 | 790 | ||
| 794 | 791 | /* The hog must have configured the line with the expected direction. */ | |
| 795 | - | gdev = gpio_device_find_by_label(GPIO_CONSUMER_NAME); | |
| 792 | + | struct gpio_device *gdev __free(gpio_device_put) = | |
| 793 | + | gpio_device_find_by_label(GPIO_CONSUMER_NAME); | |
| 796 | 794 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, gdev); | |
| 797 | 795 | ||
| 798 | - | ret = kunit_add_action_or_reset(test, gpio_device_put_wrapper, gdev); | |
| 799 | - | KUNIT_ASSERT_EQ(test, ret, 0); | |
| 800 | - | ||
| 801 | 796 | desc = gpio_device_get_desc(gdev, offset); | |
| 802 | 797 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, desc); | |
| 803 | 798 | ||
modified drivers/gpio/gpiolib.c
| @@ -3954,17 +3954,16 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep, | |||
| 3954 | 3954 | } while ((i < array_size) && | |
| 3955 | 3955 | gpio_device_chip_cmp(desc_array[i]->gdev, guard.gc)); | |
| 3956 | 3956 | /* push collected bits to outputs */ | |
| 3957 | - | ret = 0; | |
| 3958 | - | if (count != 0) | |
| 3957 | + | if (count != 0) { | |
| 3959 | 3958 | ret = gpiochip_set_multiple(guard.gc, mask, bits); | |
| 3959 | + | if (ret) | |
| 3960 | + | return ret; | |
| 3961 | + | } | |
| 3960 | 3962 | ||
| 3961 | 3963 | if (mask != fastpath_mask) | |
| 3962 | 3964 | bitmap_free(mask); | |
| 3963 | 3965 | if (bits != fastpath_bits) | |
| 3964 | 3966 | bitmap_free(bits); | |
| 3965 | - | ||
| 3966 | - | if (ret) | |
| 3967 | - | return ret; | |
| 3968 | 3967 | } | |
| 3969 | 3968 | return 0; | |
| 3970 | 3969 | } | |
modified fs/tracefs/event_inode.c
| @@ -91,6 +91,14 @@ static void free_ei_rcu(struct rcu_head *rcu) | |||
| 91 | 91 | } | |
| 92 | 92 | } | |
| 93 | 93 | ||
| 94 | + | /* read under eventfs_srcu and, by tracefs_d_revalidate(), in rcu pathwalk */ | |
| 95 | + | static void free_ei_srcu(struct rcu_head *rcu) | |
| 96 | + | { | |
| 97 | + | struct eventfs_inode *ei = container_of(rcu, struct eventfs_inode, rcu); | |
| 98 | + | ||
| 99 | + | call_rcu(&ei->rcu, free_ei_rcu); | |
| 100 | + | } | |
| 101 | + | ||
| 94 | 102 | /* | |
| 95 | 103 | * eventfs_inode reference count management. | |
| 96 | 104 | * | |
| @@ -112,7 +120,7 @@ static void release_ei(struct kref *ref) | |||
| 112 | 120 | entry->release(entry->name, ei->data); | |
| 113 | 121 | } | |
| 114 | 122 | ||
| 115 | - | call_srcu(&eventfs_srcu, &ei->rcu, free_ei_rcu); | |
| 123 | + | call_srcu(&eventfs_srcu, &ei->rcu, free_ei_srcu); | |
| 116 | 124 | } | |
| 117 | 125 | ||
| 118 | 126 | static inline void put_ei(struct eventfs_inode *ei) | |
modified kernel/trace/Makefile
| @@ -146,11 +146,12 @@ KASAN_SANITIZE_undefsyms_base.o := y | |||
| 146 | 146 | ||
| 147 | 147 | UNDEFINED_ALLOWLIST = __asan __gcov __kasan __kcsan __hwasan __sancov __sanitizer __tsan __ubsan __msan \ | |
| 148 | 148 | __aeabi_unwind_cpp __s390_indirect_jump __x86_indirect_thunk simple_ring_buffer \ | |
| 149 | - | $(shell $(NM) -u $(obj)/undefsyms_base.o 2>/dev/null | awk '{print $$2}') | |
| 149 | + | current_thread_info_reg \ | |
| 150 | + | $(shell $(NM) -u $(obj)/undefsyms_base.o 2>/dev/null | awk '$$2 {print $$2}') | |
| 150 | 151 | ||
| 151 | 152 | quiet_cmd_check_undefined = NM $< | |
| 152 | 153 | cmd_check_undefined = \ | |
| 153 | - | undefsyms=$$($(NM) -u $< | grep -v $(addprefix -e , $(UNDEFINED_ALLOWLIST)) || true); \ | |
| 154 | + | undefsyms=$$($(NM) -u $< | awk '$$2 {print $$2}' | grep -v $(addprefix -e , $(UNDEFINED_ALLOWLIST)) || true); \ | |
| 154 | 155 | if [ -n "$$undefsyms" ]; then \ | |
| 155 | 156 | echo "Unexpected symbols in $<:" >&2; \ | |
| 156 | 157 | echo "$$undefsyms" >&2; \ | |
modified kernel/trace/ring_buffer.c
| @@ -2380,6 +2380,9 @@ int ring_buffer_meta_seq_init(struct file *file, struct trace_buffer *buffer, in | |||
| 2380 | 2380 | struct seq_file *m; | |
| 2381 | 2381 | int ret; | |
| 2382 | 2382 | ||
| 2383 | + | if (!cpumask_test_cpu(cpu, buffer->cpumask)) | |
| 2384 | + | return -ENODEV; | |
| 2385 | + | ||
| 2383 | 2386 | ret = seq_open(file, &rb_meta_seq_ops); | |
| 2384 | 2387 | if (ret) | |
| 2385 | 2388 | return ret; | |
| @@ -2440,22 +2443,33 @@ static int __rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer, | |||
| 2440 | 2443 | unsigned long nr_pages, struct list_head *pages) | |
| 2441 | 2444 | { | |
| 2442 | 2445 | struct trace_buffer *buffer = cpu_buffer->buffer; | |
| 2446 | + | unsigned int subbuf_order = buffer->subbuf_order; | |
| 2443 | 2447 | struct ring_buffer_cpu_meta *meta = NULL; | |
| 2444 | 2448 | struct buffer_page *bpage, *tmp; | |
| 2445 | - | bool user_thread = current->mm != NULL; | |
| 2446 | 2449 | struct ring_buffer_desc *desc = NULL; | |
| 2450 | + | bool user_thread = false; | |
| 2447 | 2451 | long i; | |
| 2448 | 2452 | ||
| 2449 | - | /* | |
| 2450 | - | * Check if the available memory is there first. | |
| 2451 | - | * Note, si_mem_available() only gives us a rough estimate of available | |
| 2452 | - | * memory. It may not be accurate. But we don't care, we just want | |
| 2453 | - | * to prevent doing any allocation when it is obvious that it is | |
| 2454 | - | * not going to succeed. | |
| 2455 | - | */ | |
| 2456 | - | i = si_mem_available(); | |
| 2457 | - | if (i < nr_pages) | |
| 2458 | - | return -ENOMEM; | |
| 2453 | + | if (buffer->range_addr_start) { | |
| 2454 | + | meta = rb_range_meta(buffer, nr_pages, cpu_buffer->cpu); | |
| 2455 | + | } else if (buffer->remote) { | |
| 2456 | + | desc = ring_buffer_desc(buffer->remote->desc, cpu_buffer->cpu); | |
| 2457 | + | if (!desc || WARN_ON(desc->nr_page_va != (nr_pages + 1))) | |
| 2458 | + | return -EINVAL; | |
| 2459 | + | } else { | |
| 2460 | + | /* | |
| 2461 | + | * Check if the available memory is there first. | |
| 2462 | + | * Note, si_mem_available() only gives us a rough estimate of available | |
| 2463 | + | * memory. It may not be accurate. But we don't care, we just want | |
| 2464 | + | * to prevent doing any allocation when it is obvious that it is | |
| 2465 | + | * not going to succeed. | |
| 2466 | + | */ | |
| 2467 | + | i = si_mem_available(); | |
| 2468 | + | if (i < (nr_pages << subbuf_order)) | |
| 2469 | + | return -ENOMEM; | |
| 2470 | + | ||
| 2471 | + | user_thread = current->mm != NULL; | |
| 2472 | + | } | |
| 2459 | 2473 | ||
| 2460 | 2474 | /* | |
| 2461 | 2475 | * If a user thread allocates too much, and si_mem_available() | |
| @@ -2469,15 +2483,6 @@ static int __rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer, | |||
| 2469 | 2483 | if (user_thread) | |
| 2470 | 2484 | set_current_oom_origin(); | |
| 2471 | 2485 | ||
| 2472 | - | if (buffer->range_addr_start) | |
| 2473 | - | meta = rb_range_meta(buffer, nr_pages, cpu_buffer->cpu); | |
| 2474 | - | ||
| 2475 | - | if (buffer->remote) { | |
| 2476 | - | desc = ring_buffer_desc(buffer->remote->desc, cpu_buffer->cpu); | |
| 2477 | - | if (!desc || WARN_ON(desc->nr_page_va != (nr_pages + 1))) | |
| 2478 | - | return -EINVAL; | |
| 2479 | - | } | |
| 2480 | - | ||
| 2481 | 2486 | for (i = 0; i < nr_pages; i++) { | |
| 2482 | 2487 | ||
| 2483 | 2488 | bpage = alloc_cpu_page(cpu_buffer->cpu); | |
| @@ -2513,12 +2518,11 @@ static int __rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer, | |||
| 2513 | 2518 | bpage->id = i + 1; | |
| 2514 | 2519 | cpu_buffer->subbuf_ids[i + 1] = bpage; | |
| 2515 | 2520 | } else { | |
| 2516 | - | bpage->page = alloc_cpu_data(cpu_buffer->cpu, | |
| 2517 | - | cpu_buffer->buffer->subbuf_order); | |
| 2521 | + | bpage->page = alloc_cpu_data(cpu_buffer->cpu, subbuf_order); | |
| 2518 | 2522 | if (!bpage->page) | |
| 2519 | 2523 | goto free_pages; | |
| 2520 | 2524 | } | |
| 2521 | - | bpage->order = cpu_buffer->buffer->subbuf_order; | |
| 2525 | + | bpage->order = subbuf_order; | |
| 2522 | 2526 | ||
| 2523 | 2527 | if (user_thread && fatal_signal_pending(current)) | |
| 2524 | 2528 | goto free_pages; | |
| @@ -3627,10 +3631,8 @@ static void rb_inc_iter(struct ring_buffer_iter *iter) | |||
| 3627 | 3631 | /* Return the index into the sub-buffers for a given sub-buffer */ | |
| 3628 | 3632 | static int rb_meta_subbuf_idx(struct ring_buffer_cpu_meta *meta, void *subbuf) | |
| 3629 | 3633 | { | |
| 3630 | - | void *subbuf_array; | |
| 3634 | + | void *subbuf_array = rb_subbufs_from_meta(meta); | |
| 3631 | 3635 | ||
| 3632 | - | subbuf_array = (void *)meta + sizeof(int) * meta->nr_subbufs; | |
| 3633 | - | subbuf_array = (void *)ALIGN((unsigned long)subbuf_array, meta->subbuf_size); | |
| 3634 | 3636 | return (subbuf - subbuf_array) / meta->subbuf_size; | |
| 3635 | 3637 | } | |
| 3636 | 3638 | ||
| @@ -7997,12 +7999,8 @@ consume: | |||
| 7997 | 7999 | goto out; | |
| 7998 | 8000 | } | |
| 7999 | 8001 | ||
| 8000 | - | /* Did the reader catch up with the writer? */ | |
| 8001 | - | if (cpu_buffer->reader_page == cpu_buffer->commit_page) | |
| 8002 | - | goto out; | |
| 8003 | - | ||
| 8004 | 8002 | reader = rb_get_reader_page(cpu_buffer); | |
| 8005 | - | if (WARN_ON(!reader)) | |
| 8003 | + | if (!reader) | |
| 8006 | 8004 | goto out; | |
| 8007 | 8005 | ||
| 8008 | 8006 | /* Check if any events were dropped */ | |
modified kernel/trace/trace.c
| @@ -99,6 +99,12 @@ struct tracers { | |||
| 99 | 99 | struct tracer_flags *flags; | |
| 100 | 100 | }; | |
| 101 | 101 | ||
| 102 | + | /* | |
| 103 | + | * Tracers that do not define their own flags use these empty flags, | |
| 104 | + | * as tr->current_trace_flags must never be NULL. | |
| 105 | + | */ | |
| 106 | + | static struct tracer_flags no_tracer_flags; | |
| 107 | + | ||
| 102 | 108 | /* | |
| 103 | 109 | * To prevent the comm cache from being overwritten when no | |
| 104 | 110 | * tracing is active, only save the comm when a trace event | |
| @@ -1318,7 +1324,12 @@ static int run_tracer_selftest(struct tracer *type) | |||
| 1318 | 1324 | tracing_reset_online_cpus(&tr->array_buffer); | |
| 1319 | 1325 | ||
| 1320 | 1326 | tr->current_trace = type; | |
| 1321 | - | tr->current_trace_flags = type->flags ? : type->default_flags; | |
| 1327 | + | if (type->flags) | |
| 1328 | + | tr->current_trace_flags = type->flags; | |
| 1329 | + | else if (type->default_flags) | |
| 1330 | + | tr->current_trace_flags = type->default_flags; | |
| 1331 | + | else | |
| 1332 | + | tr->current_trace_flags = &no_tracer_flags; | |
| 1322 | 1333 | ||
| 1323 | 1334 | #ifdef CONFIG_TRACER_MAX_TRACE | |
| 1324 | 1335 | if (tracer_uses_snapshot(type)) { | |
| @@ -5089,7 +5100,12 @@ int tracing_set_tracer(struct trace_array *tr, const char *buf) | |||
| 5089 | 5100 | return ret; | |
| 5090 | 5101 | } | |
| 5091 | 5102 | ||
| 5092 | - | tr->current_trace_flags = t->flags ? : t->tracer->flags; | |
| 5103 | + | if (t->flags) | |
| 5104 | + | tr->current_trace_flags = t->flags; | |
| 5105 | + | else if (t->tracer->flags) | |
| 5106 | + | tr->current_trace_flags = t->tracer->flags; | |
| 5107 | + | else | |
| 5108 | + | tr->current_trace_flags = &no_tracer_flags; | |
| 5093 | 5109 | ||
| 5094 | 5110 | if (trace->init) { | |
| 5095 | 5111 | ret = tracer_init(trace, tr); | |
| @@ -5881,7 +5897,7 @@ static int tracing_buffer_meta_open(struct inode *inode, struct file *filp) | |||
| 5881 | 5897 | ||
| 5882 | 5898 | ret = ring_buffer_meta_seq_init(filp, tr->array_buffer.buffer, cpu); | |
| 5883 | 5899 | if (ret < 0) | |
| 5884 | - | __trace_array_put(tr); | |
| 5900 | + | trace_array_put(tr); | |
| 5885 | 5901 | return ret; | |
| 5886 | 5902 | } | |
| 5887 | 5903 | ||
| @@ -9287,6 +9303,12 @@ static struct notifier_block trace_module_nb = { | |||
| 9287 | 9303 | ||
| 9288 | 9304 | static __init void tracer_init_tracefs_work_func(struct work_struct *work) | |
| 9289 | 9305 | { | |
| 9306 | + | /* | |
| 9307 | + | * Do not attempt to initialize tracefs if tracing was disabled or | |
| 9308 | + | * failed to allocate | |
| 9309 | + | */ | |
| 9310 | + | if (tracing_disabled) | |
| 9311 | + | return; | |
| 9290 | 9312 | ||
| 9291 | 9313 | event_trace_init(); | |
| 9292 | 9314 | ||
modified kernel/trace/trace_events_filter.c
| @@ -482,18 +482,17 @@ predicate_parse(const char *str, int nr_parens, int nr_preds, | |||
| 482 | 482 | int len; | |
| 483 | 483 | int N = 0; | |
| 484 | 484 | int i; | |
| 485 | - | ||
| 486 | - | nr_preds += 2; /* For TRUE and FALSE */ | |
| 485 | + | int nr_preds_alloc = nr_preds + 2; /* For TRUE and FALSE */ | |
| 487 | 486 | ||
| 488 | 487 | op_stack = kmalloc_objs(*op_stack, nr_parens); | |
| 489 | 488 | if (!op_stack) | |
| 490 | 489 | return ERR_PTR(-ENOMEM); | |
| 491 | - | prog_stack = kzalloc_objs(*prog_stack, nr_preds); | |
| 490 | + | prog_stack = kzalloc_objs(*prog_stack, nr_preds_alloc); | |
| 492 | 491 | if (!prog_stack) { | |
| 493 | 492 | parse_error(pe, -ENOMEM, 0); | |
| 494 | 493 | goto out_free; | |
| 495 | 494 | } | |
| 496 | - | inverts = kmalloc_array(nr_preds, sizeof(*inverts), GFP_KERNEL); | |
| 495 | + | inverts = kmalloc_array(nr_preds_alloc, sizeof(*inverts), GFP_KERNEL); | |
| 497 | 496 | if (!inverts) { | |
| 498 | 497 | parse_error(pe, -ENOMEM, 0); | |
| 499 | 498 | goto out_free; | |
modified kernel/trace/trace_events_hist.c
| @@ -289,7 +289,7 @@ static u64 hist_field_log2(struct hist_field *hist_field, | |||
| 289 | 289 | ||
| 290 | 290 | u64 val = hist_fn_call(operand, elt, buffer, rbe, event); | |
| 291 | 291 | ||
| 292 | - | return (u64) ilog2(roundup_pow_of_two(val)); | |
| 292 | + | return order_base_2(val); | |
| 293 | 293 | } | |
| 294 | 294 | ||
| 295 | 295 | static u64 hist_field_bucket(struct hist_field *hist_field, | |
| @@ -873,7 +873,7 @@ static u64 hist_field_timestamp(struct hist_field *hist_field, | |||
| 873 | 873 | struct hist_trigger_data *hist_data = hist_field->hist_data; | |
| 874 | 874 | struct trace_array *tr = hist_data->event_file->tr; | |
| 875 | 875 | ||
| 876 | - | u64 ts = ring_buffer_event_time_stamp(buffer, rbe); | |
| 876 | + | u64 ts = tracing_event_time_stamp(buffer, rbe); | |
| 877 | 877 | ||
| 878 | 878 | if (hist_data->attrs->ts_in_usecs && trace_clock_in_ns(tr)) | |
| 879 | 879 | ts = ns2usecs(ts); | |
| @@ -2121,7 +2121,8 @@ static int init_var_ref(struct hist_field *ref_field, | |||
| 2121 | 2121 | ref_field->size = var_field->size; | |
| 2122 | 2122 | ref_field->is_signed = var_field->is_signed; | |
| 2123 | 2123 | ref_field->flags |= var_field->flags & | |
| 2124 | - | (HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS); | |
| 2124 | + | (HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS | | |
| 2125 | + | HIST_FIELD_FL_STACKTRACE); | |
| 2125 | 2126 | ||
| 2126 | 2127 | if (system) { | |
| 2127 | 2128 | ref_field->system = kstrdup(system, GFP_KERNEL); | |
| @@ -3090,7 +3091,7 @@ create_field_var_hist(struct hist_trigger_data *target_hist_data, | |||
| 3090 | 3091 | key_field = hist_data->fields[i]; | |
| 3091 | 3092 | if (!first) | |
| 3092 | 3093 | seq_buf_putc(&s, ','); | |
| 3093 | - | seq_buf_puts(&s, key_field->field->name); | |
| 3094 | + | expr_field_str(key_field, &s); | |
| 3094 | 3095 | first = false; | |
| 3095 | 3096 | } | |
| 3096 | 3097 | ||
| @@ -3318,6 +3319,7 @@ static struct field_var *create_field_var(struct hist_trigger_data *hist_data, | |||
| 3318 | 3319 | ret = PTR_ERR(var); | |
| 3319 | 3320 | goto err; | |
| 3320 | 3321 | } | |
| 3322 | + | var->flags |= val->flags & HIST_FIELD_FL_STACKTRACE; | |
| 3321 | 3323 | ||
| 3322 | 3324 | field_var = kzalloc_obj(struct field_var); | |
| 3323 | 3325 | if (!field_var) { | |
| @@ -3946,7 +3948,10 @@ static int check_synth_field(struct synth_event *event, | |||
| 3946 | 3948 | && field->is_dynamic) | |
| 3947 | 3949 | return 0; | |
| 3948 | 3950 | ||
| 3949 | - | if (strstr(hist_field->type, "long[") && field->is_stack) | |
| 3951 | + | if (!!(hist_field->flags & HIST_FIELD_FL_STACKTRACE) != field->is_stack) | |
| 3952 | + | return -EINVAL; | |
| 3953 | + | ||
| 3954 | + | if (field->is_stack) | |
| 3950 | 3955 | return 0; | |
| 3951 | 3956 | ||
| 3952 | 3957 | if (strcmp(field->type, hist_field->type) != 0) { | |
| @@ -4487,7 +4492,8 @@ static int create_var_field(struct hist_trigger_data *hist_data, | |||
| 4487 | 4492 | if (!ret && hist_data->fields[val_idx]->flags & HIST_FIELD_FL_EXECNAME) | |
| 4488 | 4493 | update_var_execname(hist_data->fields[val_idx]); | |
| 4489 | 4494 | ||
| 4490 | - | if (!ret && hist_data->fields[val_idx]->flags & | |
| 4495 | + | if (!ret && !(hist_data->fields[val_idx]->flags & HIST_FIELD_FL_ALIAS) && | |
| 4496 | + | hist_data->fields[val_idx]->flags & | |
| 4491 | 4497 | (HIST_FIELD_FL_STRING | HIST_FIELD_FL_STACKTRACE)) | |
| 4492 | 4498 | hist_data->fields[val_idx]->var_str_idx = hist_data->n_var_str++; | |
| 4493 | 4499 | ||
| @@ -5228,7 +5234,8 @@ static void hist_trigger_elt_update(struct hist_trigger_data *hist_data, | |||
| 5228 | 5234 | if (hist_field->flags & HIST_FIELD_FL_VAR) { | |
| 5229 | 5235 | var_idx = hist_field->var.idx; | |
| 5230 | 5236 | ||
| 5231 | - | if (hist_field->flags & | |
| 5237 | + | if (!(hist_field->flags & HIST_FIELD_FL_ALIAS) && | |
| 5238 | + | hist_field->flags & | |
| 5232 | 5239 | (HIST_FIELD_FL_STRING | HIST_FIELD_FL_STACKTRACE)) { | |
| 5233 | 5240 | unsigned int str_start, var_str_idx, idx; | |
| 5234 | 5241 | char *str, *val_str; | |
modified kernel/trace/trace_snapshot.c
| @@ -675,9 +675,12 @@ tracing_snapshot_write(struct file *filp, const char __user *ubuf, size_t cnt, | |||
| 675 | 675 | if (iter->cpu_file != RING_BUFFER_ALL_CPUS) | |
| 676 | 676 | return -EINVAL; | |
| 677 | 677 | #endif | |
| 678 | - | if (tr->allocated_snapshot) | |
| 678 | + | if (tr->allocated_snapshot) { | |
| 679 | 679 | ret = resize_buffer_duplicate_size(&tr->snapshot_buffer, | |
| 680 | 680 | &tr->array_buffer, iter->cpu_file); | |
| 681 | + | if (ret < 0) | |
| 682 | + | return ret; | |
| 683 | + | } | |
| 681 | 684 | ||
| 682 | 685 | ret = tracing_arm_snapshot_locked(tr); | |
| 683 | 686 | if (ret) | |
modified kernel/trace/undefsyms_base.c
| @@ -9,6 +9,7 @@ | |||
| 9 | 9 | ||
| 10 | 10 | #include <linux/atomic.h> | |
| 11 | 11 | #include <linux/string.h> | |
| 12 | + | #include <asm/local.h> | |
| 12 | 13 | #include <asm/page.h> | |
| 13 | 14 | ||
| 14 | 15 | void undefsyms_base(void *p, int n); | |
| @@ -18,11 +19,13 @@ static char page[PAGE_SIZE] __aligned(PAGE_SIZE); | |||
| 18 | 19 | void undefsyms_base(void *p, int n) | |
| 19 | 20 | { | |
| 20 | 21 | char buffer[256] = { 0 }; | |
| 21 | - | ||
| 22 | 22 | u32 u = 0; | |
| 23 | + | ||
| 23 | 24 | memset((char * volatile)page, 8, PAGE_SIZE); | |
| 24 | 25 | memset((char * volatile)buffer, 8, sizeof(buffer)); | |
| 25 | 26 | memcpy((void * volatile)p, buffer, sizeof(buffer)); | |
| 26 | 27 | cmpxchg((u32 * volatile)&u, 0, 8); | |
| 28 | + | cmpxchg((unsigned long *)p, 0, 8); | |
| 29 | + | local_set((local_t *)p, 8); | |
| 27 | 30 | WARN_ON(n == 0xdeadbeef); | |
| 28 | 31 | } | |
modified tools/gpio/Makefile
| @@ -7,13 +7,7 @@ bindir ?= /usr/bin | |||
| 7 | 7 | # isn't set and when invoked from selftests build, where srctree | |
| 8 | 8 | # is set to ".". building_out_of_srctree is undefined for in srctree | |
| 9 | 9 | # builds | |
| 10 | - | ifeq ($(srctree),) | |
| 11 | - | update_srctree := 1 | |
| 12 | - | endif | |
| 13 | 10 | ifndef building_out_of_srctree | |
| 14 | - | update_srctree := 1 | |
| 15 | - | endif | |
| 16 | - | ifeq ($(update_srctree),1) | |
| 17 | 11 | srctree := $(patsubst %/,%,$(dir $(CURDIR))) | |
| 18 | 12 | srctree := $(patsubst %/,%,$(dir $(srctree))) | |
| 19 | 13 | endif | |