History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

No conflicts.

Jakub Kicinski committed 4 years ago

Commit c59400a2 parents 9c30918 dcb85f8405 files · +4030 −2043Browse files

Showing the changes to kernel (20 of 405 files). Show all

Unified · Split

20 files
  1. kernel/async.c +0 −3
  2. kernel/audit.c +43 −19
  3. kernel/bpf/bpf_lsm.c +1 −1
  4. kernel/bpf/ringbuf.c +1 −1
  5. kernel/bpf/trampoline.c +3 −2
  6. kernel/cgroup/cgroup-v1.c +14 −0
  7. kernel/cgroup/cpuset.c +51 −14
  8. kernel/events/core.c +19 −4
  9. kernel/module.c +5 −20
  10. kernel/power/snapshot.c +7 −14
  11. kernel/power/wakelock.c +4 −7
  12. kernel/printk/sysctl.c +1 −1
  13. kernel/rcu/tasks.h +8 −4
  14. kernel/sched/membarrier.c +5 −4
  15. kernel/sched/psi.c +41 −38
  16. kernel/stackleak.c +2 −3
  17. kernel/trace/Kconfig +7 −1
  18. kernel/trace/trace.c +2 −1
  19. kernel/trace/trace_events_hist.c +8 −2
  20. kernel/ucount.c +2 −0
kernel/async.c+0−3
@@ -205,9 +205,6 @@ async_cookie_t async_schedule_node_domain(async_func_t func, void *data, · 204 unmodified lines
205205 atomic_inc(&entry_count);
206206 spin_unlock_irqrestore(&async_lock, flags);
207207
208− /* mark that this task has queued an async job, used by module init */
209− current->flags |= PF_USED_ASYNC;
210−
211208 /* schedule for execution */
212209 queue_work_node(node, system_unbound_wq, &entry->work);
213210
kernel/audit.c+43−19
@@ -541,20 +541,22 @@ static void kauditd_printk_skb(struct sk_buff *skb) · 540 unmodified lines
541541 /**
542542 * kauditd_rehold_skb - Handle a audit record send failure in the hold queue
543543 * @skb: audit record
544+ * @error: error code (unused)
544545 *
545546 * Description:
546547 * This should only be used by the kauditd_thread when it fails to flush the
547548 * hold queue.
548549 */
549−static void kauditd_rehold_skb(struct sk_buff *skb)
550+static void kauditd_rehold_skb(struct sk_buff *skb, __always_unused int error)
550551 {
551− /* put the record back in the queue at the same place */
552− skb_queue_head(&audit_hold_queue, skb);
552+ /* put the record back in the queue */
553+ skb_queue_tail(&audit_hold_queue, skb);
553554 }
554555
555556 /**
556557 * kauditd_hold_skb - Queue an audit record, waiting for auditd
557558 * @skb: audit record
559+ * @error: error code
558560 *
559561 * Description:
560562 * Queue the audit record, waiting for an instance of auditd. When this
@@ -564,19 +566,31 @@ static void kauditd_rehold_skb(struct sk_buff *skb) · 3 unmodified lines
564566 * and queue it, if we have room. If we want to hold on to the record, but we
565567 * don't have room, record a record lost message.
566568 */
567−static void kauditd_hold_skb(struct sk_buff *skb)
569+static void kauditd_hold_skb(struct sk_buff *skb, int error)
568570 {
569571 /* at this point it is uncertain if we will ever send this to auditd so
570572 * try to send the message via printk before we go any further */
571573 kauditd_printk_skb(skb);
572574
573575 /* can we just silently drop the message? */
574− if (!audit_default) {
575− kfree_skb(skb);
576− return;
576+ if (!audit_default)
577+ goto drop;
578+
579+ /* the hold queue is only for when the daemon goes away completely,
580+ * not -EAGAIN failures; if we are in a -EAGAIN state requeue the
581+ * record on the retry queue unless it's full, in which case drop it
582+ */
583+ if (error == -EAGAIN) {
584+ if (!audit_backlog_limit ||
585+ skb_queue_len(&audit_retry_queue) < audit_backlog_limit) {
586+ skb_queue_tail(&audit_retry_queue, skb);
587+ return;
588+ }
589+ audit_log_lost("kauditd retry queue overflow");
590+ goto drop;
577591 }
578592
579− /* if we have room, queue the message */
593+ /* if we have room in the hold queue, queue the message */
580594 if (!audit_backlog_limit ||
581595 skb_queue_len(&audit_hold_queue) < audit_backlog_limit) {
582596 skb_queue_tail(&audit_hold_queue, skb);
@@ -585,24 +599,32 @@ static void kauditd_hold_skb(struct sk_buff *skb) · 2 unmodified lines
585599
586600 /* we have no other options - drop the message */
587601 audit_log_lost("kauditd hold queue overflow");
602+drop:
588603 kfree_skb(skb);
589604 }
590605
591606 /**
592607 * kauditd_retry_skb - Queue an audit record, attempt to send again to auditd
593608 * @skb: audit record
609+ * @error: error code (unused)
594610 *
595611 * Description:
596612 * Not as serious as kauditd_hold_skb() as we still have a connected auditd,
597613 * but for some reason we are having problems sending it audit records so
598614 * queue the given record and attempt to resend.
599615 */
600−static void kauditd_retry_skb(struct sk_buff *skb)
616+static void kauditd_retry_skb(struct sk_buff *skb, __always_unused int error)
601617 {
602− /* NOTE: because records should only live in the retry queue for a
603− * short period of time, before either being sent or moved to the hold
604− * queue, we don't currently enforce a limit on this queue */
605− skb_queue_tail(&audit_retry_queue, skb);
618+ if (!audit_backlog_limit ||
619+ skb_queue_len(&audit_retry_queue) < audit_backlog_limit) {
620+ skb_queue_tail(&audit_retry_queue, skb);
621+ return;
622+ }
623+
624+ /* we have to drop the record, send it via printk as a last effort */
625+ kauditd_printk_skb(skb);
626+ audit_log_lost("kauditd retry queue overflow");
627+ kfree_skb(skb);
606628 }
607629
608630 /**
@@ -640,7 +662,7 @@ static void auditd_reset(const struct auditd_connection *ac) · 31 unmodified lines
640662 /* flush the retry queue to the hold queue, but don't touch the main
641663 * queue since we need to process that normally for multicast */
642664 while ((skb = skb_dequeue(&audit_retry_queue)))
643− kauditd_hold_skb(skb);
665+ kauditd_hold_skb(skb, -ECONNREFUSED);
644666 }
645667
646668 /**
@@ -714,16 +736,18 @@ static int kauditd_send_queue(struct sock *sk, u32 portid, · 67 unmodified lines
714736 struct sk_buff_head *queue,
715737 unsigned int retry_limit,
716738 void (*skb_hook)(struct sk_buff *skb),
717− void (*err_hook)(struct sk_buff *skb))
739+ void (*err_hook)(struct sk_buff *skb, int error))
718740 {
719741 int rc = 0;
720− struct sk_buff *skb;
742+ struct sk_buff *skb = NULL;
743+ struct sk_buff *skb_tail;
721744 unsigned int failed = 0;
722745
723746 /* NOTE: kauditd_thread takes care of all our locking, we just use
724747 * the netlink info passed to us (e.g. sk and portid) */
725748
726− while ((skb = skb_dequeue(queue))) {
749+ skb_tail = skb_peek_tail(queue);
750+ while ((skb != skb_tail) && (skb = skb_dequeue(queue))) {
727751 /* call the skb_hook for each skb we touch */
728752 if (skb_hook)
729753 (*skb_hook)(skb);
@@ -731,7 +755,7 @@ static int kauditd_send_queue(struct sock *sk, u32 portid, · 1 unmodified line
731755 /* can we send to anyone via unicast? */
732756 if (!sk) {
733757 if (err_hook)
734− (*err_hook)(skb);
758+ (*err_hook)(skb, -ECONNREFUSED);
735759 continue;
736760 }
737761
@@ -745,7 +769,7 @@ retry: · 7 unmodified lines
745769 rc == -ECONNREFUSED || rc == -EPERM) {
746770 sk = NULL;
747771 if (err_hook)
748− (*err_hook)(skb);
772+ (*err_hook)(skb, rc);
749773 if (rc == -EAGAIN)
750774 rc = 0;
751775 /* continue to drain the queue */
kernel/bpf/bpf_lsm.c+1−1
@@ -207,7 +207,7 @@ BTF_ID(func, bpf_lsm_socket_socketpair) · 206 unmodified lines
207207
208208 BTF_ID(func, bpf_lsm_syslog)
209209 BTF_ID(func, bpf_lsm_task_alloc)
210−BTF_ID(func, bpf_lsm_task_getsecid_subj)
210+BTF_ID(func, bpf_lsm_current_getsecid_subj)
211211 BTF_ID(func, bpf_lsm_task_getsecid_obj)
212212 BTF_ID(func, bpf_lsm_task_prctl)
213213 BTF_ID(func, bpf_lsm_task_setscheduler)
kernel/bpf/ringbuf.c+1−1
@@ -104,7 +104,7 @@ static struct bpf_ringbuf *bpf_ringbuf_area_alloc(size_t data_sz, int numa_node) · 103 unmodified lines
104104 }
105105
106106 rb = vmap(pages, nr_meta_pages + 2 * nr_data_pages,
107− VM_ALLOC | VM_USERMAP, PAGE_KERNEL);
107+ VM_MAP | VM_USERMAP, PAGE_KERNEL);
108108 if (rb) {
109109 kmemleak_not_leak(pages);
110110 rb->pages = pages;
kernel/bpf/trampoline.c+3−2
@@ -550,11 +550,12 @@ static __always_inline u64 notrace bpf_prog_start_time(void) · 549 unmodified lines
550550 static void notrace inc_misses_counter(struct bpf_prog *prog)
551551 {
552552 struct bpf_prog_stats *stats;
553+ unsigned int flags;
553554
554555 stats = this_cpu_ptr(prog->stats);
555− u64_stats_update_begin(&stats->syncp);
556+ flags = u64_stats_update_begin_irqsave(&stats->syncp);
556557 u64_stats_inc(&stats->misses);
557− u64_stats_update_end(&stats->syncp);
558+ u64_stats_update_end_irqrestore(&stats->syncp, flags);
558559 }
559560
560561 /* The logic is similar to bpf_prog_run(), but with an explicit
kernel/cgroup/cgroup-v1.c+14−0
@@ -549,6 +549,14 @@ static ssize_t cgroup_release_agent_write(struct kernfs_open_file *of, · 548 unmodified lines
549549
550550 BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX);
551551
552+ /*
553+ * Release agent gets called with all capabilities,
554+ * require capabilities to set release agent.
555+ */
556+ if ((of->file->f_cred->user_ns != &init_user_ns) ||
557+ !capable(CAP_SYS_ADMIN))
558+ return -EPERM;
559+
552560 cgrp = cgroup_kn_lock_live(of->kn, false);
553561 if (!cgrp)
554562 return -ENODEV;
@@ -954,6 +962,12 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param) · 399 unmodified lines
954962 /* Specifying two release agents is forbidden */
955963 if (ctx->release_agent)
956964 return invalfc(fc, "release_agent respecified");
965+ /*
966+ * Release agent gets called with all capabilities,
967+ * require capabilities to set release agent.
968+ */
969+ if ((fc->user_ns != &init_user_ns) || !capable(CAP_SYS_ADMIN))
970+ return invalfc(fc, "Setting release_agent not allowed");
957971 ctx->release_agent = param->string;
958972 param->string = NULL;
959973 break;
kernel/cgroup/cpuset.c+51−14
@@ -590,6 +590,35 @@ static inline void free_cpuset(struct cpuset *cs) · 589 unmodified lines
590590 kfree(cs);
591591 }
592592
593+/*
594+ * validate_change_legacy() - Validate conditions specific to legacy (v1)
595+ * behavior.
596+ */
597+static int validate_change_legacy(struct cpuset *cur, struct cpuset *trial)
598+{
599+ struct cgroup_subsys_state *css;
600+ struct cpuset *c, *par;
601+ int ret;
602+
603+ WARN_ON_ONCE(!rcu_read_lock_held());
604+
605+ /* Each of our child cpusets must be a subset of us */
606+ ret = -EBUSY;
607+ cpuset_for_each_child(c, css, cur)
608+ if (!is_cpuset_subset(c, trial))
609+ goto out;
610+
611+ /* On legacy hierarchy, we must be a subset of our parent cpuset. */
612+ ret = -EACCES;
613+ par = parent_cs(cur);
614+ if (par && !is_cpuset_subset(trial, par))
615+ goto out;
616+
617+ ret = 0;
618+out:
619+ return ret;
620+}
621+
593622 /*
594623 * validate_change() - Used to validate that any proposed cpuset change
595624 * follows the structural rules for cpusets.
@@ -614,20 +643,21 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial) · 18 unmodified lines
614643 {
615644 struct cgroup_subsys_state *css;
616645 struct cpuset *c, *par;
617− int ret;
618−
619− /* The checks don't apply to root cpuset */
620− if (cur == &top_cpuset)
621− return 0;
646+ int ret = 0;
622647
623648 rcu_read_lock();
624− par = parent_cs(cur);
625649
626− /* On legacy hierarchy, we must be a subset of our parent cpuset. */
627− ret = -EACCES;
628− if (!is_in_v2_mode() && !is_cpuset_subset(trial, par))
650+ if (!is_in_v2_mode())
651+ ret = validate_change_legacy(cur, trial);
652+ if (ret)
653+ goto out;
654+
655+ /* Remaining checks don't apply to root cpuset */
656+ if (cur == &top_cpuset)
629657 goto out;
630658
659+ par = parent_cs(cur);
660+
631661 /*
632662 * If either I or some sibling (!= me) is exclusive, we can't
633663 * overlap
@@ -1175,9 +1205,7 @@ enum subparts_cmd { · 541 unmodified lines
11751205 *
11761206 * Because of the implicit cpu exclusive nature of a partition root,
11771207 * cpumask changes that violates the cpu exclusivity rule will not be
1178− * permitted when checked by validate_change(). The validate_change()
1179− * function will also prevent any changes to the cpu list if it is not
1180− * a superset of children's cpu lists.
1208+ * permitted when checked by validate_change().
11811209 */
11821210 static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd,
11831211 struct cpumask *newmask,
@@ -1522,10 +1550,15 @@ static void update_sibling_cpumasks(struct cpuset *parent, struct cpuset *cs, · 338 unmodified lines
15221550 struct cpuset *sibling;
15231551 struct cgroup_subsys_state *pos_css;
15241552
1553+ percpu_rwsem_assert_held(&cpuset_rwsem);
1554+
15251555 /*
15261556 * Check all its siblings and call update_cpumasks_hier()
15271557 * if their use_parent_ecpus flag is set in order for them
15281558 * to use the right effective_cpus value.
1559+ *
1560+ * The update_cpumasks_hier() function may sleep. So we have to
1561+ * release the RCU read lock before calling it.
15291562 */
15301563 rcu_read_lock();
15311564 cpuset_for_each_child(sibling, pos_css, parent) {
@@ -1533,8 +1566,13 @@ static void update_sibling_cpumasks(struct cpuset *parent, struct cpuset *cs, · 1 unmodified line
15331566 continue;
15341567 if (!sibling->use_parent_ecpus)
15351568 continue;
1569+ if (!css_tryget_online(&sibling->css))
1570+ continue;
15361571
1572+ rcu_read_unlock();
15371573 update_cpumasks_hier(sibling, tmp);
1574+ rcu_read_lock();
1575+ css_put(&sibling->css);
15381576 }
15391577 rcu_read_unlock();
15401578 }
@@ -1607,8 +1645,7 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs, · 66 unmodified lines
16071645 * Make sure that subparts_cpus is a subset of cpus_allowed.
16081646 */
16091647 if (cs->nr_subparts_cpus) {
1610− cpumask_andnot(cs->subparts_cpus, cs->subparts_cpus,
1611− cs->cpus_allowed);
1648+ cpumask_and(cs->subparts_cpus, cs->subparts_cpus, cs->cpus_allowed);
16121649 cs->nr_subparts_cpus = cpumask_weight(cs->subparts_cpus);
16131650 }
16141651 spin_unlock_irq(&callback_lock);
kernel/events/core.c+19−4
@@ -2462,7 +2462,11 @@ static void perf_remove_from_context(struct perf_event *event, unsigned long fla · 2461 unmodified lines
24622462 * event_function_call() user.
24632463 */
24642464 raw_spin_lock_irq(&ctx->lock);
2465− if (!ctx->is_active) {
2465+ /*
2466+ * Cgroup events are per-cpu events, and must IPI because of
2467+ * cgrp_cpuctx_list.
2468+ */
2469+ if (!ctx->is_active && !is_cgroup_event(event)) {
24662470 __perf_remove_from_context(event, __get_cpu_context(ctx),
24672471 ctx, (void *)flags);
24682472 raw_spin_unlock_irq(&ctx->lock);
@@ -2895,11 +2899,14 @@ perf_install_in_context(struct perf_event_context *ctx, · 426 unmodified lines
28952899 * perf_event_attr::disabled events will not run and can be initialized
28962900 * without IPI. Except when this is the first event for the context, in
28972901 * that case we need the magic of the IPI to set ctx->is_active.
2902+ * Similarly, cgroup events for the context also needs the IPI to
2903+ * manipulate the cgrp_cpuctx_list.
28982904 *
28992905 * The IOC_ENABLE that is sure to follow the creation of a disabled
29002906 * event will issue the IPI and reprogram the hardware.
29012907 */
2902− if (__perf_effective_state(event) == PERF_EVENT_STATE_OFF && ctx->nr_events) {
2908+ if (__perf_effective_state(event) == PERF_EVENT_STATE_OFF &&
2909+ ctx->nr_events && !is_cgroup_event(event)) {
29032910 raw_spin_lock_irq(&ctx->lock);
29042911 if (ctx->task == TASK_TOMBSTONE) {
29052912 raw_spin_unlock_irq(&ctx->lock);
@@ -5985,6 +5992,8 @@ static void ring_buffer_attach(struct perf_event *event, · 3079 unmodified lines
59855992 struct perf_buffer *old_rb = NULL;
59865993 unsigned long flags;
59875994
5995+ WARN_ON_ONCE(event->parent);
5996+
59885997 if (event->rb) {
59895998 /*
59905999 * Should be impossible, we set this when removing
@@ -6042,6 +6051,9 @@ static void ring_buffer_wakeup(struct perf_event *event) · 51 unmodified lines
60426051 {
60436052 struct perf_buffer *rb;
60446053
6054+ if (event->parent)
6055+ event = event->parent;
6056+
60456057 rcu_read_lock();
60466058 rb = rcu_dereference(event->rb);
60476059 if (rb) {
@@ -6055,6 +6067,9 @@ struct perf_buffer *ring_buffer_get(struct perf_event *event) · 7 unmodified lines
60556067 {
60566068 struct perf_buffer *rb;
60576069
6070+ if (event->parent)
6071+ event = event->parent;
6072+
60586073 rcu_read_lock();
60596074 rb = rcu_dereference(event->rb);
60606075 if (rb) {
@@ -6763,7 +6778,7 @@ static unsigned long perf_prepare_sample_aux(struct perf_event *event, · 702 unmodified lines
67636778 if (WARN_ON_ONCE(READ_ONCE(sampler->oncpu) != smp_processor_id()))
67646779 goto out;
67656780
6766− rb = ring_buffer_get(sampler->parent ? sampler->parent : sampler);
6781+ rb = ring_buffer_get(sampler);
67676782 if (!rb)
67686783 goto out;
67696784
@@ -6829,7 +6844,7 @@ static void perf_aux_sample_output(struct perf_event *event, · 59 unmodified lines
68296844 if (WARN_ON_ONCE(!sampler || !data->aux_size))
68306845 return;
68316846
6832− rb = ring_buffer_get(sampler->parent ? sampler->parent : sampler);
6847+ rb = ring_buffer_get(sampler);
68336848 if (!rb)
68346849 return;
68356850
kernel/module.c+5−20
@@ -3725,12 +3725,6 @@ static noinline int do_init_module(struct module *mod) · 3724 unmodified lines
37253725 }
37263726 freeinit->module_init = mod->init_layout.base;
37273727
3728− /*
3729− * We want to find out whether @mod uses async during init. Clear
3730− * PF_USED_ASYNC. async_schedule*() will set it.
3731− */
3732− current->flags &= ~PF_USED_ASYNC;
3733−
37343728 do_mod_ctors(mod);
37353729 /* Start the module */
37363730 if (mod->init != NULL)
@@ -3756,22 +3750,13 @@ static noinline int do_init_module(struct module *mod) · 19 unmodified lines
37563750
37573751 /*
37583752 * We need to finish all async code before the module init sequence
3759− * is done. This has potential to deadlock. For example, a newly
3760− * detected block device can trigger request_module() of the
3761− * default iosched from async probing task. Once userland helper
3762− * reaches here, async_synchronize_full() will wait on the async
3763− * task waiting on request_module() and deadlock.
3764− *
3765− * This deadlock is avoided by perfomring async_synchronize_full()
3766− * iff module init queued any async jobs. This isn't a full
3767− * solution as it will deadlock the same if module loading from
3768− * async jobs nests more than once; however, due to the various
3769− * constraints, this hack seems to be the best option for now.
3770− * Please refer to the following thread for details.
3753+ * is done. This has potential to deadlock if synchronous module
3754+ * loading is requested from async (which is not allowed!).
37713755 *
3772− * http://thread.gmane.org/gmane.linux.kernel/1420814
3756+ * See commit 0fdff3ec6d87 ("async, kmod: warn on synchronous
3757+ * request_module() from async workers") for more details.
37733758 */
3774− if (!mod->async_probe_requested && (current->flags & PF_USED_ASYNC))
3759+ if (!mod->async_probe_requested)
37753760 async_synchronize_full();
37763761
37773762 ftrace_free_mem(mod, mod->init_layout.base, mod->init_layout.base +
kernel/power/snapshot.c+7−14
@@ -978,8 +978,7 @@ static void memory_bm_recycle(struct memory_bitmap *bm) · 977 unmodified lines
978978 * Register a range of page frames the contents of which should not be saved
979979 * during hibernation (to be used in the early initialization code).
980980 */
981−void __init __register_nosave_region(unsigned long start_pfn,
982− unsigned long end_pfn, int use_kmalloc)
981+void __init register_nosave_region(unsigned long start_pfn, unsigned long end_pfn)
983982 {
984983 struct nosave_region *region;
985984
@@ -995,18 +994,12 @@ void __init __register_nosave_region(unsigned long start_pfn, · 9 unmodified lines
995994 goto Report;
996995 }
997996 }
998− if (use_kmalloc) {
999− /* During init, this shouldn't fail */
1000− region = kmalloc(sizeof(struct nosave_region), GFP_KERNEL);
1001− BUG_ON(!region);
1002− } else {
1003− /* This allocation cannot fail */
1004− region = memblock_alloc(sizeof(struct nosave_region),
1005− SMP_CACHE_BYTES);
1006− if (!region)
1007− panic("%s: Failed to allocate %zu bytes\n", __func__,
1008− sizeof(struct nosave_region));
1009− }
997+ /* This allocation cannot fail */
998+ region = memblock_alloc(sizeof(struct nosave_region),
999+ SMP_CACHE_BYTES);
1000+ if (!region)
1001+ panic("%s: Failed to allocate %zu bytes\n", __func__,
1002+ sizeof(struct nosave_region));
10101003 region->start_pfn = start_pfn;
10111004 region->end_pfn = end_pfn;
10121005 list_add_tail(&region->list, &nosave_regions);
kernel/power/wakelock.c+4−7
@@ -39,23 +39,20 @@ ssize_t pm_show_wakelocks(char *buf, bool show_active) · 38 unmodified lines
3939 {
4040 struct rb_node *node;
4141 struct wakelock *wl;
42− char *str = buf;
43− char *end = buf + PAGE_SIZE;
42+ int len = 0;
4443
4544 mutex_lock(&wakelocks_lock);
4645
4746 for (node = rb_first(&wakelocks_tree); node; node = rb_next(node)) {
4847 wl = rb_entry(node, struct wakelock, node);
4948 if (wl->ws->active == show_active)
50− str += scnprintf(str, end - str, "%s ", wl->name);
49+ len += sysfs_emit_at(buf, len, "%s ", wl->name);
5150 }
52− if (str > buf)
53− str--;
5451
55− str += scnprintf(str, end - str, "\n");
52+ len += sysfs_emit_at(buf, len, "\n");
5653
5754 mutex_unlock(&wakelocks_lock);
58− return (str - buf);
55+ return len;
5956 }
6057
6158 #if CONFIG_PM_WAKELOCKS_LIMIT > 0
kernel/printk/sysctl.c+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
1212 static const int ten_thousand = 10000;
1313
1414 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
15− void __user *buffer, size_t *lenp, loff_t *ppos)
15+ void *buffer, size_t *lenp, loff_t *ppos)
1616 {
1717 if (write && !capable(CAP_SYS_ADMIN))
1818 return -EPERM;
kernel/rcu/tasks.h+8−4
@@ -123,7 +123,7 @@ static struct rcu_tasks rt_name = \ · 122 unmodified lines
123123 .call_func = call, \
124124 .rtpcpu = &rt_name ## __percpu, \
125125 .name = n, \
126− .percpu_enqueue_shift = ilog2(CONFIG_NR_CPUS), \
126+ .percpu_enqueue_shift = ilog2(CONFIG_NR_CPUS) + 1, \
127127 .percpu_enqueue_lim = 1, \
128128 .percpu_dequeue_lim = 1, \
129129 .barrier_q_mutex = __MUTEX_INITIALIZER(rt_name.barrier_q_mutex), \
@@ -216,6 +216,7 @@ static void cblist_init_generic(struct rcu_tasks *rtp) · 86 unmodified lines
216216 int cpu;
217217 unsigned long flags;
218218 int lim;
219+ int shift;
219220
220221 raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags);
221222 if (rcu_task_enqueue_lim < 0) {
@@ -229,7 +230,10 @@ static void cblist_init_generic(struct rcu_tasks *rtp) · 7 unmodified lines
229230
230231 if (lim > nr_cpu_ids)
231232 lim = nr_cpu_ids;
232− WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids / lim));
233+ shift = ilog2(nr_cpu_ids / lim);
234+ if (((nr_cpu_ids - 1) >> shift) >= lim)
235+ shift++;
236+ WRITE_ONCE(rtp->percpu_enqueue_shift, shift);
233237 WRITE_ONCE(rtp->percpu_dequeue_lim, lim);
234238 smp_store_release(&rtp->percpu_enqueue_lim, lim);
235239 for_each_possible_cpu(cpu) {
@@ -298,7 +302,7 @@ static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func, · 62 unmodified lines
298302 if (unlikely(needadjust)) {
299303 raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags);
300304 if (rtp->percpu_enqueue_lim != nr_cpu_ids) {
301− WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids));
305+ WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids) + 1);
302306 WRITE_ONCE(rtp->percpu_dequeue_lim, nr_cpu_ids);
303307 smp_store_release(&rtp->percpu_enqueue_lim, nr_cpu_ids);
304308 pr_info("Switching %s to per-CPU callback queuing.\n", rtp->name);
@@ -413,7 +417,7 @@ static int rcu_tasks_need_gpcb(struct rcu_tasks *rtp) · 108 unmodified lines
413417 if (rcu_task_cb_adjust && ncbs <= rcu_task_collapse_lim) {
414418 raw_spin_lock_irqsave(&rtp->cbs_gbl_lock, flags);
415419 if (rtp->percpu_enqueue_lim > 1) {
416− WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids));
420+ WRITE_ONCE(rtp->percpu_enqueue_shift, ilog2(nr_cpu_ids) + 1);
417421 smp_store_release(&rtp->percpu_enqueue_lim, 1);
418422 rtp->percpu_dequeue_gpseq = get_state_synchronize_rcu();
419423 pr_info("Starting switch %s to CPU-0 callback queuing.\n", rtp->name);
kernel/sched/membarrier.c+5−4
@@ -147,11 +147,11 @@ · 146 unmodified lines
147147 #endif
148148
149149 #ifdef CONFIG_RSEQ
150−#define MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ_BITMASK \
150+#define MEMBARRIER_PRIVATE_EXPEDITED_RSEQ_BITMASK \
151151 (MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ \
152− | MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ_BITMASK)
152+ | MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ)
153153 #else
154−#define MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ_BITMASK 0
154+#define MEMBARRIER_PRIVATE_EXPEDITED_RSEQ_BITMASK 0
155155 #endif
156156
157157 #define MEMBARRIER_CMD_BITMASK \
@@ -159,7 +159,8 @@ · 1 unmodified line
159159 | MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED \
160160 | MEMBARRIER_CMD_PRIVATE_EXPEDITED \
161161 | MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED \
162− | MEMBARRIER_PRIVATE_EXPEDITED_SYNC_CORE_BITMASK)
162+ | MEMBARRIER_PRIVATE_EXPEDITED_SYNC_CORE_BITMASK \
163+ | MEMBARRIER_PRIVATE_EXPEDITED_RSEQ_BITMASK)
163164
164165 static void ipi_mb(void *info)
165166 {
kernel/sched/psi.c+41−38
@@ -1082,44 +1082,6 @@ int psi_show(struct seq_file *m, struct psi_group *group, enum psi_res res) · 1081 unmodified lines
10821082 return 0;
10831083 }
10841084
1085−static int psi_io_show(struct seq_file *m, void *v)
1086−{
1087− return psi_show(m, &psi_system, PSI_IO);
1088−}
1089−
1090−static int psi_memory_show(struct seq_file *m, void *v)
1091−{
1092− return psi_show(m, &psi_system, PSI_MEM);
1093−}
1094−
1095−static int psi_cpu_show(struct seq_file *m, void *v)
1096−{
1097− return psi_show(m, &psi_system, PSI_CPU);
1098−}
1099−
1100−static int psi_open(struct file *file, int (*psi_show)(struct seq_file *, void *))
1101−{
1102− if (file->f_mode & FMODE_WRITE && !capable(CAP_SYS_RESOURCE))
1103− return -EPERM;
1104−
1105− return single_open(file, psi_show, NULL);
1106−}
1107−
1108−static int psi_io_open(struct inode *inode, struct file *file)
1109−{
1110− return psi_open(file, psi_io_show);
1111−}
1112−
1113−static int psi_memory_open(struct inode *inode, struct file *file)
1114−{
1115− return psi_open(file, psi_memory_show);
1116−}
1117−
1118−static int psi_cpu_open(struct inode *inode, struct file *file)
1119−{
1120− return psi_open(file, psi_cpu_show);
1121−}
1122−
11231085 struct psi_trigger *psi_trigger_create(struct psi_group *group,
11241086 char *buf, size_t nbytes, enum psi_res res)
11251087 {
@@ -1278,6 +1240,45 @@ __poll_t psi_trigger_poll(void **trigger_ptr, · 152 unmodified lines
12781240 return ret;
12791241 }
12801242
1243+#ifdef CONFIG_PROC_FS
1244+static int psi_io_show(struct seq_file *m, void *v)
1245+{
1246+ return psi_show(m, &psi_system, PSI_IO);
1247+}
1248+
1249+static int psi_memory_show(struct seq_file *m, void *v)
1250+{
1251+ return psi_show(m, &psi_system, PSI_MEM);
1252+}
1253+
1254+static int psi_cpu_show(struct seq_file *m, void *v)
1255+{
1256+ return psi_show(m, &psi_system, PSI_CPU);
1257+}
1258+
1259+static int psi_open(struct file *file, int (*psi_show)(struct seq_file *, void *))
1260+{
1261+ if (file->f_mode & FMODE_WRITE && !capable(CAP_SYS_RESOURCE))
1262+ return -EPERM;
1263+
1264+ return single_open(file, psi_show, NULL);
1265+}
1266+
1267+static int psi_io_open(struct inode *inode, struct file *file)
1268+{
1269+ return psi_open(file, psi_io_show);
1270+}
1271+
1272+static int psi_memory_open(struct inode *inode, struct file *file)
1273+{
1274+ return psi_open(file, psi_memory_show);
1275+}
1276+
1277+static int psi_cpu_open(struct inode *inode, struct file *file)
1278+{
1279+ return psi_open(file, psi_cpu_show);
1280+}
1281+
12811282 static ssize_t psi_write(struct file *file, const char __user *user_buf,
12821283 size_t nbytes, enum psi_res res)
12831284 {
@@ -1392,3 +1393,5 @@ static int __init psi_proc_init(void) · 108 unmodified lines
13921393 return 0;
13931394 }
13941395 module_init(psi_proc_init);
1396+
1397+#endif /* CONFIG_PROC_FS */
kernel/stackleak.c+2−3
@@ -70,7 +70,7 @@ late_initcall(stackleak_sysctls_init); · 69 unmodified lines
7070 #define skip_erasing() false
7171 #endif /* CONFIG_STACKLEAK_RUNTIME_DISABLE */
7272
73−asmlinkage void notrace stackleak_erase(void)
73+asmlinkage void noinstr stackleak_erase(void)
7474 {
7575 /* It would be nice not to have 'kstack_ptr' and 'boundary' on stack */
7676 unsigned long kstack_ptr = current->lowest_stack;
@@ -124,9 +124,8 @@ asmlinkage void notrace stackleak_erase(void) · 47 unmodified lines
124124 /* Reset the 'lowest_stack' value for the next syscall */
125125 current->lowest_stack = current_top_of_stack() - THREAD_SIZE/64;
126126 }
127−NOKPROBE_SYMBOL(stackleak_erase);
128127
129−void __used __no_caller_saved_registers notrace stackleak_track_stack(void)
128+void __used __no_caller_saved_registers noinstr stackleak_track_stack(void)
130129 {
131130 unsigned long sp = current_stack_pointer;
132131
kernel/trace/Kconfig+7−1
@@ -70,10 +70,16 @@ config HAVE_C_RECORDMCOUNT · 69 unmodified lines
7070 help
7171 C version of recordmcount available?
7272
73+config HAVE_BUILDTIME_MCOUNT_SORT
74+ bool
75+ help
76+ An architecture selects this if it sorts the mcount_loc section
77+ at build time.
78+
7379 config BUILDTIME_MCOUNT_SORT
7480 bool
7581 default y
76− depends on BUILDTIME_TABLE_SORT && !S390
82+ depends on HAVE_BUILDTIME_MCOUNT_SORT && DYNAMIC_FTRACE
7783 help
7884 Sort the mcount_loc section at build time.
7985
kernel/trace/trace.c+2−1
@@ -7740,7 +7740,8 @@ static struct tracing_log_err *get_tracing_log_err(struct trace_array *tr) · 7739 unmodified lines
77407740 err = kzalloc(sizeof(*err), GFP_KERNEL);
77417741 if (!err)
77427742 err = ERR_PTR(-ENOMEM);
7743− tr->n_err_log_entries++;
7743+ else
7744+ tr->n_err_log_entries++;
77447745
77457746 return err;
77467747 }
kernel/trace/trace_events_hist.c+8−2
@@ -2503,6 +2503,8 @@ static struct hist_field *parse_unary(struct hist_trigger_data *hist_data, · 2502 unmodified lines
25032503 (HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS);
25042504 expr->fn = hist_field_unary_minus;
25052505 expr->operands[0] = operand1;
2506+ expr->size = operand1->size;
2507+ expr->is_signed = operand1->is_signed;
25062508 expr->operator = FIELD_OP_UNARY_MINUS;
25072509 expr->name = expr_str(expr, 0);
25082510 expr->type = kstrdup_const(operand1->type, GFP_KERNEL);
@@ -2719,6 +2721,7 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data, · 210 unmodified lines
27192721
27202722 /* The operand sizes should be the same, so just pick one */
27212723 expr->size = operand1->size;
2724+ expr->is_signed = operand1->is_signed;
27222725
27232726 expr->operator = field_op;
27242727 expr->type = kstrdup_const(operand1->type, GFP_KERNEL);
@@ -3935,6 +3938,7 @@ static int trace_action_create(struct hist_trigger_data *hist_data, · 1210 unmodified lines
39353938
39363939 var_ref_idx = find_var_ref_idx(hist_data, var_ref);
39373940 if (WARN_ON(var_ref_idx < 0)) {
3941+ kfree(p);
39383942 ret = var_ref_idx;
39393943 goto err;
39403944 }
@@ -6163,7 +6167,9 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops, · 2222 unmodified lines
61636167
61646168 lockdep_assert_held(&event_mutex);
61656169
6166− if (glob && strlen(glob)) {
6170+ WARN_ON(!glob);
6171+
6172+ if (strlen(glob)) {
61676173 hist_err_clear();
61686174 last_cmd_set(file, param);
61696175 }
@@ -6196,7 +6202,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops, · 26 unmodified lines
61966202 continue;
61976203 }
61986204 break;
6199− } while (p);
6205+ } while (1);
62006206
62016207 if (!p)
62026208 param = NULL;
kernel/ucount.c+2−0
@@ -190,6 +190,7 @@ struct ucounts *alloc_ucounts(struct user_namespace *ns, kuid_t uid) · 189 unmodified lines
190190 kfree(new);
191191 } else {
192192 hlist_add_head(&new->node, hashent);
193+ get_user_ns(new->ns);
193194 spin_unlock_irq(&ucounts_lock);
194195 return new;
195196 }
@@ -210,6 +211,7 @@ void put_ucounts(struct ucounts *ucounts) · 14 unmodified lines
210211 if (atomic_dec_and_lock_irqsave(&ucounts->count, &ucounts_lock, flags)) {
211212 hlist_del_init(&ucounts->node);
212213 spin_unlock_irqrestore(&ucounts_lock, flags);
214+ put_user_ns(ucounts->ns);
213215 kfree(ucounts);
214216 }
215217 }