diff options
| author | Rob Herring <robh@kernel.org> | 2018-03-08 10:21:07 -0500 |
|---|---|---|
| committer | Rob Herring <robh@kernel.org> | 2018-03-08 10:21:07 -0500 |
| commit | c679fa6e3aaa5c58fc514b5b88cfa82774b8d390 (patch) | |
| tree | 0c10b339368bd1795152a66a4e245e6f654fb3ec /kernel | |
| parent | bdb7013df910681f84eff27b07791d4c160cb76f (diff) | |
| parent | 4fd98e374fd377ae0458a9dc44aa779cf9631ddd (diff) | |
Merge branch 'dtc-update' into dt/next
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/bpf/arraymap.c | 33 | ||||
| -rw-r--r-- | kernel/bpf/core.c | 2 | ||||
| -rw-r--r-- | kernel/bpf/cpumap.c | 2 | ||||
| -rw-r--r-- | kernel/bpf/lpm_trie.c | 14 | ||||
| -rw-r--r-- | kernel/bpf/sockmap.c | 3 | ||||
| -rw-r--r-- | kernel/fork.c | 15 | ||||
| -rw-r--r-- | kernel/irq/irqdomain.c | 18 | ||||
| -rw-r--r-- | kernel/irq/matrix.c | 23 | ||||
| -rw-r--r-- | kernel/kprobes.c | 178 | ||||
| -rw-r--r-- | kernel/locking/qspinlock.c | 21 | ||||
| -rw-r--r-- | kernel/relay.c | 2 | ||||
| -rw-r--r-- | kernel/sched/core.c | 27 | ||||
| -rw-r--r-- | kernel/sched/cpufreq_schedutil.c | 2 | ||||
| -rw-r--r-- | kernel/sched/deadline.c | 6 | ||||
| -rw-r--r-- | kernel/sched/rt.c | 3 | ||||
| -rw-r--r-- | kernel/seccomp.c | 6 | ||||
| -rw-r--r-- | kernel/trace/bpf_trace.c | 2 | ||||
| -rw-r--r-- | kernel/user.c | 3 | ||||
| -rw-r--r-- | kernel/workqueue.c | 16 |
19 files changed, 243 insertions, 133 deletions
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index b1f66480135b..14750e7c5ee4 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c | |||
| @@ -26,8 +26,10 @@ static void bpf_array_free_percpu(struct bpf_array *array) | |||
| 26 | { | 26 | { |
| 27 | int i; | 27 | int i; |
| 28 | 28 | ||
| 29 | for (i = 0; i < array->map.max_entries; i++) | 29 | for (i = 0; i < array->map.max_entries; i++) { |
| 30 | free_percpu(array->pptrs[i]); | 30 | free_percpu(array->pptrs[i]); |
| 31 | cond_resched(); | ||
| 32 | } | ||
| 31 | } | 33 | } |
| 32 | 34 | ||
| 33 | static int bpf_array_alloc_percpu(struct bpf_array *array) | 35 | static int bpf_array_alloc_percpu(struct bpf_array *array) |
| @@ -43,6 +45,7 @@ static int bpf_array_alloc_percpu(struct bpf_array *array) | |||
| 43 | return -ENOMEM; | 45 | return -ENOMEM; |
| 44 | } | 46 | } |
| 45 | array->pptrs[i] = ptr; | 47 | array->pptrs[i] = ptr; |
| 48 | cond_resched(); | ||
| 46 | } | 49 | } |
| 47 | 50 | ||
| 48 | return 0; | 51 | return 0; |
| @@ -73,11 +76,11 @@ static int array_map_alloc_check(union bpf_attr *attr) | |||
| 73 | static struct bpf_map *array_map_alloc(union bpf_attr *attr) | 76 | static struct bpf_map *array_map_alloc(union bpf_attr *attr) |
| 74 | { | 77 | { |
| 75 | bool percpu = attr->map_type == BPF_MAP_TYPE_PERCPU_ARRAY; | 78 | bool percpu = attr->map_type == BPF_MAP_TYPE_PERCPU_ARRAY; |
| 76 | int numa_node = bpf_map_attr_numa_node(attr); | 79 | int ret, numa_node = bpf_map_attr_numa_node(attr); |
| 77 | u32 elem_size, index_mask, max_entries; | 80 | u32 elem_size, index_mask, max_entries; |
| 78 | bool unpriv = !capable(CAP_SYS_ADMIN); | 81 | bool unpriv = !capable(CAP_SYS_ADMIN); |
| 82 | u64 cost, array_size, mask64; | ||
| 79 | struct bpf_array *array; | 83 | struct bpf_array *array; |
| 80 | u64 array_size, mask64; | ||
| 81 | 84 | ||
| 82 | elem_size = round_up(attr->value_size, 8); | 85 | elem_size = round_up(attr->value_size, 8); |
| 83 | 86 | ||
| @@ -109,8 +112,19 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr) | |||
| 109 | array_size += (u64) max_entries * elem_size; | 112 | array_size += (u64) max_entries * elem_size; |
| 110 | 113 | ||
| 111 | /* make sure there is no u32 overflow later in round_up() */ | 114 | /* make sure there is no u32 overflow later in round_up() */ |
| 112 | if (array_size >= U32_MAX - PAGE_SIZE) | 115 | cost = array_size; |
| 116 | if (cost >= U32_MAX - PAGE_SIZE) | ||
| 113 | return ERR_PTR(-ENOMEM); | 117 | return ERR_PTR(-ENOMEM); |
| 118 | if (percpu) { | ||
| 119 | cost += (u64)attr->max_entries * elem_size * num_possible_cpus(); | ||
| 120 | if (cost >= U32_MAX - PAGE_SIZE) | ||
| 121 | return ERR_PTR(-ENOMEM); | ||
| 122 | } | ||
| 123 | cost = round_up(cost, PAGE_SIZE) >> PAGE_SHIFT; | ||
| 124 | |||
| 125 | ret = bpf_map_precharge_memlock(cost); | ||
| 126 | if (ret < 0) | ||
| 127 | return ERR_PTR(ret); | ||
| 114 | 128 | ||
| 115 | /* allocate all map elements and zero-initialize them */ | 129 | /* allocate all map elements and zero-initialize them */ |
| 116 | array = bpf_map_area_alloc(array_size, numa_node); | 130 | array = bpf_map_area_alloc(array_size, numa_node); |
| @@ -121,20 +135,13 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr) | |||
| 121 | 135 | ||
| 122 | /* copy mandatory map attributes */ | 136 | /* copy mandatory map attributes */ |
| 123 | bpf_map_init_from_attr(&array->map, attr); | 137 | bpf_map_init_from_attr(&array->map, attr); |
| 138 | array->map.pages = cost; | ||
| 124 | array->elem_size = elem_size; | 139 | array->elem_size = elem_size; |
| 125 | 140 | ||
| 126 | if (!percpu) | 141 | if (percpu && bpf_array_alloc_percpu(array)) { |
| 127 | goto out; | ||
| 128 | |||
| 129 | array_size += (u64) attr->max_entries * elem_size * num_possible_cpus(); | ||
| 130 | |||
| 131 | if (array_size >= U32_MAX - PAGE_SIZE || | ||
| 132 | bpf_array_alloc_percpu(array)) { | ||
| 133 | bpf_map_area_free(array); | 142 | bpf_map_area_free(array); |
| 134 | return ERR_PTR(-ENOMEM); | 143 | return ERR_PTR(-ENOMEM); |
| 135 | } | 144 | } |
| 136 | out: | ||
| 137 | array->map.pages = round_up(array_size, PAGE_SIZE) >> PAGE_SHIFT; | ||
| 138 | 145 | ||
| 139 | return &array->map; | 146 | return &array->map; |
| 140 | } | 147 | } |
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 29ca9208dcfa..d315b393abdd 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c | |||
| @@ -1590,7 +1590,7 @@ int bpf_prog_array_copy_to_user(struct bpf_prog_array __rcu *progs, | |||
| 1590 | * so always copy 'cnt' prog_ids to the user. | 1590 | * so always copy 'cnt' prog_ids to the user. |
| 1591 | * In a rare race the user will see zero prog_ids | 1591 | * In a rare race the user will see zero prog_ids |
| 1592 | */ | 1592 | */ |
| 1593 | ids = kcalloc(cnt, sizeof(u32), GFP_USER); | 1593 | ids = kcalloc(cnt, sizeof(u32), GFP_USER | __GFP_NOWARN); |
| 1594 | if (!ids) | 1594 | if (!ids) |
| 1595 | return -ENOMEM; | 1595 | return -ENOMEM; |
| 1596 | rcu_read_lock(); | 1596 | rcu_read_lock(); |
diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c index fbfdada6caee..a4bb0b34375a 100644 --- a/kernel/bpf/cpumap.c +++ b/kernel/bpf/cpumap.c | |||
| @@ -334,7 +334,7 @@ static int cpu_map_kthread_run(void *data) | |||
| 334 | static struct bpf_cpu_map_entry *__cpu_map_entry_alloc(u32 qsize, u32 cpu, | 334 | static struct bpf_cpu_map_entry *__cpu_map_entry_alloc(u32 qsize, u32 cpu, |
| 335 | int map_id) | 335 | int map_id) |
| 336 | { | 336 | { |
| 337 | gfp_t gfp = GFP_ATOMIC|__GFP_NOWARN; | 337 | gfp_t gfp = GFP_KERNEL | __GFP_NOWARN; |
| 338 | struct bpf_cpu_map_entry *rcpu; | 338 | struct bpf_cpu_map_entry *rcpu; |
| 339 | int numa, err; | 339 | int numa, err; |
| 340 | 340 | ||
diff --git a/kernel/bpf/lpm_trie.c b/kernel/bpf/lpm_trie.c index 7b469d10d0e9..b4b5b81e7251 100644 --- a/kernel/bpf/lpm_trie.c +++ b/kernel/bpf/lpm_trie.c | |||
| @@ -555,7 +555,10 @@ static void trie_free(struct bpf_map *map) | |||
| 555 | struct lpm_trie_node __rcu **slot; | 555 | struct lpm_trie_node __rcu **slot; |
| 556 | struct lpm_trie_node *node; | 556 | struct lpm_trie_node *node; |
| 557 | 557 | ||
| 558 | raw_spin_lock(&trie->lock); | 558 | /* Wait for outstanding programs to complete |
| 559 | * update/lookup/delete/get_next_key and free the trie. | ||
| 560 | */ | ||
| 561 | synchronize_rcu(); | ||
| 559 | 562 | ||
| 560 | /* Always start at the root and walk down to a node that has no | 563 | /* Always start at the root and walk down to a node that has no |
| 561 | * children. Then free that node, nullify its reference in the parent | 564 | * children. Then free that node, nullify its reference in the parent |
| @@ -566,10 +569,9 @@ static void trie_free(struct bpf_map *map) | |||
| 566 | slot = &trie->root; | 569 | slot = &trie->root; |
| 567 | 570 | ||
| 568 | for (;;) { | 571 | for (;;) { |
| 569 | node = rcu_dereference_protected(*slot, | 572 | node = rcu_dereference_protected(*slot, 1); |
| 570 | lockdep_is_held(&trie->lock)); | ||
| 571 | if (!node) | 573 | if (!node) |
| 572 | goto unlock; | 574 | goto out; |
| 573 | 575 | ||
| 574 | if (rcu_access_pointer(node->child[0])) { | 576 | if (rcu_access_pointer(node->child[0])) { |
| 575 | slot = &node->child[0]; | 577 | slot = &node->child[0]; |
| @@ -587,8 +589,8 @@ static void trie_free(struct bpf_map *map) | |||
| 587 | } | 589 | } |
| 588 | } | 590 | } |
| 589 | 591 | ||
| 590 | unlock: | 592 | out: |
| 591 | raw_spin_unlock(&trie->lock); | 593 | kfree(trie); |
| 592 | } | 594 | } |
| 593 | 595 | ||
| 594 | static int trie_get_next_key(struct bpf_map *map, void *_key, void *_next_key) | 596 | static int trie_get_next_key(struct bpf_map *map, void *_key, void *_next_key) |
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c index 48c33417d13c..a927e89dad6e 100644 --- a/kernel/bpf/sockmap.c +++ b/kernel/bpf/sockmap.c | |||
| @@ -521,8 +521,8 @@ static struct smap_psock *smap_init_psock(struct sock *sock, | |||
| 521 | static struct bpf_map *sock_map_alloc(union bpf_attr *attr) | 521 | static struct bpf_map *sock_map_alloc(union bpf_attr *attr) |
| 522 | { | 522 | { |
| 523 | struct bpf_stab *stab; | 523 | struct bpf_stab *stab; |
| 524 | int err = -EINVAL; | ||
| 525 | u64 cost; | 524 | u64 cost; |
| 525 | int err; | ||
| 526 | 526 | ||
| 527 | if (!capable(CAP_NET_ADMIN)) | 527 | if (!capable(CAP_NET_ADMIN)) |
| 528 | return ERR_PTR(-EPERM); | 528 | return ERR_PTR(-EPERM); |
| @@ -547,6 +547,7 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr) | |||
| 547 | 547 | ||
| 548 | /* make sure page count doesn't overflow */ | 548 | /* make sure page count doesn't overflow */ |
| 549 | cost = (u64) stab->map.max_entries * sizeof(struct sock *); | 549 | cost = (u64) stab->map.max_entries * sizeof(struct sock *); |
| 550 | err = -EINVAL; | ||
| 550 | if (cost >= U32_MAX - PAGE_SIZE) | 551 | if (cost >= U32_MAX - PAGE_SIZE) |
| 551 | goto free_stab; | 552 | goto free_stab; |
| 552 | 553 | ||
diff --git a/kernel/fork.c b/kernel/fork.c index be8aa5b98666..e5d9d405ae4e 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
| @@ -592,7 +592,7 @@ static void check_mm(struct mm_struct *mm) | |||
| 592 | * is dropped: either by a lazy thread or by | 592 | * is dropped: either by a lazy thread or by |
| 593 | * mmput. Free the page directory and the mm. | 593 | * mmput. Free the page directory and the mm. |
| 594 | */ | 594 | */ |
| 595 | static void __mmdrop(struct mm_struct *mm) | 595 | void __mmdrop(struct mm_struct *mm) |
| 596 | { | 596 | { |
| 597 | BUG_ON(mm == &init_mm); | 597 | BUG_ON(mm == &init_mm); |
| 598 | mm_free_pgd(mm); | 598 | mm_free_pgd(mm); |
| @@ -603,18 +603,7 @@ static void __mmdrop(struct mm_struct *mm) | |||
| 603 | put_user_ns(mm->user_ns); | 603 | put_user_ns(mm->user_ns); |
| 604 | free_mm(mm); | 604 | free_mm(mm); |
| 605 | } | 605 | } |
| 606 | 606 | EXPORT_SYMBOL_GPL(__mmdrop); | |
| 607 | void mmdrop(struct mm_struct *mm) | ||
| 608 | { | ||
| 609 | /* | ||
| 610 | * The implicit full barrier implied by atomic_dec_and_test() is | ||
| 611 | * required by the membarrier system call before returning to | ||
| 612 | * user-space, after storing to rq->curr. | ||
| 613 | */ | ||
| 614 | if (unlikely(atomic_dec_and_test(&mm->mm_count))) | ||
| 615 | __mmdrop(mm); | ||
| 616 | } | ||
| 617 | EXPORT_SYMBOL_GPL(mmdrop); | ||
| 618 | 607 | ||
| 619 | static void mmdrop_async_fn(struct work_struct *work) | 608 | static void mmdrop_async_fn(struct work_struct *work) |
| 620 | { | 609 | { |
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index e6a9c36470ee..82b8b18ee1eb 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c | |||
| @@ -1726,25 +1726,14 @@ static int irq_domain_debug_show(struct seq_file *m, void *p) | |||
| 1726 | irq_domain_debug_show_one(m, d, 0); | 1726 | irq_domain_debug_show_one(m, d, 0); |
| 1727 | return 0; | 1727 | return 0; |
| 1728 | } | 1728 | } |
| 1729 | 1729 | DEFINE_SHOW_ATTRIBUTE(irq_domain_debug); | |
| 1730 | static int irq_domain_debug_open(struct inode *inode, struct file *file) | ||
| 1731 | { | ||
| 1732 | return single_open(file, irq_domain_debug_show, inode->i_private); | ||
| 1733 | } | ||
| 1734 | |||
| 1735 | static const struct file_operations dfs_domain_ops = { | ||
| 1736 | .open = irq_domain_debug_open, | ||
| 1737 | .read = seq_read, | ||
| 1738 | .llseek = seq_lseek, | ||
| 1739 | .release = single_release, | ||
| 1740 | }; | ||
| 1741 | 1730 | ||
| 1742 | static void debugfs_add_domain_dir(struct irq_domain *d) | 1731 | static void debugfs_add_domain_dir(struct irq_domain *d) |
| 1743 | { | 1732 | { |
| 1744 | if (!d->name || !domain_dir || d->debugfs_file) | 1733 | if (!d->name || !domain_dir || d->debugfs_file) |
| 1745 | return; | 1734 | return; |
| 1746 | d->debugfs_file = debugfs_create_file(d->name, 0444, domain_dir, d, | 1735 | d->debugfs_file = debugfs_create_file(d->name, 0444, domain_dir, d, |
| 1747 | &dfs_domain_ops); | 1736 | &irq_domain_debug_fops); |
| 1748 | } | 1737 | } |
| 1749 | 1738 | ||
| 1750 | static void debugfs_remove_domain_dir(struct irq_domain *d) | 1739 | static void debugfs_remove_domain_dir(struct irq_domain *d) |
| @@ -1760,7 +1749,8 @@ void __init irq_domain_debugfs_init(struct dentry *root) | |||
| 1760 | if (!domain_dir) | 1749 | if (!domain_dir) |
| 1761 | return; | 1750 | return; |
| 1762 | 1751 | ||
| 1763 | debugfs_create_file("default", 0444, domain_dir, NULL, &dfs_domain_ops); | 1752 | debugfs_create_file("default", 0444, domain_dir, NULL, |
| 1753 | &irq_domain_debug_fops); | ||
| 1764 | mutex_lock(&irq_domain_mutex); | 1754 | mutex_lock(&irq_domain_mutex); |
| 1765 | list_for_each_entry(d, &irq_domain_list, link) | 1755 | list_for_each_entry(d, &irq_domain_list, link) |
| 1766 | debugfs_add_domain_dir(d); | 1756 | debugfs_add_domain_dir(d); |
diff --git a/kernel/irq/matrix.c b/kernel/irq/matrix.c index 5187dfe809ac..4c5770407031 100644 --- a/kernel/irq/matrix.c +++ b/kernel/irq/matrix.c | |||
| @@ -16,6 +16,7 @@ struct cpumap { | |||
| 16 | unsigned int available; | 16 | unsigned int available; |
| 17 | unsigned int allocated; | 17 | unsigned int allocated; |
| 18 | unsigned int managed; | 18 | unsigned int managed; |
| 19 | bool initialized; | ||
| 19 | bool online; | 20 | bool online; |
| 20 | unsigned long alloc_map[IRQ_MATRIX_SIZE]; | 21 | unsigned long alloc_map[IRQ_MATRIX_SIZE]; |
| 21 | unsigned long managed_map[IRQ_MATRIX_SIZE]; | 22 | unsigned long managed_map[IRQ_MATRIX_SIZE]; |
| @@ -81,9 +82,11 @@ void irq_matrix_online(struct irq_matrix *m) | |||
| 81 | 82 | ||
| 82 | BUG_ON(cm->online); | 83 | BUG_ON(cm->online); |
| 83 | 84 | ||
| 84 | bitmap_zero(cm->alloc_map, m->matrix_bits); | 85 | if (!cm->initialized) { |
| 85 | cm->available = m->alloc_size - (cm->managed + m->systembits_inalloc); | 86 | cm->available = m->alloc_size; |
| 86 | cm->allocated = 0; | 87 | cm->available -= cm->managed + m->systembits_inalloc; |
| 88 | cm->initialized = true; | ||
| 89 | } | ||
| 87 | m->global_available += cm->available; | 90 | m->global_available += cm->available; |
| 88 | cm->online = true; | 91 | cm->online = true; |
| 89 | m->online_maps++; | 92 | m->online_maps++; |
| @@ -370,14 +373,16 @@ void irq_matrix_free(struct irq_matrix *m, unsigned int cpu, | |||
| 370 | if (WARN_ON_ONCE(bit < m->alloc_start || bit >= m->alloc_end)) | 373 | if (WARN_ON_ONCE(bit < m->alloc_start || bit >= m->alloc_end)) |
| 371 | return; | 374 | return; |
| 372 | 375 | ||
| 373 | if (cm->online) { | 376 | clear_bit(bit, cm->alloc_map); |
| 374 | clear_bit(bit, cm->alloc_map); | 377 | cm->allocated--; |
| 375 | cm->allocated--; | 378 | |
| 379 | if (cm->online) | ||
| 376 | m->total_allocated--; | 380 | m->total_allocated--; |
| 377 | if (!managed) { | 381 | |
| 378 | cm->available++; | 382 | if (!managed) { |
| 383 | cm->available++; | ||
| 384 | if (cm->online) | ||
| 379 | m->global_available++; | 385 | m->global_available++; |
| 380 | } | ||
| 381 | } | 386 | } |
| 382 | trace_irq_matrix_free(bit, cpu, m, cm); | 387 | trace_irq_matrix_free(bit, cpu, m, cm); |
| 383 | } | 388 | } |
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index da2ccf142358..102160ff5c66 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
| @@ -978,67 +978,90 @@ static int prepare_kprobe(struct kprobe *p) | |||
| 978 | } | 978 | } |
| 979 | 979 | ||
| 980 | /* Caller must lock kprobe_mutex */ | 980 | /* Caller must lock kprobe_mutex */ |
| 981 | static void arm_kprobe_ftrace(struct kprobe *p) | 981 | static int arm_kprobe_ftrace(struct kprobe *p) |
| 982 | { | 982 | { |
| 983 | int ret; | 983 | int ret = 0; |
| 984 | 984 | ||
| 985 | ret = ftrace_set_filter_ip(&kprobe_ftrace_ops, | 985 | ret = ftrace_set_filter_ip(&kprobe_ftrace_ops, |
| 986 | (unsigned long)p->addr, 0, 0); | 986 | (unsigned long)p->addr, 0, 0); |
| 987 | WARN(ret < 0, "Failed to arm kprobe-ftrace at %p (%d)\n", p->addr, ret); | 987 | if (ret) { |
| 988 | kprobe_ftrace_enabled++; | 988 | pr_debug("Failed to arm kprobe-ftrace at %p (%d)\n", p->addr, ret); |
| 989 | if (kprobe_ftrace_enabled == 1) { | 989 | return ret; |
| 990 | } | ||
| 991 | |||
| 992 | if (kprobe_ftrace_enabled == 0) { | ||
| 990 | ret = register_ftrace_function(&kprobe_ftrace_ops); | 993 | ret = register_ftrace_function(&kprobe_ftrace_ops); |
| 991 | WARN(ret < 0, "Failed to init kprobe-ftrace (%d)\n", ret); | 994 | if (ret) { |
| 995 | pr_debug("Failed to init kprobe-ftrace (%d)\n", ret); | ||
| 996 | goto err_ftrace; | ||
| 997 | } | ||
| 992 | } | 998 | } |
| 999 | |||
| 1000 | kprobe_ftrace_enabled++; | ||
| 1001 | return ret; | ||
| 1002 | |||
| 1003 | err_ftrace: | ||
| 1004 | /* | ||
| 1005 | * Note: Since kprobe_ftrace_ops has IPMODIFY set, and ftrace requires a | ||
| 1006 | * non-empty filter_hash for IPMODIFY ops, we're safe from an accidental | ||
| 1007 | * empty filter_hash which would undesirably trace all functions. | ||
| 1008 | */ | ||
| 1009 | ftrace_set_filter_ip(&kprobe_ftrace_ops, (unsigned long)p->addr, 1, 0); | ||
| 1010 | return ret; | ||
| 993 | } | 1011 | } |
| 994 | 1012 | ||
| 995 | /* Caller must lock kprobe_mutex */ | 1013 | /* Caller must lock kprobe_mutex */ |
| 996 | static void disarm_kprobe_ftrace(struct kprobe *p) | 1014 | static int disarm_kprobe_ftrace(struct kprobe *p) |
| 997 | { | 1015 | { |
| 998 | int ret; | 1016 | int ret = 0; |
| 999 | 1017 | ||
| 1000 | kprobe_ftrace_enabled--; | 1018 | if (kprobe_ftrace_enabled == 1) { |
| 1001 | if (kprobe_ftrace_enabled == 0) { | ||
| 1002 | ret = unregister_ftrace_function(&kprobe_ftrace_ops); | 1019 | ret = unregister_ftrace_function(&kprobe_ftrace_ops); |
| 1003 | WARN(ret < 0, "Failed to init kprobe-ftrace (%d)\n", ret); | 1020 | if (WARN(ret < 0, "Failed to unregister kprobe-ftrace (%d)\n", ret)) |
| 1021 | return ret; | ||
| 1004 | } | 1022 | } |
| 1023 | |||
| 1024 | kprobe_ftrace_enabled--; | ||
| 1025 | |||
| 1005 | ret = ftrace_set_filter_ip(&kprobe_ftrace_ops, | 1026 | ret = ftrace_set_filter_ip(&kprobe_ftrace_ops, |
| 1006 | (unsigned long)p->addr, 1, 0); | 1027 | (unsigned long)p->addr, 1, 0); |
| 1007 | WARN(ret < 0, "Failed to disarm kprobe-ftrace at %p (%d)\n", p->addr, ret); | 1028 | WARN(ret < 0, "Failed to disarm kprobe-ftrace at %p (%d)\n", p->addr, ret); |
| 1029 | return ret; | ||
| 1008 | } | 1030 | } |
| 1009 | #else /* !CONFIG_KPROBES_ON_FTRACE */ | 1031 | #else /* !CONFIG_KPROBES_ON_FTRACE */ |
| 1010 | #define prepare_kprobe(p) arch_prepare_kprobe(p) | 1032 | #define prepare_kprobe(p) arch_prepare_kprobe(p) |
| 1011 | #define arm_kprobe_ftrace(p) do {} while (0) | 1033 | #define arm_kprobe_ftrace(p) (-ENODEV) |
| 1012 | #define disarm_kprobe_ftrace(p) do {} while (0) | 1034 | #define disarm_kprobe_ftrace(p) (-ENODEV) |
| 1013 | #endif | 1035 | #endif |
| 1014 | 1036 | ||
| 1015 | /* Arm a kprobe with text_mutex */ | 1037 | /* Arm a kprobe with text_mutex */ |
| 1016 | static void arm_kprobe(struct kprobe *kp) | 1038 | static int arm_kprobe(struct kprobe *kp) |
| 1017 | { | 1039 | { |
| 1018 | if (unlikely(kprobe_ftrace(kp))) { | 1040 | if (unlikely(kprobe_ftrace(kp))) |
| 1019 | arm_kprobe_ftrace(kp); | 1041 | return arm_kprobe_ftrace(kp); |
| 1020 | return; | 1042 | |
| 1021 | } | ||
| 1022 | cpus_read_lock(); | 1043 | cpus_read_lock(); |
| 1023 | mutex_lock(&text_mutex); | 1044 | mutex_lock(&text_mutex); |
| 1024 | __arm_kprobe(kp); | 1045 | __arm_kprobe(kp); |
| 1025 | mutex_unlock(&text_mutex); | 1046 | mutex_unlock(&text_mutex); |
| 1026 | cpus_read_unlock(); | 1047 | cpus_read_unlock(); |
| 1048 | |||
| 1049 | return 0; | ||
| 1027 | } | 1050 | } |
| 1028 | 1051 | ||
| 1029 | /* Disarm a kprobe with text_mutex */ | 1052 | /* Disarm a kprobe with text_mutex */ |
| 1030 | static void disarm_kprobe(struct kprobe *kp, bool reopt) | 1053 | static int disarm_kprobe(struct kprobe *kp, bool reopt) |
| 1031 | { | 1054 | { |
| 1032 | if (unlikely(kprobe_ftrace(kp))) { | 1055 | if (unlikely(kprobe_ftrace(kp))) |
| 1033 | disarm_kprobe_ftrace(kp); | 1056 | return disarm_kprobe_ftrace(kp); |
| 1034 | return; | ||
| 1035 | } | ||
| 1036 | 1057 | ||
| 1037 | cpus_read_lock(); | 1058 | cpus_read_lock(); |
| 1038 | mutex_lock(&text_mutex); | 1059 | mutex_lock(&text_mutex); |
| 1039 | __disarm_kprobe(kp, reopt); | 1060 | __disarm_kprobe(kp, reopt); |
| 1040 | mutex_unlock(&text_mutex); | 1061 | mutex_unlock(&text_mutex); |
| 1041 | cpus_read_unlock(); | 1062 | cpus_read_unlock(); |
| 1063 | |||
| 1064 | return 0; | ||
| 1042 | } | 1065 | } |
| 1043 | 1066 | ||
| 1044 | /* | 1067 | /* |
| @@ -1362,9 +1385,15 @@ out: | |||
| 1362 | 1385 | ||
| 1363 | if (ret == 0 && kprobe_disabled(ap) && !kprobe_disabled(p)) { | 1386 | if (ret == 0 && kprobe_disabled(ap) && !kprobe_disabled(p)) { |
| 1364 | ap->flags &= ~KPROBE_FLAG_DISABLED; | 1387 | ap->flags &= ~KPROBE_FLAG_DISABLED; |
| 1365 | if (!kprobes_all_disarmed) | 1388 | if (!kprobes_all_disarmed) { |
| 1366 | /* Arm the breakpoint again. */ | 1389 | /* Arm the breakpoint again. */ |
| 1367 | arm_kprobe(ap); | 1390 | ret = arm_kprobe(ap); |
| 1391 | if (ret) { | ||
| 1392 | ap->flags |= KPROBE_FLAG_DISABLED; | ||
| 1393 | list_del_rcu(&p->list); | ||
| 1394 | synchronize_sched(); | ||
| 1395 | } | ||
| 1396 | } | ||
| 1368 | } | 1397 | } |
| 1369 | return ret; | 1398 | return ret; |
| 1370 | } | 1399 | } |
| @@ -1573,8 +1602,14 @@ int register_kprobe(struct kprobe *p) | |||
| 1573 | hlist_add_head_rcu(&p->hlist, | 1602 | hlist_add_head_rcu(&p->hlist, |
| 1574 | &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]); | 1603 | &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]); |
| 1575 | 1604 | ||
| 1576 | if (!kprobes_all_disarmed && !kprobe_disabled(p)) | 1605 | if (!kprobes_all_disarmed && !kprobe_disabled(p)) { |
| 1577 | arm_kprobe(p); | 1606 | ret = arm_kprobe(p); |
| 1607 | if (ret) { | ||
| 1608 | hlist_del_rcu(&p->hlist); | ||
| 1609 | synchronize_sched(); | ||
| 1610 | goto out; | ||
| 1611 | } | ||
| 1612 | } | ||
| 1578 | 1613 | ||
| 1579 | /* Try to optimize kprobe */ | 1614 | /* Try to optimize kprobe */ |
| 1580 | try_to_optimize_kprobe(p); | 1615 | try_to_optimize_kprobe(p); |
| @@ -1608,11 +1643,12 @@ static int aggr_kprobe_disabled(struct kprobe *ap) | |||
| 1608 | static struct kprobe *__disable_kprobe(struct kprobe *p) | 1643 | static struct kprobe *__disable_kprobe(struct kprobe *p) |
| 1609 | { | 1644 | { |
| 1610 | struct kprobe *orig_p; | 1645 | struct kprobe *orig_p; |
| 1646 | int ret; | ||
| 1611 | 1647 | ||
| 1612 | /* Get an original kprobe for return */ | 1648 | /* Get an original kprobe for return */ |
| 1613 | orig_p = __get_valid_kprobe(p); | 1649 | orig_p = __get_valid_kprobe(p); |
| 1614 | if (unlikely(orig_p == NULL)) | 1650 | if (unlikely(orig_p == NULL)) |
| 1615 | return NULL; | 1651 | return ERR_PTR(-EINVAL); |
| 1616 | 1652 | ||
| 1617 | if (!kprobe_disabled(p)) { | 1653 | if (!kprobe_disabled(p)) { |
| 1618 | /* Disable probe if it is a child probe */ | 1654 | /* Disable probe if it is a child probe */ |
| @@ -1626,8 +1662,13 @@ static struct kprobe *__disable_kprobe(struct kprobe *p) | |||
| 1626 | * should have already been disarmed, so | 1662 | * should have already been disarmed, so |
| 1627 | * skip unneed disarming process. | 1663 | * skip unneed disarming process. |
| 1628 | */ | 1664 | */ |
| 1629 | if (!kprobes_all_disarmed) | 1665 | if (!kprobes_all_disarmed) { |
| 1630 | disarm_kprobe(orig_p, true); | 1666 | ret = disarm_kprobe(orig_p, true); |
| 1667 | if (ret) { | ||
| 1668 | p->flags &= ~KPROBE_FLAG_DISABLED; | ||
| 1669 | return ERR_PTR(ret); | ||
| 1670 | } | ||
| 1671 | } | ||
| 1631 | orig_p->flags |= KPROBE_FLAG_DISABLED; | 1672 | orig_p->flags |= KPROBE_FLAG_DISABLED; |
| 1632 | } | 1673 | } |
| 1633 | } | 1674 | } |
| @@ -1644,8 +1685,8 @@ static int __unregister_kprobe_top(struct kprobe *p) | |||
| 1644 | 1685 | ||
| 1645 | /* Disable kprobe. This will disarm it if needed. */ | 1686 | /* Disable kprobe. This will disarm it if needed. */ |
| 1646 | ap = __disable_kprobe(p); | 1687 | ap = __disable_kprobe(p); |
| 1647 | if (ap == NULL) | 1688 | if (IS_ERR(ap)) |
| 1648 | return -EINVAL; | 1689 | return PTR_ERR(ap); |
| 1649 | 1690 | ||
| 1650 | if (ap == p) | 1691 | if (ap == p) |
| 1651 | /* | 1692 | /* |
| @@ -2078,12 +2119,14 @@ static void kill_kprobe(struct kprobe *p) | |||
| 2078 | int disable_kprobe(struct kprobe *kp) | 2119 | int disable_kprobe(struct kprobe *kp) |
| 2079 | { | 2120 | { |
| 2080 | int ret = 0; | 2121 | int ret = 0; |
| 2122 | struct kprobe *p; | ||
| 2081 | 2123 | ||
| 2082 | mutex_lock(&kprobe_mutex); | 2124 | mutex_lock(&kprobe_mutex); |
| 2083 | 2125 | ||
| 2084 | /* Disable this kprobe */ | 2126 | /* Disable this kprobe */ |
| 2085 | if (__disable_kprobe(kp) == NULL) | 2127 | p = __disable_kprobe(kp); |
| 2086 | ret = -EINVAL; | 2128 | if (IS_ERR(p)) |
| 2129 | ret = PTR_ERR(p); | ||
| 2087 | 2130 | ||
| 2088 | mutex_unlock(&kprobe_mutex); | 2131 | mutex_unlock(&kprobe_mutex); |
| 2089 | return ret; | 2132 | return ret; |
| @@ -2116,7 +2159,9 @@ int enable_kprobe(struct kprobe *kp) | |||
| 2116 | 2159 | ||
| 2117 | if (!kprobes_all_disarmed && kprobe_disabled(p)) { | 2160 | if (!kprobes_all_disarmed && kprobe_disabled(p)) { |
| 2118 | p->flags &= ~KPROBE_FLAG_DISABLED; | 2161 | p->flags &= ~KPROBE_FLAG_DISABLED; |
| 2119 | arm_kprobe(p); | 2162 | ret = arm_kprobe(p); |
| 2163 | if (ret) | ||
| 2164 | p->flags |= KPROBE_FLAG_DISABLED; | ||
| 2120 | } | 2165 | } |
| 2121 | out: | 2166 | out: |
| 2122 | mutex_unlock(&kprobe_mutex); | 2167 | mutex_unlock(&kprobe_mutex); |
| @@ -2407,11 +2452,12 @@ static const struct file_operations debugfs_kprobe_blacklist_ops = { | |||
| 2407 | .release = seq_release, | 2452 | .release = seq_release, |
| 2408 | }; | 2453 | }; |
| 2409 | 2454 | ||
| 2410 | static void arm_all_kprobes(void) | 2455 | static int arm_all_kprobes(void) |
| 2411 | { | 2456 | { |
| 2412 | struct hlist_head *head; | 2457 | struct hlist_head *head; |
| 2413 | struct kprobe *p; | 2458 | struct kprobe *p; |
| 2414 | unsigned int i; | 2459 | unsigned int i, total = 0, errors = 0; |
| 2460 | int err, ret = 0; | ||
| 2415 | 2461 | ||
| 2416 | mutex_lock(&kprobe_mutex); | 2462 | mutex_lock(&kprobe_mutex); |
| 2417 | 2463 | ||
| @@ -2428,46 +2474,74 @@ static void arm_all_kprobes(void) | |||
| 2428 | /* Arming kprobes doesn't optimize kprobe itself */ | 2474 | /* Arming kprobes doesn't optimize kprobe itself */ |
| 2429 | for (i = 0; i < KPROBE_TABLE_SIZE; i++) { | 2475 | for (i = 0; i < KPROBE_TABLE_SIZE; i++) { |
| 2430 | head = &kprobe_table[i]; | 2476 | head = &kprobe_table[i]; |
| 2431 | hlist_for_each_entry_rcu(p, head, hlist) | 2477 | /* Arm all kprobes on a best-effort basis */ |
| 2432 | if (!kprobe_disabled(p)) | 2478 | hlist_for_each_entry_rcu(p, head, hlist) { |
| 2433 | arm_kprobe(p); | 2479 | if (!kprobe_disabled(p)) { |
| 2480 | err = arm_kprobe(p); | ||
| 2481 | if (err) { | ||
| 2482 | errors++; | ||
| 2483 | ret = err; | ||
| 2484 | } | ||
| 2485 | total++; | ||
| 2486 | } | ||
| 2487 | } | ||
| 2434 | } | 2488 | } |
| 2435 | 2489 | ||
| 2436 | printk(KERN_INFO "Kprobes globally enabled\n"); | 2490 | if (errors) |
| 2491 | pr_warn("Kprobes globally enabled, but failed to arm %d out of %d probes\n", | ||
| 2492 | errors, total); | ||
| 2493 | else | ||
| 2494 | pr_info("Kprobes globally enabled\n"); | ||
| 2437 | 2495 | ||
| 2438 | already_enabled: | 2496 | already_enabled: |
| 2439 | mutex_unlock(&kprobe_mutex); | 2497 | mutex_unlock(&kprobe_mutex); |
| 2440 | return; | 2498 | return ret; |
| 2441 | } | 2499 | } |
| 2442 | 2500 | ||
| 2443 | static void disarm_all_kprobes(void) | 2501 | static int disarm_all_kprobes(void) |
| 2444 | { | 2502 | { |
| 2445 | struct hlist_head *head; | 2503 | struct hlist_head *head; |
| 2446 | struct kprobe *p; | 2504 | struct kprobe *p; |
| 2447 | unsigned int i; | 2505 | unsigned int i, total = 0, errors = 0; |
| 2506 | int err, ret = 0; | ||
| 2448 | 2507 | ||
| 2449 | mutex_lock(&kprobe_mutex); | 2508 | mutex_lock(&kprobe_mutex); |
| 2450 | 2509 | ||
| 2451 | /* If kprobes are already disarmed, just return */ | 2510 | /* If kprobes are already disarmed, just return */ |
| 2452 | if (kprobes_all_disarmed) { | 2511 | if (kprobes_all_disarmed) { |
| 2453 | mutex_unlock(&kprobe_mutex); | 2512 | mutex_unlock(&kprobe_mutex); |
| 2454 | return; | 2513 | return 0; |
| 2455 | } | 2514 | } |
| 2456 | 2515 | ||
| 2457 | kprobes_all_disarmed = true; | 2516 | kprobes_all_disarmed = true; |
| 2458 | printk(KERN_INFO "Kprobes globally disabled\n"); | ||
| 2459 | 2517 | ||
| 2460 | for (i = 0; i < KPROBE_TABLE_SIZE; i++) { | 2518 | for (i = 0; i < KPROBE_TABLE_SIZE; i++) { |
| 2461 | head = &kprobe_table[i]; | 2519 | head = &kprobe_table[i]; |
| 2520 | /* Disarm all kprobes on a best-effort basis */ | ||
| 2462 | hlist_for_each_entry_rcu(p, head, hlist) { | 2521 | hlist_for_each_entry_rcu(p, head, hlist) { |
| 2463 | if (!arch_trampoline_kprobe(p) && !kprobe_disabled(p)) | 2522 | if (!arch_trampoline_kprobe(p) && !kprobe_disabled(p)) { |
| 2464 | disarm_kprobe(p, false); | 2523 | err = disarm_kprobe(p, false); |
| 2524 | if (err) { | ||
| 2525 | errors++; | ||
| 2526 | ret = err; | ||
| 2527 | } | ||
| 2528 | total++; | ||
| 2529 | } | ||
| 2465 | } | 2530 | } |
| 2466 | } | 2531 | } |
| 2532 | |||
| 2533 | if (errors) | ||
| 2534 | pr_warn("Kprobes globally disabled, but failed to disarm %d out of %d probes\n", | ||
| 2535 | errors, total); | ||
| 2536 | else | ||
| 2537 | pr_info("Kprobes globally disabled\n"); | ||
| 2538 | |||
| 2467 | mutex_unlock(&kprobe_mutex); | 2539 | mutex_unlock(&kprobe_mutex); |
| 2468 | 2540 | ||
| 2469 | /* Wait for disarming all kprobes by optimizer */ | 2541 | /* Wait for disarming all kprobes by optimizer */ |
| 2470 | wait_for_kprobe_optimizer(); | 2542 | wait_for_kprobe_optimizer(); |
| 2543 | |||
| 2544 | return ret; | ||
| 2471 | } | 2545 | } |
| 2472 | 2546 | ||
| 2473 | /* | 2547 | /* |
| @@ -2494,6 +2568,7 @@ static ssize_t write_enabled_file_bool(struct file *file, | |||
| 2494 | { | 2568 | { |
| 2495 | char buf[32]; | 2569 | char buf[32]; |
| 2496 | size_t buf_size; | 2570 | size_t buf_size; |
| 2571 | int ret = 0; | ||
| 2497 | 2572 | ||
| 2498 | buf_size = min(count, (sizeof(buf)-1)); | 2573 | buf_size = min(count, (sizeof(buf)-1)); |
| 2499 | if (copy_from_user(buf, user_buf, buf_size)) | 2574 | if (copy_from_user(buf, user_buf, buf_size)) |
| @@ -2504,17 +2579,20 @@ static ssize_t write_enabled_file_bool(struct file *file, | |||
| 2504 | case 'y': | 2579 | case 'y': |
| 2505 | case 'Y': | 2580 | case 'Y': |
| 2506 | case '1': | 2581 | case '1': |
| 2507 | arm_all_kprobes(); | 2582 | ret = arm_all_kprobes(); |
| 2508 | break; | 2583 | break; |
| 2509 | case 'n': | 2584 | case 'n': |
| 2510 | case 'N': | 2585 | case 'N': |
| 2511 | case '0': | 2586 | case '0': |
| 2512 | disarm_all_kprobes(); | 2587 | ret = disarm_all_kprobes(); |
| 2513 | break; | 2588 | break; |
| 2514 | default: | 2589 | default: |
| 2515 | return -EINVAL; | 2590 | return -EINVAL; |
| 2516 | } | 2591 | } |
| 2517 | 2592 | ||
| 2593 | if (ret) | ||
| 2594 | return ret; | ||
| 2595 | |||
| 2518 | return count; | 2596 | return count; |
| 2519 | } | 2597 | } |
| 2520 | 2598 | ||
diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c index 38ece035039e..d880296245c5 100644 --- a/kernel/locking/qspinlock.c +++ b/kernel/locking/qspinlock.c | |||
| @@ -379,6 +379,14 @@ queue: | |||
| 379 | tail = encode_tail(smp_processor_id(), idx); | 379 | tail = encode_tail(smp_processor_id(), idx); |
| 380 | 380 | ||
| 381 | node += idx; | 381 | node += idx; |
| 382 | |||
| 383 | /* | ||
| 384 | * Ensure that we increment the head node->count before initialising | ||
| 385 | * the actual node. If the compiler is kind enough to reorder these | ||
| 386 | * stores, then an IRQ could overwrite our assignments. | ||
| 387 | */ | ||
| 388 | barrier(); | ||
| 389 | |||
| 382 | node->locked = 0; | 390 | node->locked = 0; |
| 383 | node->next = NULL; | 391 | node->next = NULL; |
| 384 | pv_init_node(node); | 392 | pv_init_node(node); |
| @@ -408,14 +416,15 @@ queue: | |||
| 408 | */ | 416 | */ |
| 409 | if (old & _Q_TAIL_MASK) { | 417 | if (old & _Q_TAIL_MASK) { |
| 410 | prev = decode_tail(old); | 418 | prev = decode_tail(old); |
| 419 | |||
| 411 | /* | 420 | /* |
| 412 | * The above xchg_tail() is also a load of @lock which | 421 | * We must ensure that the stores to @node are observed before |
| 413 | * generates, through decode_tail(), a pointer. The address | 422 | * the write to prev->next. The address dependency from |
| 414 | * dependency matches the RELEASE of xchg_tail() such that | 423 | * xchg_tail is not sufficient to ensure this because the read |
| 415 | * the subsequent access to @prev happens after. | 424 | * component of xchg_tail is unordered with respect to the |
| 425 | * initialisation of @node. | ||
| 416 | */ | 426 | */ |
| 417 | 427 | smp_store_release(&prev->next, node); | |
| 418 | WRITE_ONCE(prev->next, node); | ||
| 419 | 428 | ||
| 420 | pv_wait_node(node, prev); | 429 | pv_wait_node(node, prev); |
| 421 | arch_mcs_spin_lock_contended(&node->locked); | 430 | arch_mcs_spin_lock_contended(&node->locked); |
diff --git a/kernel/relay.c b/kernel/relay.c index c3029402f15c..c955b10c973c 100644 --- a/kernel/relay.c +++ b/kernel/relay.c | |||
| @@ -163,7 +163,7 @@ static struct rchan_buf *relay_create_buf(struct rchan *chan) | |||
| 163 | { | 163 | { |
| 164 | struct rchan_buf *buf; | 164 | struct rchan_buf *buf; |
| 165 | 165 | ||
| 166 | if (chan->n_subbufs > UINT_MAX / sizeof(size_t *)) | 166 | if (chan->n_subbufs > KMALLOC_MAX_SIZE / sizeof(size_t *)) |
| 167 | return NULL; | 167 | return NULL; |
| 168 | 168 | ||
| 169 | buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL); | 169 | buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL); |
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index bf724c1952ea..e7c535eee0a6 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
| @@ -2601,19 +2601,31 @@ static inline void finish_task(struct task_struct *prev) | |||
| 2601 | #endif | 2601 | #endif |
| 2602 | } | 2602 | } |
| 2603 | 2603 | ||
| 2604 | static inline void finish_lock_switch(struct rq *rq) | 2604 | static inline void |
| 2605 | prepare_lock_switch(struct rq *rq, struct task_struct *next, struct rq_flags *rf) | ||
| 2605 | { | 2606 | { |
| 2607 | /* | ||
| 2608 | * Since the runqueue lock will be released by the next | ||
| 2609 | * task (which is an invalid locking op but in the case | ||
| 2610 | * of the scheduler it's an obvious special-case), so we | ||
| 2611 | * do an early lockdep release here: | ||
| 2612 | */ | ||
| 2613 | rq_unpin_lock(rq, rf); | ||
| 2614 | spin_release(&rq->lock.dep_map, 1, _THIS_IP_); | ||
| 2606 | #ifdef CONFIG_DEBUG_SPINLOCK | 2615 | #ifdef CONFIG_DEBUG_SPINLOCK |
| 2607 | /* this is a valid case when another task releases the spinlock */ | 2616 | /* this is a valid case when another task releases the spinlock */ |
| 2608 | rq->lock.owner = current; | 2617 | rq->lock.owner = next; |
| 2609 | #endif | 2618 | #endif |
| 2619 | } | ||
| 2620 | |||
| 2621 | static inline void finish_lock_switch(struct rq *rq) | ||
| 2622 | { | ||
| 2610 | /* | 2623 | /* |
| 2611 | * If we are tracking spinlock dependencies then we have to | 2624 | * If we are tracking spinlock dependencies then we have to |
| 2612 | * fix up the runqueue lock - which gets 'carried over' from | 2625 | * fix up the runqueue lock - which gets 'carried over' from |
| 2613 | * prev into current: | 2626 | * prev into current: |
| 2614 | */ | 2627 | */ |
| 2615 | spin_acquire(&rq->lock.dep_map, 0, 0, _THIS_IP_); | 2628 | spin_acquire(&rq->lock.dep_map, 0, 0, _THIS_IP_); |
| 2616 | |||
| 2617 | raw_spin_unlock_irq(&rq->lock); | 2629 | raw_spin_unlock_irq(&rq->lock); |
| 2618 | } | 2630 | } |
| 2619 | 2631 | ||
| @@ -2844,14 +2856,7 @@ context_switch(struct rq *rq, struct task_struct *prev, | |||
| 2844 | 2856 | ||
| 2845 | rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP); | 2857 | rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP); |
| 2846 | 2858 | ||
| 2847 | /* | 2859 | prepare_lock_switch(rq, next, rf); |
| 2848 | * Since the runqueue lock will be released by the next | ||
| 2849 | * task (which is an invalid locking op but in the case | ||
| 2850 | * of the scheduler it's an obvious special-case), so we | ||
| 2851 | * do an early lockdep release here: | ||
| 2852 | */ | ||
| 2853 | rq_unpin_lock(rq, rf); | ||
| 2854 | spin_release(&rq->lock.dep_map, 1, _THIS_IP_); | ||
| 2855 | 2860 | ||
| 2856 | /* Here we just switch the register state and the stack. */ | 2861 | /* Here we just switch the register state and the stack. */ |
| 2857 | switch_to(prev, next, prev); | 2862 | switch_to(prev, next, prev); |
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index dd062a1c8cf0..7936f548e071 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c | |||
| @@ -19,8 +19,6 @@ | |||
| 19 | 19 | ||
| 20 | #include "sched.h" | 20 | #include "sched.h" |
| 21 | 21 | ||
| 22 | #define SUGOV_KTHREAD_PRIORITY 50 | ||
| 23 | |||
| 24 | struct sugov_tunables { | 22 | struct sugov_tunables { |
| 25 | struct gov_attr_set attr_set; | 23 | struct gov_attr_set attr_set; |
| 26 | unsigned int rate_limit_us; | 24 | unsigned int rate_limit_us; |
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 9bb0e0c412ec..9df09782025c 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c | |||
| @@ -1153,6 +1153,7 @@ static void update_curr_dl(struct rq *rq) | |||
| 1153 | struct sched_dl_entity *dl_se = &curr->dl; | 1153 | struct sched_dl_entity *dl_se = &curr->dl; |
| 1154 | u64 delta_exec, scaled_delta_exec; | 1154 | u64 delta_exec, scaled_delta_exec; |
| 1155 | int cpu = cpu_of(rq); | 1155 | int cpu = cpu_of(rq); |
| 1156 | u64 now; | ||
| 1156 | 1157 | ||
| 1157 | if (!dl_task(curr) || !on_dl_rq(dl_se)) | 1158 | if (!dl_task(curr) || !on_dl_rq(dl_se)) |
| 1158 | return; | 1159 | return; |
| @@ -1165,7 +1166,8 @@ static void update_curr_dl(struct rq *rq) | |||
| 1165 | * natural solution, but the full ramifications of this | 1166 | * natural solution, but the full ramifications of this |
| 1166 | * approach need further study. | 1167 | * approach need further study. |
| 1167 | */ | 1168 | */ |
| 1168 | delta_exec = rq_clock_task(rq) - curr->se.exec_start; | 1169 | now = rq_clock_task(rq); |
| 1170 | delta_exec = now - curr->se.exec_start; | ||
| 1169 | if (unlikely((s64)delta_exec <= 0)) { | 1171 | if (unlikely((s64)delta_exec <= 0)) { |
| 1170 | if (unlikely(dl_se->dl_yielded)) | 1172 | if (unlikely(dl_se->dl_yielded)) |
| 1171 | goto throttle; | 1173 | goto throttle; |
| @@ -1178,7 +1180,7 @@ static void update_curr_dl(struct rq *rq) | |||
| 1178 | curr->se.sum_exec_runtime += delta_exec; | 1180 | curr->se.sum_exec_runtime += delta_exec; |
| 1179 | account_group_exec_runtime(curr, delta_exec); | 1181 | account_group_exec_runtime(curr, delta_exec); |
| 1180 | 1182 | ||
| 1181 | curr->se.exec_start = rq_clock_task(rq); | 1183 | curr->se.exec_start = now; |
| 1182 | cgroup_account_cputime(curr, delta_exec); | 1184 | cgroup_account_cputime(curr, delta_exec); |
| 1183 | 1185 | ||
| 1184 | sched_rt_avg_update(rq, delta_exec); | 1186 | sched_rt_avg_update(rq, delta_exec); |
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 663b2355a3aa..aad49451584e 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c | |||
| @@ -950,12 +950,13 @@ static void update_curr_rt(struct rq *rq) | |||
| 950 | { | 950 | { |
| 951 | struct task_struct *curr = rq->curr; | 951 | struct task_struct *curr = rq->curr; |
| 952 | struct sched_rt_entity *rt_se = &curr->rt; | 952 | struct sched_rt_entity *rt_se = &curr->rt; |
| 953 | u64 now = rq_clock_task(rq); | ||
| 954 | u64 delta_exec; | 953 | u64 delta_exec; |
| 954 | u64 now; | ||
| 955 | 955 | ||
| 956 | if (curr->sched_class != &rt_sched_class) | 956 | if (curr->sched_class != &rt_sched_class) |
| 957 | return; | 957 | return; |
| 958 | 958 | ||
| 959 | now = rq_clock_task(rq); | ||
| 959 | delta_exec = now - curr->se.exec_start; | 960 | delta_exec = now - curr->se.exec_start; |
| 960 | if (unlikely((s64)delta_exec <= 0)) | 961 | if (unlikely((s64)delta_exec <= 0)) |
| 961 | return; | 962 | return; |
diff --git a/kernel/seccomp.c b/kernel/seccomp.c index 940fa408a288..dc77548167ef 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c | |||
| @@ -1076,14 +1076,16 @@ long seccomp_get_metadata(struct task_struct *task, | |||
| 1076 | 1076 | ||
| 1077 | size = min_t(unsigned long, size, sizeof(kmd)); | 1077 | size = min_t(unsigned long, size, sizeof(kmd)); |
| 1078 | 1078 | ||
| 1079 | if (copy_from_user(&kmd, data, size)) | 1079 | if (size < sizeof(kmd.filter_off)) |
| 1080 | return -EINVAL; | ||
| 1081 | |||
| 1082 | if (copy_from_user(&kmd.filter_off, data, sizeof(kmd.filter_off))) | ||
| 1080 | return -EFAULT; | 1083 | return -EFAULT; |
| 1081 | 1084 | ||
| 1082 | filter = get_nth_filter(task, kmd.filter_off); | 1085 | filter = get_nth_filter(task, kmd.filter_off); |
| 1083 | if (IS_ERR(filter)) | 1086 | if (IS_ERR(filter)) |
| 1084 | return PTR_ERR(filter); | 1087 | return PTR_ERR(filter); |
| 1085 | 1088 | ||
| 1086 | memset(&kmd, 0, sizeof(kmd)); | ||
| 1087 | if (filter->log) | 1089 | if (filter->log) |
| 1088 | kmd.flags |= SECCOMP_FILTER_FLAG_LOG; | 1090 | kmd.flags |= SECCOMP_FILTER_FLAG_LOG; |
| 1089 | 1091 | ||
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index fc2838ac8b78..c0a9e310d715 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c | |||
| @@ -872,6 +872,8 @@ int perf_event_query_prog_array(struct perf_event *event, void __user *info) | |||
| 872 | return -EINVAL; | 872 | return -EINVAL; |
| 873 | if (copy_from_user(&query, uquery, sizeof(query))) | 873 | if (copy_from_user(&query, uquery, sizeof(query))) |
| 874 | return -EFAULT; | 874 | return -EFAULT; |
| 875 | if (query.ids_len > BPF_TRACE_MAX_PROGS) | ||
| 876 | return -E2BIG; | ||
| 875 | 877 | ||
| 876 | mutex_lock(&bpf_event_mutex); | 878 | mutex_lock(&bpf_event_mutex); |
| 877 | ret = bpf_prog_array_copy_info(event->tp_event->prog_array, | 879 | ret = bpf_prog_array_copy_info(event->tp_event->prog_array, |
diff --git a/kernel/user.c b/kernel/user.c index 9a20acce460d..36288d840675 100644 --- a/kernel/user.c +++ b/kernel/user.c | |||
| @@ -101,6 +101,7 @@ struct user_struct root_user = { | |||
| 101 | .sigpending = ATOMIC_INIT(0), | 101 | .sigpending = ATOMIC_INIT(0), |
| 102 | .locked_shm = 0, | 102 | .locked_shm = 0, |
| 103 | .uid = GLOBAL_ROOT_UID, | 103 | .uid = GLOBAL_ROOT_UID, |
| 104 | .ratelimit = RATELIMIT_STATE_INIT(root_user.ratelimit, 0, 0), | ||
| 104 | }; | 105 | }; |
| 105 | 106 | ||
| 106 | /* | 107 | /* |
| @@ -191,6 +192,8 @@ struct user_struct *alloc_uid(kuid_t uid) | |||
| 191 | 192 | ||
| 192 | new->uid = uid; | 193 | new->uid = uid; |
| 193 | atomic_set(&new->__count, 1); | 194 | atomic_set(&new->__count, 1); |
| 195 | ratelimit_state_init(&new->ratelimit, HZ, 100); | ||
| 196 | ratelimit_set_flags(&new->ratelimit, RATELIMIT_MSG_ON_RELEASE); | ||
| 194 | 197 | ||
| 195 | /* | 198 | /* |
| 196 | * Before adding this, check whether we raced | 199 | * Before adding this, check whether we raced |
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 017044c26233..bb9a519cbf50 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
| @@ -4180,6 +4180,22 @@ void workqueue_set_max_active(struct workqueue_struct *wq, int max_active) | |||
| 4180 | EXPORT_SYMBOL_GPL(workqueue_set_max_active); | 4180 | EXPORT_SYMBOL_GPL(workqueue_set_max_active); |
| 4181 | 4181 | ||
| 4182 | /** | 4182 | /** |
| 4183 | * current_work - retrieve %current task's work struct | ||
| 4184 | * | ||
| 4185 | * Determine if %current task is a workqueue worker and what it's working on. | ||
| 4186 | * Useful to find out the context that the %current task is running in. | ||
| 4187 | * | ||
| 4188 | * Return: work struct if %current task is a workqueue worker, %NULL otherwise. | ||
| 4189 | */ | ||
| 4190 | struct work_struct *current_work(void) | ||
| 4191 | { | ||
| 4192 | struct worker *worker = current_wq_worker(); | ||
| 4193 | |||
| 4194 | return worker ? worker->current_work : NULL; | ||
| 4195 | } | ||
| 4196 | EXPORT_SYMBOL(current_work); | ||
| 4197 | |||
| 4198 | /** | ||
| 4183 | * current_is_workqueue_rescuer - is %current workqueue rescuer? | 4199 | * current_is_workqueue_rescuer - is %current workqueue rescuer? |
| 4184 | * | 4200 | * |
| 4185 | * Determine whether %current is a workqueue rescuer. Can be used from | 4201 | * Determine whether %current is a workqueue rescuer. Can be used from |
