History

Merge tag 'v5.11' into sched/core, to pick up fixes & refresh the branch

Ingo Molnar committed 5 years ago

Commit ed3cd452 parents bae4ec1 f40ddce1642 files · +19353 −9628Browse files

Showing the changes to kernel (47 of 1642 files). Show all

Unified · Split

47 files
  1. kernel/bpf/bpf_inode_storage.c +11 −4
  2. kernel/bpf/bpf_lsm.c +12 −0
  3. kernel/bpf/bpf_task_storage.c +4 −1
  4. kernel/bpf/btf.c +1 −1
  5. kernel/bpf/cgroup.c +9 −3
  6. kernel/bpf/hashtab.c +1 −0
  7. kernel/bpf/helpers.c +1 −1
  8. kernel/bpf/preload/Makefile +4 −1
  9. kernel/bpf/stackmap.c +2 −0
  10. kernel/bpf/syscall.c +4 −3
  11. kernel/bpf/task_iter.c +9 −8
  12. kernel/bpf/verifier.c +25 −21
  13. kernel/cgroup/cgroup-v1.c +3 −0
  14. kernel/cgroup/cgroup.c +3 −1
  15. kernel/configs/android-recommended.config +0 −1
  16. kernel/dma/map_benchmark.c +6 −2
  17. kernel/entry/common.c +3 −11
  18. kernel/entry/syscall_user_dispatch.c +2 −2
  19. kernel/fork.c +2 −4
  20. kernel/futex.c +96 −123
  21. kernel/gcov/Kconfig +1 −1
  22. kernel/irq/manage.c +1 −0
  23. kernel/irq/msi.c +21 −25
  24. kernel/kexec_core.c +0 −2
  25. kernel/kprobes.c +28 −8
  26. kernel/kthread.c +27 −2
  27. kernel/locking/lockdep.c +7 −2
  28. kernel/locking/rtmutex.c +1 −2
  29. kernel/locking/rtmutex_common.h +1 −2
  30. kernel/power/swap.c +1 −1
  31. kernel/printk/printk.c +29 −11
  32. kernel/printk/printk_ringbuffer.c +1 −1
  33. kernel/rcu/tasks.h +21 −4
  34. kernel/sched/core.c +88 −23
  35. kernel/sched/sched.h +1 −0
  36. kernel/signal.c +5 −1
  37. kernel/smpboot.c +1 −0
  38. kernel/time/ntp.c +4 −4
  39. kernel/time/timekeeping.c +1 −2
  40. kernel/trace/Kconfig +1 −1
  41. kernel/trace/bpf_trace.c +0 −3
  42. kernel/trace/fgraph.c +0 −2
  43. kernel/trace/trace.c +1 −1
  44. kernel/trace/trace_events.c +2 −1
  45. kernel/trace/trace_irqsoff.c +4 −0
  46. kernel/trace/trace_kprobe.c +7 −5
  47. kernel/workqueue.c +13 −9
kernel/bpf/bpf_inode_storage.c+11−4
@@ -125,8 +125,12 @@ static int bpf_fd_inode_storage_update_elem(struct bpf_map *map, void *key, · 124 unmodified lines
125125
126126 fd = *(int *)key;
127127 f = fget_raw(fd);
128− if (!f || !inode_storage_ptr(f->f_inode))
128+ if (!f)
129+ return -EBADF;
130+ if (!inode_storage_ptr(f->f_inode)) {
131+ fput(f);
129132 return -EBADF;
133+ }
130134
131135 sdata = bpf_local_storage_update(f->f_inode,
132136 (struct bpf_local_storage_map *)map,
@@ -176,14 +180,14 @@ BPF_CALL_4(bpf_inode_storage_get, struct bpf_map *, map, struct inode *, inode, · 43 unmodified lines
176180 * bpf_local_storage_update expects the owner to have a
177181 * valid storage pointer.
178182 */
179− if (!inode_storage_ptr(inode))
183+ if (!inode || !inode_storage_ptr(inode))
180184 return (unsigned long)NULL;
181185
182186 sdata = inode_storage_lookup(inode, map, true);
183187 if (sdata)
184188 return (unsigned long)sdata->data;
185189
186− /* This helper must only called from where the inode is gurranteed
190+ /* This helper must only called from where the inode is guaranteed
187191 * to have a refcount and cannot be freed.
188192 */
189193 if (flags & BPF_LOCAL_STORAGE_GET_F_CREATE) {
@@ -200,7 +204,10 @@ BPF_CALL_4(bpf_inode_storage_get, struct bpf_map *, map, struct inode *, inode, · 10 unmodified lines
200204 BPF_CALL_2(bpf_inode_storage_delete,
201205 struct bpf_map *, map, struct inode *, inode)
202206 {
203− /* This helper must only called from where the inode is gurranteed
207+ if (!inode)
208+ return -EINVAL;
209+
210+ /* This helper must only called from where the inode is guaranteed
204211 * to have a refcount and cannot be freed.
205212 */
206213 return inode_storage_delete(inode, map);
kernel/bpf/bpf_lsm.c+12−0
@@ -149,7 +149,11 @@ BTF_ID(func, bpf_lsm_file_ioctl) · 148 unmodified lines
149149 BTF_ID(func, bpf_lsm_file_lock)
150150 BTF_ID(func, bpf_lsm_file_open)
151151 BTF_ID(func, bpf_lsm_file_receive)
152+
153+#ifdef CONFIG_SECURITY_NETWORK
152154 BTF_ID(func, bpf_lsm_inet_conn_established)
155+#endif /* CONFIG_SECURITY_NETWORK */
156+
153157 BTF_ID(func, bpf_lsm_inode_create)
154158 BTF_ID(func, bpf_lsm_inode_free_security)
155159 BTF_ID(func, bpf_lsm_inode_getattr)
@@ -166,7 +170,11 @@ BTF_ID(func, bpf_lsm_inode_symlink) · 10 unmodified lines
166170 BTF_ID(func, bpf_lsm_inode_unlink)
167171 BTF_ID(func, bpf_lsm_kernel_module_request)
168172 BTF_ID(func, bpf_lsm_kernfs_init_security)
173+
174+#ifdef CONFIG_KEYS
169175 BTF_ID(func, bpf_lsm_key_free)
176+#endif /* CONFIG_KEYS */
177+
170178 BTF_ID(func, bpf_lsm_mmap_file)
171179 BTF_ID(func, bpf_lsm_netlink_send)
172180 BTF_ID(func, bpf_lsm_path_notify)
@@ -181,6 +189,8 @@ BTF_ID(func, bpf_lsm_sb_show_options) · 8 unmodified lines
181189 BTF_ID(func, bpf_lsm_sb_statfs)
182190 BTF_ID(func, bpf_lsm_sb_umount)
183191 BTF_ID(func, bpf_lsm_settime)
192+
193+#ifdef CONFIG_SECURITY_NETWORK
184194 BTF_ID(func, bpf_lsm_socket_accept)
185195 BTF_ID(func, bpf_lsm_socket_bind)
186196 BTF_ID(func, bpf_lsm_socket_connect)
@@ -195,6 +205,8 @@ BTF_ID(func, bpf_lsm_socket_recvmsg) · 8 unmodified lines
195205 BTF_ID(func, bpf_lsm_socket_sendmsg)
196206 BTF_ID(func, bpf_lsm_socket_shutdown)
197207 BTF_ID(func, bpf_lsm_socket_socketpair)
208+#endif /* CONFIG_SECURITY_NETWORK */
209+
198210 BTF_ID(func, bpf_lsm_syslog)
199211 BTF_ID(func, bpf_lsm_task_alloc)
200212 BTF_ID(func, bpf_lsm_task_getsecid)
kernel/bpf/bpf_task_storage.c+4−1
@@ -218,7 +218,7 @@ BPF_CALL_4(bpf_task_storage_get, struct bpf_map *, map, struct task_struct *, · 217 unmodified lines
218218 * bpf_local_storage_update expects the owner to have a
219219 * valid storage pointer.
220220 */
221− if (!task_storage_ptr(task))
221+ if (!task || !task_storage_ptr(task))
222222 return (unsigned long)NULL;
223223
224224 sdata = task_storage_lookup(task, map, true);
@@ -243,6 +243,9 @@ BPF_CALL_4(bpf_task_storage_get, struct bpf_map *, map, struct task_struct *, · 18 unmodified lines
243243 BPF_CALL_2(bpf_task_storage_delete, struct bpf_map *, map, struct task_struct *,
244244 task)
245245 {
246+ if (!task)
247+ return -EINVAL;
248+
246249 /* This helper must only be called from places where the lifetime of the task
247250 * is guaranteed. Either by being refcounted or by being protected
248251 * by an RCU read-side critical section.
kernel/bpf/btf.c+1−1
@@ -4172,7 +4172,7 @@ static int btf_parse_hdr(struct btf_verifier_env *env) · 4171 unmodified lines
41724172 return -ENOTSUPP;
41734173 }
41744174
4175− if (btf_data_size == hdr->hdr_len) {
4175+ if (!btf->base_btf && btf_data_size == hdr->hdr_len) {
41764176 btf_verifier_log(env, "No data");
41774177 return -EINVAL;
41784178 }
kernel/bpf/cgroup.c+9−3
@@ -1391,12 +1391,13 @@ int __cgroup_bpf_run_filter_setsockopt(struct sock *sk, int *level, · 1390 unmodified lines
13911391 if (ctx.optlen != 0) {
13921392 *optlen = ctx.optlen;
13931393 *kernel_optval = ctx.optval;
1394+ /* export and don't free sockopt buf */
1395+ return 0;
13941396 }
13951397 }
13961398
13971399 out:
1398− if (ret)
1399− sockopt_free_buf(&ctx);
1400+ sockopt_free_buf(&ctx);
14001401 return ret;
14011402 }
14021403
@@ -1441,6 +1442,11 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level, · 38 unmodified lines
14411442 goto out;
14421443 }
14431444
1445+ if (ctx.optlen < 0) {
1446+ ret = -EFAULT;
1447+ goto out;
1448+ }
1449+
14441450 if (copy_from_user(ctx.optval, optval,
14451451 min(ctx.optlen, max_optlen)) != 0) {
14461452 ret = -EFAULT;
@@ -1458,7 +1464,7 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level, · 11 unmodified lines
14581464 goto out;
14591465 }
14601466
1461− if (ctx.optlen > max_optlen) {
1467+ if (ctx.optlen > max_optlen || ctx.optlen < 0) {
14621468 ret = -EFAULT;
14631469 goto out;
14641470 }
kernel/bpf/hashtab.c+1−0
@@ -152,6 +152,7 @@ static void htab_init_buckets(struct bpf_htab *htab) · 151 unmodified lines
152152 lockdep_set_class(&htab->buckets[i].lock,
153153 &htab->lockdep_key);
154154 }
155+ cond_resched();
155156 }
156157 }
157158
kernel/bpf/helpers.c+1−1
@@ -108,7 +108,7 @@ BPF_CALL_2(bpf_map_peek_elem, struct bpf_map *, map, void *, value) · 107 unmodified lines
108108 }
109109
110110 const struct bpf_func_proto bpf_map_peek_elem_proto = {
111− .func = bpf_map_pop_elem,
111+ .func = bpf_map_peek_elem,
112112 .gpl_only = false,
113113 .ret_type = RET_INTEGER,
114114 .arg1_type = ARG_CONST_MAP_PTR,
kernel/bpf/preload/Makefile+4−1
@@ -4,8 +4,11 @@ LIBBPF_SRCS = $(srctree)/tools/lib/bpf/ · 3 unmodified lines
44 LIBBPF_A = $(obj)/libbpf.a
55 LIBBPF_OUT = $(abspath $(obj))
66
7+# Although not in use by libbpf's Makefile, set $(O) so that the "dummy" test
8+# in tools/scripts/Makefile.include always succeeds when building the kernel
9+# with $(O) pointing to a relative path, as in "make O=build bindeb-pkg".
710 $(LIBBPF_A):
8− $(Q)$(MAKE) -C $(LIBBPF_SRCS) OUTPUT=$(LIBBPF_OUT)/ $(LIBBPF_OUT)/libbpf.a
11+ $(Q)$(MAKE) -C $(LIBBPF_SRCS) O=$(LIBBPF_OUT)/ OUTPUT=$(LIBBPF_OUT)/ $(LIBBPF_OUT)/libbpf.a
912
1013 userccflags += -I $(srctree)/tools/include/ -I $(srctree)/tools/include/uapi \
1114 -I $(srctree)/tools/lib/ -Wno-unused-result
kernel/bpf/stackmap.c+2−0
@@ -115,6 +115,8 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr) · 114 unmodified lines
115115
116116 /* hash table size must be power of 2 */
117117 n_buckets = roundup_pow_of_two(attr->max_entries);
118+ if (!n_buckets)
119+ return ERR_PTR(-E2BIG);
118120
119121 cost = n_buckets * sizeof(struct stack_map_bucket *) + sizeof(*smap);
120122 cost += n_buckets * (value_size + sizeof(struct stack_map_bucket));
kernel/bpf/syscall.c+4−3
@@ -17,7 +17,6 @@ · 16 unmodified lines
1717 #include <linux/fs.h>
1818 #include <linux/license.h>
1919 #include <linux/filter.h>
20−#include <linux/version.h>
2120 #include <linux/kernel.h>
2221 #include <linux/idr.h>
2322 #include <linux/cred.h>
@@ -2713,7 +2712,6 @@ out_unlock: · 2689 unmodified lines
27132712 out_put_prog:
27142713 if (tgt_prog_fd && tgt_prog)
27152714 bpf_prog_put(tgt_prog);
2716− bpf_prog_put(prog);
27172715 return err;
27182716 }
27192717
@@ -2826,7 +2824,10 @@ static int bpf_raw_tracepoint_open(const union bpf_attr *attr) · 106 unmodified lines
28262824 tp_name = prog->aux->attach_func_name;
28272825 break;
28282826 }
2829− return bpf_tracing_prog_attach(prog, 0, 0);
2827+ err = bpf_tracing_prog_attach(prog, 0, 0);
2828+ if (err >= 0)
2829+ return err;
2830+ goto out_put_prog;
28302831 case BPF_PROG_TYPE_RAW_TRACEPOINT:
28312832 case BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE:
28322833 if (strncpy_from_user(buf,
kernel/bpf/task_iter.c+9−8
@@ -37,7 +37,7 @@ retry: · 36 unmodified lines
3737 if (!task) {
3838 ++*tid;
3939 goto retry;
40− } else if (skip_if_dup_files && task->tgid != task->pid &&
40+ } else if (skip_if_dup_files && !thread_group_leader(task) &&
4141 task->files == task->group_leader->files) {
4242 put_task_struct(task);
4343 task = NULL;
@@ -151,13 +151,14 @@ again: · 107 unmodified lines
151151 curr_task = info->task;
152152 curr_fd = info->fd;
153153 } else {
154− curr_task = task_seq_get_next(ns, &curr_tid, true);
155− if (!curr_task) {
156− info->task = NULL;
157− return NULL;
158− }
159−
160− /* set info->task and info->tid */
154+ curr_task = task_seq_get_next(ns, &curr_tid, true);
155+ if (!curr_task) {
156+ info->task = NULL;
157+ info->tid = curr_tid;
158+ return NULL;
159+ }
160+
161+ /* set info->task and info->tid */
161162 info->task = curr_task;
162163 if (curr_tid == info->tid) {
163164 curr_fd = info->fd;
kernel/bpf/verifier.c+25−21
@@ -2217,6 +2217,8 @@ static bool is_spillable_regtype(enum bpf_reg_type type) · 2216 unmodified lines
22172217 case PTR_TO_RDWR_BUF:
22182218 case PTR_TO_RDWR_BUF_OR_NULL:
22192219 case PTR_TO_PERCPU_BTF_ID:
2220+ case PTR_TO_MEM:
2221+ case PTR_TO_MEM_OR_NULL:
22202222 return true;
22212223 default:
22222224 return false;
@@ -5311,7 +5313,7 @@ static bool signed_add_overflows(s64 a, s64 b) · 3088 unmodified lines
53115313 return res < a;
53125314 }
53135315
5314−static bool signed_add32_overflows(s64 a, s64 b)
5316+static bool signed_add32_overflows(s32 a, s32 b)
53155317 {
53165318 /* Do the add in u32, where overflow is well-defined */
53175319 s32 res = (s32)((u32)a + (u32)b);
@@ -5321,7 +5323,7 @@ static bool signed_add32_overflows(s64 a, s64 b) · 3 unmodified lines
53215323 return res < a;
53225324 }
53235325
5324−static bool signed_sub_overflows(s32 a, s32 b)
5326+static bool signed_sub_overflows(s64 a, s64 b)
53255327 {
53265328 /* Do the sub in u64, where overflow is well-defined */
53275329 s64 res = (s64)((u64)a - (u64)b);
@@ -5333,7 +5335,7 @@ static bool signed_sub_overflows(s32 a, s32 b) · 5 unmodified lines
53335335
53345336 static bool signed_sub32_overflows(s32 a, s32 b)
53355337 {
5336− /* Do the sub in u64, where overflow is well-defined */
5338+ /* Do the sub in u32, where overflow is well-defined */
53375339 s32 res = (s32)((u32)a - (u32)b);
53385340
53395341 if (b < 0)
@@ -6875,7 +6877,7 @@ static int is_branch32_taken(struct bpf_reg_state *reg, u32 val, u8 opcode) · 1535 unmodified lines
68756877 case BPF_JSGT:
68766878 if (reg->s32_min_value > sval)
68776879 return 1;
6878− else if (reg->s32_max_value < sval)
6880+ else if (reg->s32_max_value <= sval)
68796881 return 0;
68806882 break;
68816883 case BPF_JLT:
@@ -6948,7 +6950,7 @@ static int is_branch64_taken(struct bpf_reg_state *reg, u64 val, u8 opcode) · 66 unmodified lines
69486950 case BPF_JSGT:
69496951 if (reg->smin_value > sval)
69506952 return 1;
6951− else if (reg->smax_value < sval)
6953+ else if (reg->smax_value <= sval)
69526954 return 0;
69536955 break;
69546956 case BPF_JLT:
@@ -8588,7 +8590,11 @@ static bool range_within(struct bpf_reg_state *old, · 1633 unmodified lines
85888590 return old->umin_value <= cur->umin_value &&
85898591 old->umax_value >= cur->umax_value &&
85908592 old->smin_value <= cur->smin_value &&
8591− old->smax_value >= cur->smax_value;
8593+ old->smax_value >= cur->smax_value &&
8594+ old->u32_min_value <= cur->u32_min_value &&
8595+ old->u32_max_value >= cur->u32_max_value &&
8596+ old->s32_min_value <= cur->s32_min_value &&
8597+ old->s32_max_value >= cur->s32_max_value;
85928598 }
85938599
85948600 /* Maximum number of register states that can exist at once */
@@ -10997,30 +11003,28 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env) · 2402 unmodified lines
1099711003 insn->code == (BPF_ALU | BPF_MOD | BPF_X) ||
1099811004 insn->code == (BPF_ALU | BPF_DIV | BPF_X)) {
1099911005 bool is64 = BPF_CLASS(insn->code) == BPF_ALU64;
11000− struct bpf_insn mask_and_div[] = {
11001− BPF_MOV32_REG(insn->src_reg, insn->src_reg),
11006+ bool isdiv = BPF_OP(insn->code) == BPF_DIV;
11007+ struct bpf_insn *patchlet;
11008+ struct bpf_insn chk_and_div[] = {
1100211009 /* Rx div 0 -> 0 */
11003− BPF_JMP_IMM(BPF_JNE, insn->src_reg, 0, 2),
11010+ BPF_RAW_INSN((is64 ? BPF_JMP : BPF_JMP32) |
11011+ BPF_JNE | BPF_K, insn->src_reg,
11012+ 0, 2, 0),
1100411013 BPF_ALU32_REG(BPF_XOR, insn->dst_reg, insn->dst_reg),
1100511014 BPF_JMP_IMM(BPF_JA, 0, 0, 1),
1100611015 *insn,
1100711016 };
11008− struct bpf_insn mask_and_mod[] = {
11009− BPF_MOV32_REG(insn->src_reg, insn->src_reg),
11017+ struct bpf_insn chk_and_mod[] = {
1101011018 /* Rx mod 0 -> Rx */
11011− BPF_JMP_IMM(BPF_JEQ, insn->src_reg, 0, 1),
11019+ BPF_RAW_INSN((is64 ? BPF_JMP : BPF_JMP32) |
11020+ BPF_JEQ | BPF_K, insn->src_reg,
11021+ 0, 1, 0),
1101211022 *insn,
1101311023 };
11014− struct bpf_insn *patchlet;
1101511024
11016− if (insn->code == (BPF_ALU64 | BPF_DIV | BPF_X) ||
11017− insn->code == (BPF_ALU | BPF_DIV | BPF_X)) {
11018− patchlet = mask_and_div + (is64 ? 1 : 0);
11019− cnt = ARRAY_SIZE(mask_and_div) - (is64 ? 1 : 0);
11020− } else {
11021− patchlet = mask_and_mod + (is64 ? 1 : 0);
11022− cnt = ARRAY_SIZE(mask_and_mod) - (is64 ? 1 : 0);
11023− }
11025+ patchlet = isdiv ? chk_and_div : chk_and_mod;
11026+ cnt = isdiv ? ARRAY_SIZE(chk_and_div) :
11027+ ARRAY_SIZE(chk_and_mod);
1102411028
1102511029 new_prog = bpf_patch_insn_data(env, i + delta, patchlet, cnt);
1102611030 if (!new_prog)
kernel/cgroup/cgroup-v1.c+3−0
@@ -917,6 +917,9 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param) · 916 unmodified lines
917917 for_each_subsys(ss, i) {
918918 if (strcmp(param->key, ss->legacy_name))
919919 continue;
920+ if (!cgroup_ssid_enabled(i) || cgroup1_ssid_disabled(i))
921+ return invalfc(fc, "Disabled controller '%s'",
922+ param->key);
920923 ctx->subsys_mask |= (1 << i);
921924 return 0;
922925 }
kernel/cgroup/cgroup.c+3−1
@@ -3564,6 +3564,7 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of, char *buf, · 3563 unmodified lines
35643564 {
35653565 struct psi_trigger *new;
35663566 struct cgroup *cgrp;
3567+ struct psi_group *psi;
35673568
35683569 cgrp = cgroup_kn_lock_live(of->kn, false);
35693570 if (!cgrp)
@@ -3572,7 +3573,8 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of, char *buf, · 2 unmodified lines
35723573 cgroup_get(cgrp);
35733574 cgroup_kn_unlock(of->kn);
35743575
3575− new = psi_trigger_create(&cgrp->psi, buf, nbytes, res);
3576+ psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi;
3577+ new = psi_trigger_create(psi, buf, nbytes, res);
35763578 if (IS_ERR(new)) {
35773579 cgroup_put(cgrp);
35783580 return PTR_ERR(new);
kernel/configs/android-recommended.config+0−1
@@ -81,7 +81,6 @@ CONFIG_INPUT_JOYSTICK=y · 80 unmodified lines
8181 CONFIG_INPUT_MISC=y
8282 CONFIG_INPUT_TABLET=y
8383 CONFIG_INPUT_UINPUT=y
84−CONFIG_ION=y
8584 CONFIG_JOYSTICK_XPAD=y
8685 CONFIG_JOYSTICK_XPAD_FF=y
8786 CONFIG_JOYSTICK_XPAD_LEDS=y
kernel/dma/map_benchmark.c+6−2
@@ -36,7 +36,7 @@ struct map_benchmark { · 35 unmodified lines
3636 __s32 node; /* which numa node this benchmark will run on */
3737 __u32 dma_bits; /* DMA addressing capability */
3838 __u32 dma_dir; /* DMA data direction */
39− __u64 expansion[10]; /* For future use */
39+ __u8 expansion[84]; /* For future use */
4040 };
4141
4242 struct map_benchmark_data {
@@ -147,8 +147,10 @@ static int do_map_benchmark(struct map_benchmark_data *map) · 104 unmodified lines
147147 atomic64_set(&map->sum_sq_unmap, 0);
148148 atomic64_set(&map->loops, 0);
149149
150− for (i = 0; i < threads; i++)
150+ for (i = 0; i < threads; i++) {
151+ get_task_struct(tsk[i]);
151152 wake_up_process(tsk[i]);
153+ }
152154
153155 msleep_interruptible(map->bparam.seconds * 1000);
154156
@@ -183,6 +185,8 @@ static int do_map_benchmark(struct map_benchmark_data *map) · 28 unmodified lines
183185 }
184186
185187 out:
188+ for (i = 0; i < threads; i++)
189+ put_task_struct(tsk[i]);
186190 put_device(map->dev);
187191 kfree(tsk);
188192 return ret;
kernel/entry/common.c+3−11
@@ -209,26 +209,18 @@ static void exit_to_user_mode_prepare(struct pt_regs *regs) · 208 unmodified lines
209209 lockdep_sys_exit();
210210 }
211211
212−#ifndef _TIF_SINGLESTEP
213−static inline bool report_single_step(unsigned long work)
214−{
215− return false;
216−}
217−#else
218212 /*
219213 * If SYSCALL_EMU is set, then the only reason to report is when
220− * TIF_SINGLESTEP is set (i.e. PTRACE_SYSEMU_SINGLESTEP). This syscall
214+ * SINGLESTEP is set (i.e. PTRACE_SYSEMU_SINGLESTEP). This syscall
221215 * instruction has been already reported in syscall_enter_from_user_mode().
222216 */
223217 static inline bool report_single_step(unsigned long work)
224218 {
225− if (!(work & SYSCALL_WORK_SYSCALL_EMU))
219+ if (work & SYSCALL_WORK_SYSCALL_EMU)
226220 return false;
227221
228− return !!(current_thread_info()->flags & _TIF_SINGLESTEP);
222+ return work & SYSCALL_WORK_SYSCALL_EXIT_TRAP;
229223 }
230−#endif
231−
232224
233225 static void syscall_exit_work(struct pt_regs *regs, unsigned long work)
234226 {
kernel/entry/syscall_user_dispatch.c+2−2
@@ -50,10 +50,10 @@ bool syscall_user_dispatch(struct pt_regs *regs) · 49 unmodified lines
5050 if (unlikely(__get_user(state, sd->selector)))
5151 do_exit(SIGSEGV);
5252
53− if (likely(state == PR_SYS_DISPATCH_OFF))
53+ if (likely(state == SYSCALL_DISPATCH_FILTER_ALLOW))
5454 return false;
5555
56− if (state != PR_SYS_DISPATCH_ON)
56+ if (state != SYSCALL_DISPATCH_FILTER_BLOCK)
5757 do_exit(SIGSYS);
5858 }
5959
kernel/fork.c+2−4
@@ -819,9 +819,8 @@ void __init fork_init(void) · 818 unmodified lines
819819 init_task.signal->rlim[RLIMIT_SIGPENDING] =
820820 init_task.signal->rlim[RLIMIT_NPROC];
821821
822− for (i = 0; i < UCOUNT_COUNTS; i++) {
822+ for (i = 0; i < UCOUNT_COUNTS; i++)
823823 init_user_ns.ucount_max[i] = max_threads/2;
824− }
825824
826825 #ifdef CONFIG_VMAP_STACK
827826 cpuhp_setup_state(CPUHP_BP_PREPARE_DYN, "fork:vm_stack_cache",
@@ -1654,9 +1653,8 @@ static inline void init_task_pid_links(struct task_struct *task) · 826 unmodified lines
16541653 {
16551654 enum pid_type type;
16561655
1657− for (type = PIDTYPE_PID; type < PIDTYPE_MAX; ++type) {
1656+ for (type = PIDTYPE_PID; type < PIDTYPE_MAX; ++type)
16581657 INIT_HLIST_NODE(&task->pid_links[type]);
1659− }
16601658 }
16611659
16621660 static inline void
kernel/futex.c+96−123
@@ -763,6 +763,29 @@ static struct futex_pi_state *alloc_pi_state(void) · 762 unmodified lines
763763 return pi_state;
764764 }
765765
766+static void pi_state_update_owner(struct futex_pi_state *pi_state,
767+ struct task_struct *new_owner)
768+{
769+ struct task_struct *old_owner = pi_state->owner;
770+
771+ lockdep_assert_held(&pi_state->pi_mutex.wait_lock);
772+
773+ if (old_owner) {
774+ raw_spin_lock(&old_owner->pi_lock);
775+ WARN_ON(list_empty(&pi_state->list));
776+ list_del_init(&pi_state->list);
777+ raw_spin_unlock(&old_owner->pi_lock);
778+ }
779+
780+ if (new_owner) {
781+ raw_spin_lock(&new_owner->pi_lock);
782+ WARN_ON(!list_empty(&pi_state->list));
783+ list_add(&pi_state->list, &new_owner->pi_state_list);
784+ pi_state->owner = new_owner;
785+ raw_spin_unlock(&new_owner->pi_lock);
786+ }
787+}
788+
766789 static void get_pi_state(struct futex_pi_state *pi_state)
767790 {
768791 WARN_ON_ONCE(!refcount_inc_not_zero(&pi_state->refcount));
@@ -785,17 +808,11 @@ static void put_pi_state(struct futex_pi_state *pi_state) · 16 unmodified lines
785808 * and has cleaned up the pi_state already
786809 */
787810 if (pi_state->owner) {
788− struct task_struct *owner;
789811 unsigned long flags;
790812
791813 raw_spin_lock_irqsave(&pi_state->pi_mutex.wait_lock, flags);
792− owner = pi_state->owner;
793− if (owner) {
794− raw_spin_lock(&owner->pi_lock);
795− list_del_init(&pi_state->list);
796− raw_spin_unlock(&owner->pi_lock);
797− }
798− rt_mutex_proxy_unlock(&pi_state->pi_mutex, owner);
814+ pi_state_update_owner(pi_state, NULL);
815+ rt_mutex_proxy_unlock(&pi_state->pi_mutex);
799816 raw_spin_unlock_irqrestore(&pi_state->pi_mutex.wait_lock, flags);
800817 }
801818
@@ -941,7 +958,8 @@ static inline void exit_pi_state_list(struct task_struct *curr) { } · 139 unmodified lines
941958 * FUTEX_OWNER_DIED bit. See [4]
942959 *
943960 * [10] There is no transient state which leaves owner and user space
944− * TID out of sync.
961+ * TID out of sync. Except one error case where the kernel is denied
962+ * write access to the user address, see fixup_pi_state_owner().
945963 *
946964 *
947965 * Serialization and lifetime rules:
@@ -1521,26 +1539,15 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_pi_state *pi_ · 573 unmodified lines
15211539 ret = -EINVAL;
15221540 }
15231541
1524− if (ret)
1525− goto out_unlock;
1526−
1527− /*
1528− * This is a point of no return; once we modify the uval there is no
1529− * going back and subsequent operations must not fail.
1530− */
1531−
1532− raw_spin_lock(&pi_state->owner->pi_lock);
1533− WARN_ON(list_empty(&pi_state->list));
1534− list_del_init(&pi_state->list);
1535− raw_spin_unlock(&pi_state->owner->pi_lock);
1536−
1537− raw_spin_lock(&new_owner->pi_lock);
1538− WARN_ON(!list_empty(&pi_state->list));
1539− list_add(&pi_state->list, &new_owner->pi_state_list);
1540− pi_state->owner = new_owner;
1541− raw_spin_unlock(&new_owner->pi_lock);
1542−
1543− postunlock = __rt_mutex_futex_unlock(&pi_state->pi_mutex, &wake_q);
1542+ if (!ret) {
1543+ /*
1544+ * This is a point of no return; once we modified the uval
1545+ * there is no going back and subsequent operations must
1546+ * not fail.
1547+ */
1548+ pi_state_update_owner(pi_state, new_owner);
1549+ postunlock = __rt_mutex_futex_unlock(&pi_state->pi_mutex, &wake_q);
1550+ }
15441551
15451552 out_unlock:
15461553 raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock);
@@ -2323,18 +2330,13 @@ static void unqueue_me_pi(struct futex_q *q) · 776 unmodified lines
23232330 spin_unlock(q->lock_ptr);
23242331 }
23252332
2326−static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q,
2327− struct task_struct *argowner)
2333+static int __fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q,
2334+ struct task_struct *argowner)
23282335 {
23292336 struct futex_pi_state *pi_state = q->pi_state;
2330− u32 uval, curval, newval;
23312337 struct task_struct *oldowner, *newowner;
2332− u32 newtid;
2333− int ret, err = 0;
2334−
2335− lockdep_assert_held(q->lock_ptr);
2336−
2337− raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock);
2338+ u32 uval, curval, newval, newtid;
2339+ int err = 0;
23382340
23392341 oldowner = pi_state->owner;
23402342
@@ -2368,14 +2370,12 @@ retry: · 27 unmodified lines
23682370 * We raced against a concurrent self; things are
23692371 * already fixed up. Nothing to do.
23702372 */
2371− ret = 0;
2372− goto out_unlock;
2373+ return 0;
23732374 }
23742375
23752376 if (__rt_mutex_futex_trylock(&pi_state->pi_mutex)) {
2376− /* We got the lock after all, nothing to fix. */
2377− ret = 0;
2378− goto out_unlock;
2377+ /* We got the lock. pi_state is correct. Tell caller. */
2378+ return 1;
23792379 }
23802380
23812381 /*
@@ -2402,8 +2402,7 @@ retry: · 20 unmodified lines
24022402 * We raced against a concurrent self; things are
24032403 * already fixed up. Nothing to do.
24042404 */
2405− ret = 0;
2406− goto out_unlock;
2405+ return 1;
24072406 }
24082407 newowner = argowner;
24092408 }
@@ -2433,22 +2432,9 @@ retry: · 23 unmodified lines
24332432 * We fixed up user space. Now we need to fix the pi_state
24342433 * itself.
24352434 */
2436− if (pi_state->owner != NULL) {
2437− raw_spin_lock(&pi_state->owner->pi_lock);
2438− WARN_ON(list_empty(&pi_state->list));
2439− list_del_init(&pi_state->list);
2440− raw_spin_unlock(&pi_state->owner->pi_lock);
2441− }
2435+ pi_state_update_owner(pi_state, newowner);
24422436
2443− pi_state->owner = newowner;
2444−
2445− raw_spin_lock(&newowner->pi_lock);
2446− WARN_ON(!list_empty(&pi_state->list));
2447− list_add(&pi_state->list, &newowner->pi_state_list);
2448− raw_spin_unlock(&newowner->pi_lock);
2449− raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock);
2450−
2451− return 0;
2437+ return argowner == current;
24522438
24532439 /*
24542440 * In order to reschedule or handle a page fault, we need to drop the
@@ -2469,17 +2455,16 @@ handle_err: · 14 unmodified lines
24692455
24702456 switch (err) {
24712457 case -EFAULT:
2472− ret = fault_in_user_writeable(uaddr);
2458+ err = fault_in_user_writeable(uaddr);
24732459 break;
24742460
24752461 case -EAGAIN:
24762462 cond_resched();
2477− ret = 0;
2463+ err = 0;
24782464 break;
24792465
24802466 default:
24812467 WARN_ON_ONCE(1);
2482− ret = err;
24832468 break;
24842469 }
24852470
@@ -2489,17 +2474,44 @@ handle_err: · 3 unmodified lines
24892474 /*
24902475 * Check if someone else fixed it for us:
24912476 */
2492− if (pi_state->owner != oldowner) {
2493− ret = 0;
2494− goto out_unlock;
2495− }
2477+ if (pi_state->owner != oldowner)
2478+ return argowner == current;
24962479
2497− if (ret)
2498− goto out_unlock;
2480+ /* Retry if err was -EAGAIN or the fault in succeeded */
2481+ if (!err)
2482+ goto retry;
24992483
2500− goto retry;
2484+ /*
2485+ * fault_in_user_writeable() failed so user state is immutable. At
2486+ * best we can make the kernel state consistent but user state will
2487+ * be most likely hosed and any subsequent unlock operation will be
2488+ * rejected due to PI futex rule [10].
2489+ *
2490+ * Ensure that the rtmutex owner is also the pi_state owner despite
2491+ * the user space value claiming something different. There is no
2492+ * point in unlocking the rtmutex if current is the owner as it
2493+ * would need to wait until the next waiter has taken the rtmutex
2494+ * to guarantee consistent state. Keep it simple. Userspace asked
2495+ * for this wreckaged state.
2496+ *
2497+ * The rtmutex has an owner - either current or some other
2498+ * task. See the EAGAIN loop above.
2499+ */
2500+ pi_state_update_owner(pi_state, rt_mutex_owner(&pi_state->pi_mutex));
25012501
2502−out_unlock:
2502+ return err;
2503+}
2504+
2505+static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q,
2506+ struct task_struct *argowner)
2507+{
2508+ struct futex_pi_state *pi_state = q->pi_state;
2509+ int ret;
2510+
2511+ lockdep_assert_held(q->lock_ptr);
2512+
2513+ raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock);
2514+ ret = __fixup_pi_state_owner(uaddr, q, argowner);
25032515 raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock);
25042516 return ret;
25052517 }
@@ -2523,8 +2535,6 @@ static long futex_wait_restart(struct restart_block *restart); · 17 unmodified lines
25232535 */
25242536 static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked)
25252537 {
2526− int ret = 0;
2527−
25282538 if (locked) {
25292539 /*
25302540 * Got the lock. We might not be the anticipated owner if we
@@ -2535,8 +2545,8 @@ static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked) · 4 unmodified lines
25352545 * stable state, anything else needs more attention.
25362546 */
25372547 if (q->pi_state->owner != current)
2538− ret = fixup_pi_state_owner(uaddr, q, current);
2539− return ret ? ret : locked;
2548+ return fixup_pi_state_owner(uaddr, q, current);
2549+ return 1;
25402550 }
25412551
25422552 /*
@@ -2547,23 +2557,17 @@ static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked) · 4 unmodified lines
25472557 * Another speculative read; pi_state->owner == current is unstable
25482558 * but needs our attention.
25492559 */
2550− if (q->pi_state->owner == current) {
2551− ret = fixup_pi_state_owner(uaddr, q, NULL);
2552− return ret;
2553− }
2560+ if (q->pi_state->owner == current)
2561+ return fixup_pi_state_owner(uaddr, q, NULL);
25542562
25552563 /*
25562564 * Paranoia check. If we did not take the lock, then we should not be
2557− * the owner of the rt_mutex.
2565+ * the owner of the rt_mutex. Warn and establish consistent state.
25582566 */
2559− if (rt_mutex_owner(&q->pi_state->pi_mutex) == current) {
2560− printk(KERN_ERR "fixup_owner: ret = %d pi-mutex: %p "
2561− "pi-state %p\n", ret,
2562− q->pi_state->pi_mutex.owner,
2563− q->pi_state->owner);
2564− }
2567+ if (WARN_ON_ONCE(rt_mutex_owner(&q->pi_state->pi_mutex) == current))
2568+ return fixup_pi_state_owner(uaddr, q, current);
25652569
2566− return ret;
2570+ return 0;
25672571 }
25682572
25692573 /**
@@ -2771,7 +2775,6 @@ static int futex_lock_pi(u32 __user *uaddr, unsigned int flags, · 201 unmodified lines
27712775 ktime_t *time, int trylock)
27722776 {
27732777 struct hrtimer_sleeper timeout, *to;
2774− struct futex_pi_state *pi_state = NULL;
27752778 struct task_struct *exiting = NULL;
27762779 struct rt_mutex_waiter rt_waiter;
27772780 struct futex_hash_bucket *hb;
@@ -2907,23 +2910,8 @@ no_block: · 129 unmodified lines
29072910 if (res)
29082911 ret = (res < 0) ? res : 0;
29092912
2910− /*
2911− * If fixup_owner() faulted and was unable to handle the fault, unlock
2912− * it and return the fault to userspace.
2913− */
2914− if (ret && (rt_mutex_owner(&q.pi_state->pi_mutex) == current)) {
2915− pi_state = q.pi_state;
2916− get_pi_state(pi_state);
2917− }
2918−
29192913 /* Unqueue and drop the lock */
29202914 unqueue_me_pi(&q);
2921−
2922− if (pi_state) {
2923− rt_mutex_futex_unlock(&pi_state->pi_mutex);
2924− put_pi_state(pi_state);
2925− }
2926−
29272915 goto out;
29282916
29292917 out_unlock_put_key:
@@ -3183,7 +3171,6 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags, · 253 unmodified lines
31833171 u32 __user *uaddr2)
31843172 {
31853173 struct hrtimer_sleeper timeout, *to;
3186− struct futex_pi_state *pi_state = NULL;
31873174 struct rt_mutex_waiter rt_waiter;
31883175 struct futex_hash_bucket *hb;
31893176 union futex_key key2 = FUTEX_KEY_INIT;
@@ -3261,16 +3248,17 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags, · 71 unmodified lines
32613248 if (q.pi_state && (q.pi_state->owner != current)) {
32623249 spin_lock(q.lock_ptr);
32633250 ret = fixup_pi_state_owner(uaddr2, &q, current);
3264− if (ret && rt_mutex_owner(&q.pi_state->pi_mutex) == current) {
3265− pi_state = q.pi_state;
3266− get_pi_state(pi_state);
3267− }
32683251 /*
32693252 * Drop the reference to the pi state which
32703253 * the requeue_pi() code acquired for us.
32713254 */
32723255 put_pi_state(q.pi_state);
32733256 spin_unlock(q.lock_ptr);
3257+ /*
3258+ * Adjust the return value. It's either -EFAULT or
3259+ * success (1) but the caller expects 0 for success.
3260+ */
3261+ ret = ret < 0 ? ret : 0;
32743262 }
32753263 } else {
32763264 struct rt_mutex *pi_mutex;
@@ -3301,25 +3289,10 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags, · 24 unmodified lines
33013289 if (res)
33023290 ret = (res < 0) ? res : 0;
33033291
3304− /*
3305− * If fixup_pi_state_owner() faulted and was unable to handle
3306− * the fault, unlock the rt_mutex and return the fault to
3307− * userspace.
3308− */
3309− if (ret && rt_mutex_owner(&q.pi_state->pi_mutex) == current) {
3310− pi_state = q.pi_state;
3311− get_pi_state(pi_state);
3312− }
3313−
33143292 /* Unqueue and drop the lock. */
33153293 unqueue_me_pi(&q);
33163294 }
33173295
3318− if (pi_state) {
3319− rt_mutex_futex_unlock(&pi_state->pi_mutex);
3320− put_pi_state(pi_state);
3321− }
3322−
33233296 if (ret == -EINTR) {
33243297 /*
33253298 * We've already been requeued, but cannot restart by calling
kernel/gcov/Kconfig+1−1
@@ -4,7 +4,7 @@ menu "GCOV-based kernel profiling" · 3 unmodified lines
44 config GCOV_KERNEL
55 bool "Enable gcov-based kernel profiling"
66 depends on DEBUG_FS
7− select CONSTRUCTORS if !UML
7+ select CONSTRUCTORS
88 default n
99 help
1010 This option enables gcov-based code profiling (e.g. for code coverage
kernel/irq/manage.c+1−0
@@ -2859,3 +2859,4 @@ bool irq_check_status_bit(unsigned int irq, unsigned int bitmask) · 2858 unmodified lines
28592859 rcu_read_unlock();
28602860 return res;
28612861 }
2862+EXPORT_SYMBOL_GPL(irq_check_status_bit);
kernel/irq/msi.c+21−25
@@ -402,7 +402,7 @@ int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, · 401 unmodified lines
402402 struct msi_domain_ops *ops = info->ops;
403403 struct irq_data *irq_data;
404404 struct msi_desc *desc;
405− msi_alloc_info_t arg;
405+ msi_alloc_info_t arg = { };
406406 int i, ret, virq;
407407 bool can_reserve;
408408
@@ -436,22 +436,22 @@ int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, · 27 unmodified lines
436436
437437 can_reserve = msi_check_reservation_mode(domain, info, dev);
438438
439− for_each_msi_entry(desc, dev) {
440− virq = desc->irq;
441− if (desc->nvec_used == 1)
442− dev_dbg(dev, "irq %d for MSI\n", virq);
443− else
439+ /*
440+ * This flag is set by the PCI layer as we need to activate
441+ * the MSI entries before the PCI layer enables MSI in the
442+ * card. Otherwise the card latches a random msi message.
443+ */
444+ if (!(info->flags & MSI_FLAG_ACTIVATE_EARLY))
445+ goto skip_activate;
446+
447+ for_each_msi_vector(desc, i, dev) {
448+ if (desc->irq == i) {
449+ virq = desc->irq;
444450 dev_dbg(dev, "irq [%d-%d] for MSI\n",
445451 virq, virq + desc->nvec_used - 1);
446− /*
447− * This flag is set by the PCI layer as we need to activate
448− * the MSI entries before the PCI layer enables MSI in the
449− * card. Otherwise the card latches a random msi message.
450− */
451− if (!(info->flags & MSI_FLAG_ACTIVATE_EARLY))
452− continue;
452+ }
453453
454− irq_data = irq_domain_get_irq_data(domain, desc->irq);
454+ irq_data = irq_domain_get_irq_data(domain, i);
455455 if (!can_reserve) {
456456 irqd_clr_can_reserve(irq_data);
457457 if (domain->flags & IRQ_DOMAIN_MSI_NOMASK_QUIRK)
@@ -462,28 +462,24 @@ int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, · 4 unmodified lines
462462 goto cleanup;
463463 }
464464
465+skip_activate:
465466 /*
466467 * If these interrupts use reservation mode, clear the activated bit
467468 * so request_irq() will assign the final vector.
468469 */
469470 if (can_reserve) {
470− for_each_msi_entry(desc, dev) {
471− irq_data = irq_domain_get_irq_data(domain, desc->irq);
471+ for_each_msi_vector(desc, i, dev) {
472+ irq_data = irq_domain_get_irq_data(domain, i);
472473 irqd_clr_activated(irq_data);
473474 }
474475 }
475476 return 0;
476477
477478 cleanup:
478− for_each_msi_entry(desc, dev) {
479− struct irq_data *irqd;
480−
481− if (desc->irq == virq)
482− break;
483−
484− irqd = irq_domain_get_irq_data(domain, desc->irq);
485− if (irqd_is_activated(irqd))
486− irq_domain_deactivate_irq(irqd);
479+ for_each_msi_vector(desc, i, dev) {
480+ irq_data = irq_domain_get_irq_data(domain, i);
481+ if (irqd_is_activated(irq_data))
482+ irq_domain_deactivate_irq(irq_data);
487483 }
488484 msi_domain_free_irqs(domain, dev);
489485 return ret;
kernel/kexec_core.c+0−2
@@ -1134,7 +1134,6 @@ int kernel_kexec(void) · 1133 unmodified lines
11341134
11351135 #ifdef CONFIG_KEXEC_JUMP
11361136 if (kexec_image->preserve_context) {
1137− lock_system_sleep();
11381137 pm_prepare_console();
11391138 error = freeze_processes();
11401139 if (error) {
@@ -1197,7 +1196,6 @@ int kernel_kexec(void) · 56 unmodified lines
11971196 thaw_processes();
11981197 Restore_console:
11991198 pm_restore_console();
1200− unlock_system_sleep();
12011199 }
12021200 #endif
12031201
kernel/kprobes.c+28−8
@@ -1954,28 +1954,48 @@ bool __weak arch_kprobe_on_func_entry(unsigned long offset) · 1953 unmodified lines
19541954 return !offset;
19551955 }
19561956
1957−bool kprobe_on_func_entry(kprobe_opcode_t *addr, const char *sym, unsigned long offset)
1957+/**
1958+ * kprobe_on_func_entry() -- check whether given address is function entry
1959+ * @addr: Target address
1960+ * @sym: Target symbol name
1961+ * @offset: The offset from the symbol or the address
1962+ *
1963+ * This checks whether the given @addr+@offset or @sym+@offset is on the
1964+ * function entry address or not.
1965+ * This returns 0 if it is the function entry, or -EINVAL if it is not.
1966+ * And also it returns -ENOENT if it fails the symbol or address lookup.
1967+ * Caller must pass @addr or @sym (either one must be NULL), or this
1968+ * returns -EINVAL.
1969+ */
1970+int kprobe_on_func_entry(kprobe_opcode_t *addr, const char *sym, unsigned long offset)
19581971 {
19591972 kprobe_opcode_t *kp_addr = _kprobe_addr(addr, sym, offset);
19601973
19611974 if (IS_ERR(kp_addr))
1962− return false;
1975+ return PTR_ERR(kp_addr);
19631976
1964− if (!kallsyms_lookup_size_offset((unsigned long)kp_addr, NULL, &offset) ||
1965− !arch_kprobe_on_func_entry(offset))
1966− return false;
1977+ if (!kallsyms_lookup_size_offset((unsigned long)kp_addr, NULL, &offset))
1978+ return -ENOENT;
19671979
1968− return true;
1980+ if (!arch_kprobe_on_func_entry(offset))
1981+ return -EINVAL;
1982+
1983+ return 0;
19691984 }
19701985
19711986 int register_kretprobe(struct kretprobe *rp)
19721987 {
1973− int ret = 0;
1988+ int ret;
19741989 struct kretprobe_instance *inst;
19751990 int i;
19761991 void *addr;
19771992
1978− if (!kprobe_on_func_entry(rp->kp.addr, rp->kp.symbol_name, rp->kp.offset))
1993+ ret = kprobe_on_func_entry(rp->kp.addr, rp->kp.symbol_name, rp->kp.offset);
1994+ if (ret)
1995+ return ret;
1996+
1997+ /* If only rp->kp.addr is specified, check reregistering kprobes */
1998+ if (rp->kp.addr && check_kprobe_rereg(&rp->kp))
19791999 return -EINVAL;
19802000
19812001 if (kretprobe_blacklist_size) {
kernel/kthread.c+27−2
@@ -294,7 +294,7 @@ static int kthread(void *_create) · 293 unmodified lines
294294 do_exit(ret);
295295 }
296296
297−/* called from do_fork() to get node information for about to be created task */
297+/* called from kernel_clone() to get node information for about to be created task */
298298 int tsk_fork_get_node(struct task_struct *tsk)
299299 {
300300 #ifdef CONFIG_NUMA
@@ -493,11 +493,36 @@ struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data), · 192 unmodified lines
493493 return p;
494494 kthread_bind(p, cpu);
495495 /* CPU hotplug need to bind once again when unparking the thread. */
496− set_bit(KTHREAD_IS_PER_CPU, &to_kthread(p)->flags);
497496 to_kthread(p)->cpu = cpu;
498497 return p;
499498 }
500499
500+void kthread_set_per_cpu(struct task_struct *k, int cpu)
501+{
502+ struct kthread *kthread = to_kthread(k);
503+ if (!kthread)
504+ return;
505+
506+ WARN_ON_ONCE(!(k->flags & PF_NO_SETAFFINITY));
507+
508+ if (cpu < 0) {
509+ clear_bit(KTHREAD_IS_PER_CPU, &kthread->flags);
510+ return;
511+ }
512+
513+ kthread->cpu = cpu;
514+ set_bit(KTHREAD_IS_PER_CPU, &kthread->flags);
515+}
516+
517+bool kthread_is_per_cpu(struct task_struct *k)
518+{
519+ struct kthread *kthread = to_kthread(k);
520+ if (!kthread)
521+ return false;
522+
523+ return test_bit(KTHREAD_IS_PER_CPU, &kthread->flags);
524+}
525+
501526 /**
502527 * kthread_unpark - unpark a thread created by kthread_create().
503528 * @k: thread created by kthread_create().
kernel/locking/lockdep.c+7−2
@@ -79,7 +79,7 @@ module_param(lock_stat, int, 0644); · 78 unmodified lines
7979 DEFINE_PER_CPU(unsigned int, lockdep_recursion);
8080 EXPORT_PER_CPU_SYMBOL_GPL(lockdep_recursion);
8181
82−static inline bool lockdep_enabled(void)
82+static __always_inline bool lockdep_enabled(void)
8383 {
8484 if (!debug_locks)
8585 return false;
@@ -5271,12 +5271,15 @@ static void __lock_unpin_lock(struct lockdep_map *lock, struct pin_cookie cookie · 5185 unmodified lines
52715271 /*
52725272 * Check whether we follow the irq-flags state precisely:
52735273 */
5274−static void check_flags(unsigned long flags)
5274+static noinstr void check_flags(unsigned long flags)
52755275 {
52765276 #if defined(CONFIG_PROVE_LOCKING) && defined(CONFIG_DEBUG_LOCKDEP)
52775277 if (!debug_locks)
52785278 return;
52795279
5280+ /* Get the warning out.. */
5281+ instrumentation_begin();
5282+
52805283 if (irqs_disabled_flags(flags)) {
52815284 if (DEBUG_LOCKS_WARN_ON(lockdep_hardirqs_enabled())) {
52825285 printk("possible reason: unannotated irqs-off.\n");
@@ -5304,6 +5307,8 @@ static void check_flags(unsigned long flags) · 21 unmodified lines
53045307
53055308 if (!debug_locks)
53065309 print_irqtrace_events(current);
5310+
5311+ instrumentation_end();
53075312 #endif
53085313 }
53095314
kernel/locking/rtmutex.c+1−2
@@ -1716,8 +1716,7 @@ void rt_mutex_init_proxy_locked(struct rt_mutex *lock, · 1715 unmodified lines
17161716 * possible because it belongs to the pi_state which is about to be freed
17171717 * and it is not longer visible to other tasks.
17181718 */
1719−void rt_mutex_proxy_unlock(struct rt_mutex *lock,
1720− struct task_struct *proxy_owner)
1719+void rt_mutex_proxy_unlock(struct rt_mutex *lock)
17211720 {
17221721 debug_rt_mutex_proxy_unlock(lock);
17231722 rt_mutex_set_owner(lock, NULL);
kernel/locking/rtmutex_common.h+1−2
@@ -133,8 +133,7 @@ enum rtmutex_chainwalk { · 132 unmodified lines
133133 extern struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock);
134134 extern void rt_mutex_init_proxy_locked(struct rt_mutex *lock,
135135 struct task_struct *proxy_owner);
136−extern void rt_mutex_proxy_unlock(struct rt_mutex *lock,
137− struct task_struct *proxy_owner);
136+extern void rt_mutex_proxy_unlock(struct rt_mutex *lock);
138137 extern void rt_mutex_init_waiter(struct rt_mutex_waiter *waiter);
139138 extern int __rt_mutex_start_proxy_lock(struct rt_mutex *lock,
140139 struct rt_mutex_waiter *waiter,
kernel/power/swap.c+1−1
@@ -497,10 +497,10 @@ static int swap_writer_finish(struct swap_map_handle *handle, · 496 unmodified lines
497497 unsigned int flags, int error)
498498 {
499499 if (!error) {
500− flush_swap_writer(handle);
501500 pr_info("S");
502501 error = mark_swapfiles(handle, flags);
503502 pr_cont("|\n");
503+ flush_swap_writer(handle);
504504 }
505505
506506 if (error)
kernel/printk/printk.c+29−11
@@ -1291,11 +1291,16 @@ static size_t info_print_prefix(const struct printk_info *info, bool syslog, · 1290 unmodified lines
12911291 * done:
12921292 *
12931293 * - Add prefix for each line.
1294+ * - Drop truncated lines that no longer fit into the buffer.
12941295 * - Add the trailing newline that has been removed in vprintk_store().
1295− * - Drop truncated lines that do not longer fit into the buffer.
1296+ * - Add a string terminator.
1297+ *
1298+ * Since the produced string is always terminated, the maximum possible
1299+ * return value is @r->text_buf_size - 1;
12961300 *
12971301 * Return: The length of the updated/prepared text, including the added
1298− * prefixes and the newline. The dropped line(s) are not counted.
1302+ * prefixes and the newline. The terminator is not counted. The dropped
1303+ * line(s) are not counted.
12991304 */
13001305 static size_t record_print_text(struct printk_record *r, bool syslog,
13011306 bool time)
@@ -1338,26 +1343,31 @@ static size_t record_print_text(struct printk_record *r, bool syslog, · 36 unmodified lines
13381343
13391344 /*
13401345 * Truncate the text if there is not enough space to add the
1341− * prefix and a trailing newline.
1346+ * prefix and a trailing newline and a terminator.
13421347 */
1343− if (len + prefix_len + text_len + 1 > buf_size) {
1348+ if (len + prefix_len + text_len + 1 + 1 > buf_size) {
13441349 /* Drop even the current line if no space. */
1345− if (len + prefix_len + line_len + 1 > buf_size)
1350+ if (len + prefix_len + line_len + 1 + 1 > buf_size)
13461351 break;
13471352
1348− text_len = buf_size - len - prefix_len - 1;
1353+ text_len = buf_size - len - prefix_len - 1 - 1;
13491354 truncated = true;
13501355 }
13511356
13521357 memmove(text + prefix_len, text, text_len);
13531358 memcpy(text, prefix, prefix_len);
13541359
1360+ /*
1361+ * Increment the prepared length to include the text and
1362+ * prefix that were just moved+copied. Also increment for the
1363+ * newline at the end of this line. If this is the last line,
1364+ * there is no newline, but it will be added immediately below.
1365+ */
13551366 len += prefix_len + line_len + 1;
1356−
13571367 if (text_len == line_len) {
13581368 /*
1359− * Add the trailing newline removed in
1360− * vprintk_store().
1369+ * This is the last line. Add the trailing newline
1370+ * removed in vprintk_store().
13611371 */
13621372 text[prefix_len + line_len] = '\n';
13631373 break;
@@ -1382,6 +1392,14 @@ static size_t record_print_text(struct printk_record *r, bool syslog, · 18 unmodified lines
13821392 text_len -= line_len + 1;
13831393 }
13841394
1395+ /*
1396+ * If a buffer was provided, it will be terminated. Space for the
1397+ * string terminator is guaranteed to be available. The terminator is
1398+ * not counted in the return value.
1399+ */
1400+ if (buf_size > 0)
1401+ r->text_buf[len] = 0;
1402+
13851403 return len;
13861404 }
13871405
@@ -3427,7 +3445,7 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog, · 2039 unmodified lines
34273445 while (prb_read_valid_info(prb, seq, &info, &line_count)) {
34283446 if (r.info->seq >= dumper->next_seq)
34293447 break;
3430− l += get_record_print_text_size(&info, line_count, true, time);
3448+ l += get_record_print_text_size(&info, line_count, syslog, time);
34313449 seq = r.info->seq + 1;
34323450 }
34333451
@@ -3437,7 +3455,7 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog, · 3 unmodified lines
34373455 &info, &line_count)) {
34383456 if (r.info->seq >= dumper->next_seq)
34393457 break;
3440− l -= get_record_print_text_size(&info, line_count, true, time);
3458+ l -= get_record_print_text_size(&info, line_count, syslog, time);
34413459 seq = r.info->seq + 1;
34423460 }
34433461
kernel/printk/printk_ringbuffer.c+1−1
@@ -1718,7 +1718,7 @@ static bool copy_data(struct prb_data_ring *data_ring, · 1717 unmodified lines
17181718
17191719 /* Caller interested in the line count? */
17201720 if (line_count)
1721− *line_count = count_lines(data, data_size);
1721+ *line_count = count_lines(data, len);
17221722
17231723 /* Caller interested in the data content? */
17241724 if (!buf || !buf_size)
kernel/rcu/tasks.h+21−4
@@ -241,7 +241,7 @@ static int __noreturn rcu_tasks_kthread(void *arg) · 240 unmodified lines
241241 }
242242 }
243243
244−/* Spawn RCU-tasks grace-period kthread, e.g., at core_initcall() time. */
244+/* Spawn RCU-tasks grace-period kthread. */
245245 static void __init rcu_spawn_tasks_kthread_generic(struct rcu_tasks *rtp)
246246 {
247247 struct task_struct *t;
@@ -564,7 +564,6 @@ static int __init rcu_spawn_tasks_kthread(void) · 316 unmodified lines
564564 rcu_spawn_tasks_kthread_generic(&rcu_tasks);
565565 return 0;
566566 }
567−core_initcall(rcu_spawn_tasks_kthread);
568567
569568 #if !defined(CONFIG_TINY_RCU)
570569 void show_rcu_tasks_classic_gp_kthread(void)
@@ -692,7 +691,6 @@ static int __init rcu_spawn_tasks_rude_kthread(void) · 121 unmodified lines
692691 rcu_spawn_tasks_kthread_generic(&rcu_tasks_rude);
693692 return 0;
694693 }
695−core_initcall(rcu_spawn_tasks_rude_kthread);
696694
697695 #if !defined(CONFIG_TINY_RCU)
698696 void show_rcu_tasks_rude_gp_kthread(void)
@@ -968,6 +966,11 @@ static void rcu_tasks_trace_pregp_step(void) · 269 unmodified lines
968966 static void rcu_tasks_trace_pertask(struct task_struct *t,
969967 struct list_head *hop)
970968 {
969+ // During early boot when there is only the one boot CPU, there
970+ // is no idle task for the other CPUs. Just return.
971+ if (unlikely(t == NULL))
972+ return;
973+
971974 WRITE_ONCE(t->trc_reader_special.b.need_qs, false);
972975 WRITE_ONCE(t->trc_reader_checked, false);
973976 t->trc_ipi_to_cpu = -1;
@@ -1193,7 +1196,6 @@ static int __init rcu_spawn_tasks_trace_kthread(void) · 219 unmodified lines
11931196 rcu_spawn_tasks_kthread_generic(&rcu_tasks_trace);
11941197 return 0;
11951198 }
1196−core_initcall(rcu_spawn_tasks_trace_kthread);
11971199
11981200 #if !defined(CONFIG_TINY_RCU)
11991201 void show_rcu_tasks_trace_gp_kthread(void)
@@ -1222,6 +1224,21 @@ void show_rcu_tasks_gp_kthreads(void) · 22 unmodified lines
12221224 }
12231225 #endif /* #ifndef CONFIG_TINY_RCU */
12241226
1227+void __init rcu_init_tasks_generic(void)
1228+{
1229+#ifdef CONFIG_TASKS_RCU
1230+ rcu_spawn_tasks_kthread();
1231+#endif
1232+
1233+#ifdef CONFIG_TASKS_RUDE_RCU
1234+ rcu_spawn_tasks_rude_kthread();
1235+#endif
1236+
1237+#ifdef CONFIG_TASKS_TRACE_RCU
1238+ rcu_spawn_tasks_trace_kthread();
1239+#endif
1240+}
1241+
12251242 #else /* #ifdef CONFIG_TASKS_RCU_GENERIC */
12261243 static inline void rcu_tasks_bootup_oddness(void) {}
12271244 void show_rcu_tasks_gp_kthreads(void) {}
kernel/sched/core.c+88−23
@@ -1796,13 +1796,28 @@ static inline bool rq_has_pinned_tasks(struct rq *rq) · 1795 unmodified lines
17961796 */
17971797 static inline bool is_cpu_allowed(struct task_struct *p, int cpu)
17981798 {
1799+ /* When not in the task's cpumask, no point in looking further. */
17991800 if (!cpumask_test_cpu(cpu, p->cpus_ptr))
18001801 return false;
18011802
1802− if (is_per_cpu_kthread(p) || is_migration_disabled(p))
1803+ /* migrate_disabled() must be allowed to finish. */
1804+ if (is_migration_disabled(p))
18031805 return cpu_online(cpu);
18041806
1805− return cpu_active(cpu);
1807+ /* Non kernel threads are not allowed during either online or offline. */
1808+ if (!(p->flags & PF_KTHREAD))
1809+ return cpu_active(cpu);
1810+
1811+ /* KTHREAD_IS_PER_CPU is always allowed. */
1812+ if (kthread_is_per_cpu(p))
1813+ return cpu_online(cpu);
1814+
1815+ /* Regular kernel threads don't get to stay during offline. */
1816+ if (cpu_rq(cpu)->balance_push)
1817+ return false;
1818+
1819+ /* But are allowed during online. */
1820+ return cpu_online(cpu);
18061821 }
18071822
18081823 /*
@@ -2327,7 +2342,9 @@ static int __set_cpus_allowed_ptr(struct task_struct *p, · 518 unmodified lines
23272342
23282343 if (p->flags & PF_KTHREAD || is_migration_disabled(p)) {
23292344 /*
2330− * Kernel threads are allowed on online && !active CPUs.
2345+ * Kernel threads are allowed on online && !active CPUs,
2346+ * however, during cpu-hot-unplug, even these might get pushed
2347+ * away if not KTHREAD_IS_PER_CPU.
23312348 *
23322349 * Specifically, migration_disabled() tasks must not fail the
23332350 * cpumask_any_and_distribute() pick below, esp. so on
@@ -2371,16 +2388,6 @@ static int __set_cpus_allowed_ptr(struct task_struct *p, · 37 unmodified lines
23712388
23722389 __do_set_cpus_allowed(p, new_mask, flags);
23732390
2374− if (p->flags & PF_KTHREAD) {
2375− /*
2376− * For kernel threads that do indeed end up on online &&
2377− * !active we want to ensure they are strict per-CPU threads.
2378− */
2379− WARN_ON(cpumask_intersects(new_mask, cpu_online_mask) &&
2380− !cpumask_intersects(new_mask, cpu_active_mask) &&
2381− p->nr_cpus_allowed != 1);
2382− }
2383−
23842391 return affine_move_task(rq, p, &rf, dest_cpu, flags);
23852392
23862393 out:
@@ -3121,6 +3128,13 @@ bool cpus_share_cache(int this_cpu, int that_cpu) · 734 unmodified lines
31213128
31223129 static inline bool ttwu_queue_cond(int cpu, int wake_flags)
31233130 {
3131+ /*
3132+ * Do not complicate things with the async wake_list while the CPU is
3133+ * in hotplug state.
3134+ */
3135+ if (!cpu_active(cpu))
3136+ return false;
3137+
31243138 /*
31253139 * If the CPU does not share cache, then queue the task on the
31263140 * remote rqs wakelist to avoid accessing remote data.
@@ -7390,8 +7404,14 @@ static void balance_push(struct rq *rq) · 4263 unmodified lines
73907404 /*
73917405 * Both the cpu-hotplug and stop task are in this case and are
73927406 * required to complete the hotplug process.
7407+ *
7408+ * XXX: the idle task does not match kthread_is_per_cpu() due to
7409+ * histerical raisins.
73937410 */
7394− if (is_per_cpu_kthread(push_task) || is_migration_disabled(push_task)) {
7411+ if (rq->idle == push_task ||
7412+ ((push_task->flags & PF_KTHREAD) && kthread_is_per_cpu(push_task)) ||
7413+ is_migration_disabled(push_task)) {
7414+
73957415 /*
73967416 * If this is the idle task on the outgoing CPU try to wake
73977417 * up the hotplug control thread which might wait for the
@@ -7423,7 +7443,7 @@ static void balance_push(struct rq *rq) · 25 unmodified lines
74237443 /*
74247444 * At this point need_resched() is true and we'll take the loop in
74257445 * schedule(). The next pick is obviously going to be the stop task
7426− * which is_per_cpu_kthread() and will push this task away.
7446+ * which kthread_is_per_cpu() and will push this task away.
74277447 */
74287448 raw_spin_lock(&rq->lock);
74297449 }
@@ -7434,10 +7454,13 @@ static void balance_push_set(int cpu, bool on) · 4 unmodified lines
74347454 struct rq_flags rf;
74357455
74367456 rq_lock_irqsave(rq, &rf);
7437− if (on)
7457+ rq->balance_push = on;
7458+ if (on) {
7459+ WARN_ON_ONCE(rq->balance_callback);
74387460 rq->balance_callback = &balance_push_callback;
7439− else
7461+ } else if (rq->balance_callback == &balance_push_callback) {
74407462 rq->balance_callback = NULL;
7463+ }
74417464 rq_unlock_irqrestore(rq, &rf);
74427465 }
74437466
@@ -7555,6 +7578,10 @@ int sched_cpu_activate(unsigned int cpu) · 111 unmodified lines
75557578 struct rq *rq = cpu_rq(cpu);
75567579 struct rq_flags rf;
75577580
7581+ /*
7582+ * Make sure that when the hotplug state machine does a roll-back
7583+ * we clear balance_push. Ideally that would happen earlier...
7584+ */
75587585 balance_push_set(cpu, false);
75597586
75607587 #ifdef CONFIG_SCHED_SMT
@@ -7603,17 +7630,27 @@ int sched_cpu_deactivate(unsigned int cpu) · 42 unmodified lines
76037630 nohz_balance_exit_idle(rq);
76047631
76057632 set_cpu_active(cpu, false);
7633+
7634+ /*
7635+ * From this point forward, this CPU will refuse to run any task that
7636+ * is not: migrate_disable() or KTHREAD_IS_PER_CPU, and will actively
7637+ * push those tasks away until this gets cleared, see
7638+ * sched_cpu_dying().
7639+ */
7640+ balance_push_set(cpu, true);
7641+
76067642 /*
7607− * We've cleared cpu_active_mask, wait for all preempt-disabled and RCU
7608− * users of this state to go away such that all new such users will
7609− * observe it.
7643+ * We've cleared cpu_active_mask / set balance_push, wait for all
7644+ * preempt-disabled and RCU users of this state to go away such that
7645+ * all new such users will observe it.
7646+ *
7647+ * Specifically, we rely on ttwu to no longer target this CPU, see
7648+ * ttwu_queue_cond() and is_cpu_allowed().
76107649 *
76117650 * Do sync before park smpboot threads to take care the rcu boost case.
76127651 */
76137652 synchronize_rcu();
76147653
7615− balance_push_set(cpu, true);
7616−
76177654 rq_lock_irqsave(rq, &rf);
76187655 if (rq->rd) {
76197656 update_rq_clock(rq);
@@ -7694,6 +7731,25 @@ static void calc_load_migrate(struct rq *rq) · 74 unmodified lines
76947731 atomic_long_add(delta, &calc_load_tasks);
76957732 }
76967733
7734+static void dump_rq_tasks(struct rq *rq, const char *loglvl)
7735+{
7736+ struct task_struct *g, *p;
7737+ int cpu = cpu_of(rq);
7738+
7739+ lockdep_assert_held(&rq->lock);
7740+
7741+ printk("%sCPU%d enqueued tasks (%u total):\n", loglvl, cpu, rq->nr_running);
7742+ for_each_process_thread(g, p) {
7743+ if (task_cpu(p) != cpu)
7744+ continue;
7745+
7746+ if (!task_on_rq_queued(p))
7747+ continue;
7748+
7749+ printk("%s\tpid: %d, name: %s\n", loglvl, p->pid, p->comm);
7750+ }
7751+}
7752+
76977753 int sched_cpu_dying(unsigned int cpu)
76987754 {
76997755 struct rq *rq = cpu_rq(cpu);
@@ -7703,9 +7759,18 @@ int sched_cpu_dying(unsigned int cpu) · 3 unmodified lines
77037759 sched_tick_stop(cpu);
77047760
77057761 rq_lock_irqsave(rq, &rf);
7706− BUG_ON(rq->nr_running != 1 || rq_has_pinned_tasks(rq));
7762+ if (rq->nr_running != 1 || rq_has_pinned_tasks(rq)) {
7763+ WARN(true, "Dying CPU not properly vacated!");
7764+ dump_rq_tasks(rq, KERN_WARNING);
7765+ }
77077766 rq_unlock_irqrestore(rq, &rf);
77087767
7768+ /*
7769+ * Now that the CPU is offline, make sure we're welcome
7770+ * to new tasks once we come back up.
7771+ */
7772+ balance_push_set(cpu, false);
7773+
77097774 calc_load_migrate(rq);
77107775 update_max_interval();
77117776 hrtick_clear(rq);
kernel/sched/sched.h+1−0
@@ -975,6 +975,7 @@ struct rq { · 974 unmodified lines
975975 unsigned long cpu_capacity_orig;
976976
977977 struct callback_head *balance_callback;
978+ unsigned char balance_push;
978979
979980 unsigned char nohz_idle_balance;
980981 unsigned char idle_balance;
kernel/signal.c+5−1
@@ -2550,6 +2550,9 @@ bool get_signal(struct ksignal *ksig) · 2549 unmodified lines
25502550 struct signal_struct *signal = current->signal;
25512551 int signr;
25522552
2553+ if (unlikely(current->task_works))
2554+ task_work_run();
2555+
25532556 /*
25542557 * For non-generic architectures, check for TIF_NOTIFY_SIGNAL so
25552558 * that the arch handlers don't all have to do it. If we get here
@@ -3701,7 +3704,8 @@ static bool access_pidfd_pidns(struct pid *pid) · 1145 unmodified lines
37013704 return true;
37023705 }
37033706
3704−static int copy_siginfo_from_user_any(kernel_siginfo_t *kinfo, siginfo_t *info)
3707+static int copy_siginfo_from_user_any(kernel_siginfo_t *kinfo,
3708+ siginfo_t __user *info)
37053709 {
37063710 #ifdef CONFIG_COMPAT
37073711 /*
kernel/smpboot.c+1−0
@@ -188,6 +188,7 @@ __smpboot_create_thread(struct smp_hotplug_thread *ht, unsigned int cpu) · 187 unmodified lines
188188 kfree(td);
189189 return PTR_ERR(tsk);
190190 }
191+ kthread_set_per_cpu(tsk, cpu);
191192 /*
192193 * Park the thread so that it could start right on the CPU
193194 * when it is available.
kernel/time/ntp.c+4−4
@@ -498,11 +498,11 @@ out: · 497 unmodified lines
498498 static void sync_hw_clock(struct work_struct *work);
499499 static DECLARE_WORK(sync_work, sync_hw_clock);
500500 static struct hrtimer sync_hrtimer;
501−#define SYNC_PERIOD_NS (11UL * 60 * NSEC_PER_SEC)
501+#define SYNC_PERIOD_NS (11ULL * 60 * NSEC_PER_SEC)
502502
503503 static enum hrtimer_restart sync_timer_callback(struct hrtimer *timer)
504504 {
505− queue_work(system_power_efficient_wq, &sync_work);
505+ queue_work(system_freezable_power_efficient_wq, &sync_work);
506506
507507 return HRTIMER_NORESTART;
508508 }
@@ -512,7 +512,7 @@ static void sched_sync_hw_clock(unsigned long offset_nsec, bool retry) · 3 unmodified lines
512512 ktime_t exp = ktime_set(ktime_get_real_seconds(), 0);
513513
514514 if (retry)
515− exp = ktime_add_ns(exp, 2 * NSEC_PER_SEC - offset_nsec);
515+ exp = ktime_add_ns(exp, 2ULL * NSEC_PER_SEC - offset_nsec);
516516 else
517517 exp = ktime_add_ns(exp, SYNC_PERIOD_NS - offset_nsec);
518518
@@ -668,7 +668,7 @@ void ntp_notify_cmos_timer(void) · 149 unmodified lines
668668 * just a pointless work scheduled.
669669 */
670670 if (ntp_synced() && !hrtimer_is_queued(&sync_hrtimer))
671− queue_work(system_power_efficient_wq, &sync_work);
671+ queue_work(system_freezable_power_efficient_wq, &sync_work);
672672 }
673673
674674 static void __init ntp_init_cmos_sync(void)
kernel/time/timekeeping.c+1−2
@@ -991,8 +991,7 @@ EXPORT_SYMBOL_GPL(ktime_get_seconds); · 990 unmodified lines
991991 /**
992992 * ktime_get_real_seconds - Get the seconds portion of CLOCK_REALTIME
993993 *
994− * Returns the wall clock seconds since 1970. This replaces the
995− * get_seconds() interface which is not y2038 safe on 32bit systems.
994+ * Returns the wall clock seconds since 1970.
996995 *
997996 * For 64bit systems the fast access to tk->xtime_sec is preserved. On
998997 * 32bit systems the access must be protected with the sequence
kernel/trace/Kconfig+1−1
@@ -538,7 +538,7 @@ config KPROBE_EVENTS · 537 unmodified lines
538538 config KPROBE_EVENTS_ON_NOTRACE
539539 bool "Do NOT protect notrace function from kprobe events"
540540 depends on KPROBE_EVENTS
541− depends on KPROBES_ON_FTRACE
541+ depends on DYNAMIC_FTRACE
542542 default n
543543 help
544544 This is only for the developers who want to debug ftrace itself
kernel/trace/bpf_trace.c+0−3
@@ -96,9 +96,6 @@ unsigned int trace_call_bpf(struct trace_event_call *call, void *ctx) · 95 unmodified lines
9696 {
9797 unsigned int ret;
9898
99− if (in_nmi()) /* not supported yet */
100− return 1;
101−
10299 cant_sleep();
103100
104101 if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1)) {
kernel/trace/fgraph.c+0−2
@@ -394,7 +394,6 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list) · 393 unmodified lines
394394 }
395395
396396 if (t->ret_stack == NULL) {
397− atomic_set(&t->tracing_graph_pause, 0);
398397 atomic_set(&t->trace_overrun, 0);
399398 t->curr_ret_stack = -1;
400399 t->curr_ret_depth = -1;
@@ -489,7 +488,6 @@ static DEFINE_PER_CPU(struct ftrace_ret_stack *, idle_ret_stack); · 88 unmodified lines
489488 static void
490489 graph_init_task(struct task_struct *t, struct ftrace_ret_stack *ret_stack)
491490 {
492− atomic_set(&t->tracing_graph_pause, 0);
493491 atomic_set(&t->trace_overrun, 0);
494492 t->ftrace_timestamp = 0;
495493 /* make curr_ret_stack visible before we add the ret_stack */
kernel/trace/trace.c+1−1
@@ -2745,7 +2745,7 @@ trace_event_buffer_lock_reserve(struct trace_buffer **current_rb, · 2744 unmodified lines
27452745 (entry = this_cpu_read(trace_buffered_event))) {
27462746 /* Try to use the per cpu buffer first */
27472747 val = this_cpu_inc_return(trace_buffered_event_cnt);
2748− if (val == 1) {
2748+ if ((len < (PAGE_SIZE - sizeof(*entry))) && val == 1) {
27492749 trace_event_setup(entry, type, flags, pc);
27502750 entry->array[0] = len;
27512751 return entry;
kernel/trace/trace_events.c+2−1
@@ -1212,7 +1212,8 @@ system_enable_read(struct file *filp, char __user *ubuf, size_t cnt, · 1211 unmodified lines
12121212 mutex_lock(&event_mutex);
12131213 list_for_each_entry(file, &tr->events, list) {
12141214 call = file->event_call;
1215− if (!trace_event_name(call) || !call->class || !call->class->reg)
1215+ if ((call->flags & TRACE_EVENT_FL_IGNORE_ENABLE) ||
1216+ !trace_event_name(call) || !call->class || !call->class->reg)
12161217 continue;
12171218
12181219 if (system && strcmp(call->class->system, system->name) != 0)
kernel/trace/trace_irqsoff.c+4−0
@@ -562,6 +562,8 @@ static int __irqsoff_tracer_init(struct trace_array *tr) · 561 unmodified lines
562562 /* non overwrite screws up the latency tracers */
563563 set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1);
564564 set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, 1);
565+ /* without pause, we will produce garbage if another latency occurs */
566+ set_tracer_flag(tr, TRACE_ITER_PAUSE_ON_TRACE, 1);
565567
566568 tr->max_latency = 0;
567569 irqsoff_trace = tr;
@@ -583,11 +585,13 @@ static void __irqsoff_tracer_reset(struct trace_array *tr) · 15 unmodified lines
583585 {
584586 int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT;
585587 int overwrite_flag = save_flags & TRACE_ITER_OVERWRITE;
588+ int pause_flag = save_flags & TRACE_ITER_PAUSE_ON_TRACE;
586589
587590 stop_irqsoff_tracer(tr, is_graph(tr));
588591
589592 set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, lat_flag);
590593 set_tracer_flag(tr, TRACE_ITER_OVERWRITE, overwrite_flag);
594+ set_tracer_flag(tr, TRACE_ITER_PAUSE_ON_TRACE, pause_flag);
591595 ftrace_reset_array_ops(tr);
592596
593597 irqsoff_busy = false;
kernel/trace/trace_kprobe.c+7−5
@@ -221,9 +221,9 @@ bool trace_kprobe_on_func_entry(struct trace_event_call *call) · 220 unmodified lines
221221 {
222222 struct trace_kprobe *tk = trace_kprobe_primary_from_call(call);
223223
224− return tk ? kprobe_on_func_entry(tk->rp.kp.addr,
224+ return tk ? (kprobe_on_func_entry(tk->rp.kp.addr,
225225 tk->rp.kp.addr ? NULL : tk->rp.kp.symbol_name,
226− tk->rp.kp.addr ? 0 : tk->rp.kp.offset) : false;
226+ tk->rp.kp.addr ? 0 : tk->rp.kp.offset) == 0) : false;
227227 }
228228
229229 bool trace_kprobe_error_injectable(struct trace_event_call *call)
@@ -434,7 +434,7 @@ static int disable_trace_kprobe(struct trace_event_call *call, · 204 unmodified lines
434434 return 0;
435435 }
436436
437−#if defined(CONFIG_KPROBES_ON_FTRACE) && \
437+#if defined(CONFIG_DYNAMIC_FTRACE) && \
438438 !defined(CONFIG_KPROBE_EVENTS_ON_NOTRACE)
439439 static bool __within_notrace_func(unsigned long addr)
440440 {
@@ -828,9 +828,11 @@ static int trace_kprobe_create(int argc, const char *argv[]) · 387 unmodified lines
828828 }
829829 if (is_return)
830830 flags |= TPARG_FL_RETURN;
831− if (kprobe_on_func_entry(NULL, symbol, offset))
831+ ret = kprobe_on_func_entry(NULL, symbol, offset);
832+ if (ret == 0)
832833 flags |= TPARG_FL_FENTRY;
833− if (offset && is_return && !(flags & TPARG_FL_FENTRY)) {
834+ /* Defer the ENOENT case until register kprobe */
835+ if (ret == -EINVAL && is_return) {
834836 trace_probe_log_err(0, BAD_RETPROBE);
835837 goto parse_error;
836838 }
kernel/workqueue.c+13−9
@@ -1848,12 +1848,6 @@ static void worker_attach_to_pool(struct worker *worker, · 1847 unmodified lines
18481848 {
18491849 mutex_lock(&wq_pool_attach_mutex);
18501850
1851− /*
1852− * set_cpus_allowed_ptr() will fail if the cpumask doesn't have any
1853− * online CPUs. It'll be re-applied when any of the CPUs come up.
1854− */
1855− set_cpus_allowed_ptr(worker->task, pool->attrs->cpumask);
1856−
18571851 /*
18581852 * The wq_pool_attach_mutex ensures %POOL_DISASSOCIATED remains
18591853 * stable across this function. See the comments above the flag
@@ -1861,6 +1855,11 @@ static void worker_attach_to_pool(struct worker *worker, · 1 unmodified line
18611855 */
18621856 if (pool->flags & POOL_DISASSOCIATED)
18631857 worker->flags |= WORKER_UNBOUND;
1858+ else
1859+ kthread_set_per_cpu(worker->task, pool->cpu);
1860+
1861+ if (worker->rescue_wq)
1862+ set_cpus_allowed_ptr(worker->task, pool->attrs->cpumask);
18641863
18651864 list_add_tail(&worker->node, &pool->workers);
18661865 worker->pool = pool;
@@ -1883,6 +1882,7 @@ static void worker_detach_from_pool(struct worker *worker) · 16 unmodified lines
18831882
18841883 mutex_lock(&wq_pool_attach_mutex);
18851884
1885+ kthread_set_per_cpu(worker->task, -1);
18861886 list_del(&worker->node);
18871887 worker->pool = NULL;
18881888
@@ -4919,8 +4919,10 @@ static void unbind_workers(int cpu) · 3030 unmodified lines
49194919
49204920 raw_spin_unlock_irq(&pool->lock);
49214921
4922− for_each_pool_worker(worker, pool)
4923− WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, cpu_active_mask) < 0);
4922+ for_each_pool_worker(worker, pool) {
4923+ kthread_set_per_cpu(worker->task, -1);
4924+ WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, cpu_possible_mask) < 0);
4925+ }
49244926
49254927 mutex_unlock(&wq_pool_attach_mutex);
49264928
@@ -4972,9 +4974,11 @@ static void rebind_workers(struct worker_pool *pool) · 45 unmodified lines
49724974 * of all workers first and then clear UNBOUND. As we're called
49734975 * from CPU_ONLINE, the following shouldn't fail.
49744976 */
4975− for_each_pool_worker(worker, pool)
4977+ for_each_pool_worker(worker, pool) {
4978+ kthread_set_per_cpu(worker->task, pool->cpu);
49764979 WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task,
49774980 pool->attrs->cpumask) < 0);
4981+ }
49784982
49794983 raw_spin_lock_irq(&pool->lock);
49804984

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t