Showing the changes to kernel (47 of 1642 files). Show all
Unified · Split
| @@ -125,8 +125,12 @@ static int bpf_fd_inode_storage_update_elem(struct bpf_map *map, void *key, · 124 unmodified lines | |||
| 125 | 125 | ||
| 126 | fd = *(int *)key; | 126 | fd = *(int *)key; |
| 127 | f = fget_raw(fd); | 127 | 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); | ||
| 129 | return -EBADF; | 132 | return -EBADF; |
| 133 | } | ||
| 130 | 134 | ||
| 131 | sdata = bpf_local_storage_update(f->f_inode, | 135 | sdata = bpf_local_storage_update(f->f_inode, |
| 132 | (struct bpf_local_storage_map *)map, | 136 | (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 | |||
| 176 | * bpf_local_storage_update expects the owner to have a | 180 | * bpf_local_storage_update expects the owner to have a |
| 177 | * valid storage pointer. | 181 | * valid storage pointer. |
| 178 | */ | 182 | */ |
| 179 | if (!inode_storage_ptr(inode)) | 183 | if (!inode || !inode_storage_ptr(inode)) |
| 180 | return (unsigned long)NULL; | 184 | return (unsigned long)NULL; |
| 181 | 185 | ||
| 182 | sdata = inode_storage_lookup(inode, map, true); | 186 | sdata = inode_storage_lookup(inode, map, true); |
| 183 | if (sdata) | 187 | if (sdata) |
| 184 | return (unsigned long)sdata->data; | 188 | return (unsigned long)sdata->data; |
| 185 | 189 | ||
| 186 | /* This helper must only called from where the inode is gurranteed | 190 | /* This helper must only called from where the inode is guaranteed |
| 187 | * to have a refcount and cannot be freed. | 191 | * to have a refcount and cannot be freed. |
| 188 | */ | 192 | */ |
| 189 | if (flags & BPF_LOCAL_STORAGE_GET_F_CREATE) { | 193 | 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 | |||
| 200 | BPF_CALL_2(bpf_inode_storage_delete, | 204 | BPF_CALL_2(bpf_inode_storage_delete, |
| 201 | struct bpf_map *, map, struct inode *, inode) | 205 | struct bpf_map *, map, struct inode *, inode) |
| 202 | { | 206 | { |
| 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 | ||
| 204 | * to have a refcount and cannot be freed. | 211 | * to have a refcount and cannot be freed. |
| 205 | */ | 212 | */ |
| 206 | return inode_storage_delete(inode, map); | 213 | return inode_storage_delete(inode, map); |
| @@ -149,7 +149,11 @@ BTF_ID(func, bpf_lsm_file_ioctl) · 148 unmodified lines | |||
| 149 | BTF_ID(func, bpf_lsm_file_lock) | 149 | BTF_ID(func, bpf_lsm_file_lock) |
| 150 | BTF_ID(func, bpf_lsm_file_open) | 150 | BTF_ID(func, bpf_lsm_file_open) |
| 151 | BTF_ID(func, bpf_lsm_file_receive) | 151 | BTF_ID(func, bpf_lsm_file_receive) |
| 152 | |||
| 153 | #ifdef CONFIG_SECURITY_NETWORK | ||
| 152 | BTF_ID(func, bpf_lsm_inet_conn_established) | 154 | BTF_ID(func, bpf_lsm_inet_conn_established) |
| 155 | #endif /* CONFIG_SECURITY_NETWORK */ | ||
| 156 | |||
| 153 | BTF_ID(func, bpf_lsm_inode_create) | 157 | BTF_ID(func, bpf_lsm_inode_create) |
| 154 | BTF_ID(func, bpf_lsm_inode_free_security) | 158 | BTF_ID(func, bpf_lsm_inode_free_security) |
| 155 | BTF_ID(func, bpf_lsm_inode_getattr) | 159 | BTF_ID(func, bpf_lsm_inode_getattr) |
| @@ -166,7 +170,11 @@ BTF_ID(func, bpf_lsm_inode_symlink) · 10 unmodified lines | |||
| 166 | BTF_ID(func, bpf_lsm_inode_unlink) | 170 | BTF_ID(func, bpf_lsm_inode_unlink) |
| 167 | BTF_ID(func, bpf_lsm_kernel_module_request) | 171 | BTF_ID(func, bpf_lsm_kernel_module_request) |
| 168 | BTF_ID(func, bpf_lsm_kernfs_init_security) | 172 | BTF_ID(func, bpf_lsm_kernfs_init_security) |
| 173 | |||
| 174 | #ifdef CONFIG_KEYS | ||
| 169 | BTF_ID(func, bpf_lsm_key_free) | 175 | BTF_ID(func, bpf_lsm_key_free) |
| 176 | #endif /* CONFIG_KEYS */ | ||
| 177 | |||
| 170 | BTF_ID(func, bpf_lsm_mmap_file) | 178 | BTF_ID(func, bpf_lsm_mmap_file) |
| 171 | BTF_ID(func, bpf_lsm_netlink_send) | 179 | BTF_ID(func, bpf_lsm_netlink_send) |
| 172 | BTF_ID(func, bpf_lsm_path_notify) | 180 | BTF_ID(func, bpf_lsm_path_notify) |
| @@ -181,6 +189,8 @@ BTF_ID(func, bpf_lsm_sb_show_options) · 8 unmodified lines | |||
| 181 | BTF_ID(func, bpf_lsm_sb_statfs) | 189 | BTF_ID(func, bpf_lsm_sb_statfs) |
| 182 | BTF_ID(func, bpf_lsm_sb_umount) | 190 | BTF_ID(func, bpf_lsm_sb_umount) |
| 183 | BTF_ID(func, bpf_lsm_settime) | 191 | BTF_ID(func, bpf_lsm_settime) |
| 192 | |||
| 193 | #ifdef CONFIG_SECURITY_NETWORK | ||
| 184 | BTF_ID(func, bpf_lsm_socket_accept) | 194 | BTF_ID(func, bpf_lsm_socket_accept) |
| 185 | BTF_ID(func, bpf_lsm_socket_bind) | 195 | BTF_ID(func, bpf_lsm_socket_bind) |
| 186 | BTF_ID(func, bpf_lsm_socket_connect) | 196 | BTF_ID(func, bpf_lsm_socket_connect) |
| @@ -195,6 +205,8 @@ BTF_ID(func, bpf_lsm_socket_recvmsg) · 8 unmodified lines | |||
| 195 | BTF_ID(func, bpf_lsm_socket_sendmsg) | 205 | BTF_ID(func, bpf_lsm_socket_sendmsg) |
| 196 | BTF_ID(func, bpf_lsm_socket_shutdown) | 206 | BTF_ID(func, bpf_lsm_socket_shutdown) |
| 197 | BTF_ID(func, bpf_lsm_socket_socketpair) | 207 | BTF_ID(func, bpf_lsm_socket_socketpair) |
| 208 | #endif /* CONFIG_SECURITY_NETWORK */ | ||
| 209 | |||
| 198 | BTF_ID(func, bpf_lsm_syslog) | 210 | BTF_ID(func, bpf_lsm_syslog) |
| 199 | BTF_ID(func, bpf_lsm_task_alloc) | 211 | BTF_ID(func, bpf_lsm_task_alloc) |
| 200 | BTF_ID(func, bpf_lsm_task_getsecid) | 212 | BTF_ID(func, bpf_lsm_task_getsecid) |
| @@ -218,7 +218,7 @@ BPF_CALL_4(bpf_task_storage_get, struct bpf_map *, map, struct task_struct *, · 217 unmodified lines | |||
| 218 | * bpf_local_storage_update expects the owner to have a | 218 | * bpf_local_storage_update expects the owner to have a |
| 219 | * valid storage pointer. | 219 | * valid storage pointer. |
| 220 | */ | 220 | */ |
| 221 | if (!task_storage_ptr(task)) | 221 | if (!task || !task_storage_ptr(task)) |
| 222 | return (unsigned long)NULL; | 222 | return (unsigned long)NULL; |
| 223 | 223 | ||
| 224 | sdata = task_storage_lookup(task, map, true); | 224 | 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 | |||
| 243 | BPF_CALL_2(bpf_task_storage_delete, struct bpf_map *, map, struct task_struct *, | 243 | BPF_CALL_2(bpf_task_storage_delete, struct bpf_map *, map, struct task_struct *, |
| 244 | task) | 244 | task) |
| 245 | { | 245 | { |
| 246 | if (!task) | ||
| 247 | return -EINVAL; | ||
| 248 | |||
| 246 | /* This helper must only be called from places where the lifetime of the task | 249 | /* This helper must only be called from places where the lifetime of the task |
| 247 | * is guaranteed. Either by being refcounted or by being protected | 250 | * is guaranteed. Either by being refcounted or by being protected |
| 248 | * by an RCU read-side critical section. | 251 | * by an RCU read-side critical section. |
| @@ -4172,7 +4172,7 @@ static int btf_parse_hdr(struct btf_verifier_env *env) · 4171 unmodified lines | |||
| 4172 | return -ENOTSUPP; | 4172 | return -ENOTSUPP; |
| 4173 | } | 4173 | } |
| 4174 | 4174 | ||
| 4175 | if (btf_data_size == hdr->hdr_len) { | 4175 | if (!btf->base_btf && btf_data_size == hdr->hdr_len) { |
| 4176 | btf_verifier_log(env, "No data"); | 4176 | btf_verifier_log(env, "No data"); |
| 4177 | return -EINVAL; | 4177 | return -EINVAL; |
| 4178 | } | 4178 | } |
| @@ -1391,12 +1391,13 @@ int __cgroup_bpf_run_filter_setsockopt(struct sock *sk, int *level, · 1390 unmodified lines | |||
| 1391 | if (ctx.optlen != 0) { | 1391 | if (ctx.optlen != 0) { |
| 1392 | *optlen = ctx.optlen; | 1392 | *optlen = ctx.optlen; |
| 1393 | *kernel_optval = ctx.optval; | 1393 | *kernel_optval = ctx.optval; |
| 1394 | /* export and don't free sockopt buf */ | ||
| 1395 | return 0; | ||
| 1394 | } | 1396 | } |
| 1395 | } | 1397 | } |
| 1396 | 1398 | ||
| 1397 | out: | 1399 | out: |
| 1398 | if (ret) | 1400 | sockopt_free_buf(&ctx); |
| 1399 | sockopt_free_buf(&ctx); | ||
| 1400 | return ret; | 1401 | return ret; |
| 1401 | } | 1402 | } |
| 1402 | 1403 | ||
| @@ -1441,6 +1442,11 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level, · 38 unmodified lines | |||
| 1441 | goto out; | 1442 | goto out; |
| 1442 | } | 1443 | } |
| 1443 | 1444 | ||
| 1445 | if (ctx.optlen < 0) { | ||
| 1446 | ret = -EFAULT; | ||
| 1447 | goto out; | ||
| 1448 | } | ||
| 1449 | |||
| 1444 | if (copy_from_user(ctx.optval, optval, | 1450 | if (copy_from_user(ctx.optval, optval, |
| 1445 | min(ctx.optlen, max_optlen)) != 0) { | 1451 | min(ctx.optlen, max_optlen)) != 0) { |
| 1446 | ret = -EFAULT; | 1452 | ret = -EFAULT; |
| @@ -1458,7 +1464,7 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level, · 11 unmodified lines | |||
| 1458 | goto out; | 1464 | goto out; |
| 1459 | } | 1465 | } |
| 1460 | 1466 | ||
| 1461 | if (ctx.optlen > max_optlen) { | 1467 | if (ctx.optlen > max_optlen || ctx.optlen < 0) { |
| 1462 | ret = -EFAULT; | 1468 | ret = -EFAULT; |
| 1463 | goto out; | 1469 | goto out; |
| 1464 | } | 1470 | } |
| @@ -152,6 +152,7 @@ static void htab_init_buckets(struct bpf_htab *htab) · 151 unmodified lines | |||
| 152 | lockdep_set_class(&htab->buckets[i].lock, | 152 | lockdep_set_class(&htab->buckets[i].lock, |
| 153 | &htab->lockdep_key); | 153 | &htab->lockdep_key); |
| 154 | } | 154 | } |
| 155 | cond_resched(); | ||
| 155 | } | 156 | } |
| 156 | } | 157 | } |
| 157 | 158 | ||
| @@ -108,7 +108,7 @@ BPF_CALL_2(bpf_map_peek_elem, struct bpf_map *, map, void *, value) · 107 unmodified lines | |||
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | const struct bpf_func_proto bpf_map_peek_elem_proto = { | 110 | const struct bpf_func_proto bpf_map_peek_elem_proto = { |
| 111 | .func = bpf_map_pop_elem, | 111 | .func = bpf_map_peek_elem, |
| 112 | .gpl_only = false, | 112 | .gpl_only = false, |
| 113 | .ret_type = RET_INTEGER, | 113 | .ret_type = RET_INTEGER, |
| 114 | .arg1_type = ARG_CONST_MAP_PTR, | 114 | .arg1_type = ARG_CONST_MAP_PTR, |
| @@ -4,8 +4,11 @@ LIBBPF_SRCS = $(srctree)/tools/lib/bpf/ · 3 unmodified lines | |||
| 4 | LIBBPF_A = $(obj)/libbpf.a | 4 | LIBBPF_A = $(obj)/libbpf.a |
| 5 | LIBBPF_OUT = $(abspath $(obj)) | 5 | LIBBPF_OUT = $(abspath $(obj)) |
| 6 | 6 | ||
| 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". | ||
| 7 | $(LIBBPF_A): | 10 | $(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 |
| 9 | 12 | ||
| 10 | userccflags += -I $(srctree)/tools/include/ -I $(srctree)/tools/include/uapi \ | 13 | userccflags += -I $(srctree)/tools/include/ -I $(srctree)/tools/include/uapi \ |
| 11 | -I $(srctree)/tools/lib/ -Wno-unused-result | 14 | -I $(srctree)/tools/lib/ -Wno-unused-result |
| @@ -115,6 +115,8 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr) · 114 unmodified lines | |||
| 115 | 115 | ||
| 116 | /* hash table size must be power of 2 */ | 116 | /* hash table size must be power of 2 */ |
| 117 | n_buckets = roundup_pow_of_two(attr->max_entries); | 117 | n_buckets = roundup_pow_of_two(attr->max_entries); |
| 118 | if (!n_buckets) | ||
| 119 | return ERR_PTR(-E2BIG); | ||
| 118 | 120 | ||
| 119 | cost = n_buckets * sizeof(struct stack_map_bucket *) + sizeof(*smap); | 121 | cost = n_buckets * sizeof(struct stack_map_bucket *) + sizeof(*smap); |
| 120 | cost += n_buckets * (value_size + sizeof(struct stack_map_bucket)); | 122 | cost += n_buckets * (value_size + sizeof(struct stack_map_bucket)); |
| @@ -17,7 +17,6 @@ · 16 unmodified lines | |||
| 17 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
| 18 | #include <linux/license.h> | 18 | #include <linux/license.h> |
| 19 | #include <linux/filter.h> | 19 | #include <linux/filter.h> |
| 20 | #include <linux/version.h> | ||
| 21 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
| 22 | #include <linux/idr.h> | 21 | #include <linux/idr.h> |
| 23 | #include <linux/cred.h> | 22 | #include <linux/cred.h> |
| @@ -2713,7 +2712,6 @@ out_unlock: · 2689 unmodified lines | |||
| 2713 | out_put_prog: | 2712 | out_put_prog: |
| 2714 | if (tgt_prog_fd && tgt_prog) | 2713 | if (tgt_prog_fd && tgt_prog) |
| 2715 | bpf_prog_put(tgt_prog); | 2714 | bpf_prog_put(tgt_prog); |
| 2716 | bpf_prog_put(prog); | ||
| 2717 | return err; | 2715 | return err; |
| 2718 | } | 2716 | } |
| 2719 | 2717 | ||
| @@ -2826,7 +2824,10 @@ static int bpf_raw_tracepoint_open(const union bpf_attr *attr) · 106 unmodified lines | |||
| 2826 | tp_name = prog->aux->attach_func_name; | 2824 | tp_name = prog->aux->attach_func_name; |
| 2827 | break; | 2825 | break; |
| 2828 | } | 2826 | } |
| 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; | ||
| 2830 | case BPF_PROG_TYPE_RAW_TRACEPOINT: | 2831 | case BPF_PROG_TYPE_RAW_TRACEPOINT: |
| 2831 | case BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE: | 2832 | case BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE: |
| 2832 | if (strncpy_from_user(buf, | 2833 | if (strncpy_from_user(buf, |
| @@ -37,7 +37,7 @@ retry: · 36 unmodified lines | |||
| 37 | if (!task) { | 37 | if (!task) { |
| 38 | ++*tid; | 38 | ++*tid; |
| 39 | goto retry; | 39 | goto retry; |
| 40 | } else if (skip_if_dup_files && task->tgid != task->pid && | 40 | } else if (skip_if_dup_files && !thread_group_leader(task) && |
| 41 | task->files == task->group_leader->files) { | 41 | task->files == task->group_leader->files) { |
| 42 | put_task_struct(task); | 42 | put_task_struct(task); |
| 43 | task = NULL; | 43 | task = NULL; |
| @@ -151,13 +151,14 @@ again: · 107 unmodified lines | |||
| 151 | curr_task = info->task; | 151 | curr_task = info->task; |
| 152 | curr_fd = info->fd; | 152 | curr_fd = info->fd; |
| 153 | } else { | 153 | } else { |
| 154 | curr_task = task_seq_get_next(ns, &curr_tid, true); | 154 | curr_task = task_seq_get_next(ns, &curr_tid, true); |
| 155 | if (!curr_task) { | 155 | if (!curr_task) { |
| 156 | info->task = NULL; | 156 | info->task = NULL; |
| 157 | return NULL; | 157 | info->tid = curr_tid; |
| 158 | } | 158 | return NULL; |
| 159 | 159 | } | |
| 160 | /* set info->task and info->tid */ | 160 | |
| 161 | /* set info->task and info->tid */ | ||
| 161 | info->task = curr_task; | 162 | info->task = curr_task; |
| 162 | if (curr_tid == info->tid) { | 163 | if (curr_tid == info->tid) { |
| 163 | curr_fd = info->fd; | 164 | curr_fd = info->fd; |
| @@ -2217,6 +2217,8 @@ static bool is_spillable_regtype(enum bpf_reg_type type) · 2216 unmodified lines | |||
| 2217 | case PTR_TO_RDWR_BUF: | 2217 | case PTR_TO_RDWR_BUF: |
| 2218 | case PTR_TO_RDWR_BUF_OR_NULL: | 2218 | case PTR_TO_RDWR_BUF_OR_NULL: |
| 2219 | case PTR_TO_PERCPU_BTF_ID: | 2219 | case PTR_TO_PERCPU_BTF_ID: |
| 2220 | case PTR_TO_MEM: | ||
| 2221 | case PTR_TO_MEM_OR_NULL: | ||
| 2220 | return true; | 2222 | return true; |
| 2221 | default: | 2223 | default: |
| 2222 | return false; | 2224 | return false; |
| @@ -5311,7 +5313,7 @@ static bool signed_add_overflows(s64 a, s64 b) · 3088 unmodified lines | |||
| 5311 | return res < a; | 5313 | return res < a; |
| 5312 | } | 5314 | } |
| 5313 | 5315 | ||
| 5314 | static bool signed_add32_overflows(s64 a, s64 b) | 5316 | static bool signed_add32_overflows(s32 a, s32 b) |
| 5315 | { | 5317 | { |
| 5316 | /* Do the add in u32, where overflow is well-defined */ | 5318 | /* Do the add in u32, where overflow is well-defined */ |
| 5317 | s32 res = (s32)((u32)a + (u32)b); | 5319 | s32 res = (s32)((u32)a + (u32)b); |
| @@ -5321,7 +5323,7 @@ static bool signed_add32_overflows(s64 a, s64 b) · 3 unmodified lines | |||
| 5321 | return res < a; | 5323 | return res < a; |
| 5322 | } | 5324 | } |
| 5323 | 5325 | ||
| 5324 | static bool signed_sub_overflows(s32 a, s32 b) | 5326 | static bool signed_sub_overflows(s64 a, s64 b) |
| 5325 | { | 5327 | { |
| 5326 | /* Do the sub in u64, where overflow is well-defined */ | 5328 | /* Do the sub in u64, where overflow is well-defined */ |
| 5327 | s64 res = (s64)((u64)a - (u64)b); | 5329 | s64 res = (s64)((u64)a - (u64)b); |
| @@ -5333,7 +5335,7 @@ static bool signed_sub_overflows(s32 a, s32 b) · 5 unmodified lines | |||
| 5333 | 5335 | ||
| 5334 | static bool signed_sub32_overflows(s32 a, s32 b) | 5336 | static bool signed_sub32_overflows(s32 a, s32 b) |
| 5335 | { | 5337 | { |
| 5336 | /* Do the sub in u64, where overflow is well-defined */ | 5338 | /* Do the sub in u32, where overflow is well-defined */ |
| 5337 | s32 res = (s32)((u32)a - (u32)b); | 5339 | s32 res = (s32)((u32)a - (u32)b); |
| 5338 | 5340 | ||
| 5339 | if (b < 0) | 5341 | if (b < 0) |
| @@ -6875,7 +6877,7 @@ static int is_branch32_taken(struct bpf_reg_state *reg, u32 val, u8 opcode) · 1535 unmodified lines | |||
| 6875 | case BPF_JSGT: | 6877 | case BPF_JSGT: |
| 6876 | if (reg->s32_min_value > sval) | 6878 | if (reg->s32_min_value > sval) |
| 6877 | return 1; | 6879 | return 1; |
| 6878 | else if (reg->s32_max_value < sval) | 6880 | else if (reg->s32_max_value <= sval) |
| 6879 | return 0; | 6881 | return 0; |
| 6880 | break; | 6882 | break; |
| 6881 | case BPF_JLT: | 6883 | case BPF_JLT: |
| @@ -6948,7 +6950,7 @@ static int is_branch64_taken(struct bpf_reg_state *reg, u64 val, u8 opcode) · 66 unmodified lines | |||
| 6948 | case BPF_JSGT: | 6950 | case BPF_JSGT: |
| 6949 | if (reg->smin_value > sval) | 6951 | if (reg->smin_value > sval) |
| 6950 | return 1; | 6952 | return 1; |
| 6951 | else if (reg->smax_value < sval) | 6953 | else if (reg->smax_value <= sval) |
| 6952 | return 0; | 6954 | return 0; |
| 6953 | break; | 6955 | break; |
| 6954 | case BPF_JLT: | 6956 | case BPF_JLT: |
| @@ -8588,7 +8590,11 @@ static bool range_within(struct bpf_reg_state *old, · 1633 unmodified lines | |||
| 8588 | return old->umin_value <= cur->umin_value && | 8590 | return old->umin_value <= cur->umin_value && |
| 8589 | old->umax_value >= cur->umax_value && | 8591 | old->umax_value >= cur->umax_value && |
| 8590 | old->smin_value <= cur->smin_value && | 8592 | 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; | ||
| 8592 | } | 8598 | } |
| 8593 | 8599 | ||
| 8594 | /* Maximum number of register states that can exist at once */ | 8600 | /* 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 | |||
| 10997 | insn->code == (BPF_ALU | BPF_MOD | BPF_X) || | 11003 | insn->code == (BPF_ALU | BPF_MOD | BPF_X) || |
| 10998 | insn->code == (BPF_ALU | BPF_DIV | BPF_X)) { | 11004 | insn->code == (BPF_ALU | BPF_DIV | BPF_X)) { |
| 10999 | bool is64 = BPF_CLASS(insn->code) == BPF_ALU64; | 11005 | bool is64 = BPF_CLASS(insn->code) == BPF_ALU64; |
| 11000 | struct bpf_insn mask_and_div[] = { | 11006 | bool isdiv = BPF_OP(insn->code) == BPF_DIV; |
| 11001 | BPF_MOV32_REG(insn->src_reg, insn->src_reg), | 11007 | struct bpf_insn *patchlet; |
| 11008 | struct bpf_insn chk_and_div[] = { | ||
| 11002 | /* Rx div 0 -> 0 */ | 11009 | /* 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), | ||
| 11004 | BPF_ALU32_REG(BPF_XOR, insn->dst_reg, insn->dst_reg), | 11013 | BPF_ALU32_REG(BPF_XOR, insn->dst_reg, insn->dst_reg), |
| 11005 | BPF_JMP_IMM(BPF_JA, 0, 0, 1), | 11014 | BPF_JMP_IMM(BPF_JA, 0, 0, 1), |
| 11006 | *insn, | 11015 | *insn, |
| 11007 | }; | 11016 | }; |
| 11008 | struct bpf_insn mask_and_mod[] = { | 11017 | struct bpf_insn chk_and_mod[] = { |
| 11009 | BPF_MOV32_REG(insn->src_reg, insn->src_reg), | ||
| 11010 | /* Rx mod 0 -> Rx */ | 11018 | /* 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), | ||
| 11012 | *insn, | 11022 | *insn, |
| 11013 | }; | 11023 | }; |
| 11014 | struct bpf_insn *patchlet; | ||
| 11015 | 11024 | ||
| 11016 | if (insn->code == (BPF_ALU64 | BPF_DIV | BPF_X) || | 11025 | patchlet = isdiv ? chk_and_div : chk_and_mod; |
| 11017 | insn->code == (BPF_ALU | BPF_DIV | BPF_X)) { | 11026 | cnt = isdiv ? ARRAY_SIZE(chk_and_div) : |
| 11018 | patchlet = mask_and_div + (is64 ? 1 : 0); | 11027 | ARRAY_SIZE(chk_and_mod); |
| 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 | } | ||
| 11024 | 11028 | ||
| 11025 | new_prog = bpf_patch_insn_data(env, i + delta, patchlet, cnt); | 11029 | new_prog = bpf_patch_insn_data(env, i + delta, patchlet, cnt); |
| 11026 | if (!new_prog) | 11030 | if (!new_prog) |
| @@ -917,6 +917,9 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param) · 916 unmodified lines | |||
| 917 | for_each_subsys(ss, i) { | 917 | for_each_subsys(ss, i) { |
| 918 | if (strcmp(param->key, ss->legacy_name)) | 918 | if (strcmp(param->key, ss->legacy_name)) |
| 919 | continue; | 919 | continue; |
| 920 | if (!cgroup_ssid_enabled(i) || cgroup1_ssid_disabled(i)) | ||
| 921 | return invalfc(fc, "Disabled controller '%s'", | ||
| 922 | param->key); | ||
| 920 | ctx->subsys_mask |= (1 << i); | 923 | ctx->subsys_mask |= (1 << i); |
| 921 | return 0; | 924 | return 0; |
| 922 | } | 925 | } |
| @@ -3564,6 +3564,7 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of, char *buf, · 3563 unmodified lines | |||
| 3564 | { | 3564 | { |
| 3565 | struct psi_trigger *new; | 3565 | struct psi_trigger *new; |
| 3566 | struct cgroup *cgrp; | 3566 | struct cgroup *cgrp; |
| 3567 | struct psi_group *psi; | ||
| 3567 | 3568 | ||
| 3568 | cgrp = cgroup_kn_lock_live(of->kn, false); | 3569 | cgrp = cgroup_kn_lock_live(of->kn, false); |
| 3569 | if (!cgrp) | 3570 | if (!cgrp) |
| @@ -3572,7 +3573,8 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of, char *buf, · 2 unmodified lines | |||
| 3572 | cgroup_get(cgrp); | 3573 | cgroup_get(cgrp); |
| 3573 | cgroup_kn_unlock(of->kn); | 3574 | cgroup_kn_unlock(of->kn); |
| 3574 | 3575 | ||
| 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); | ||
| 3576 | if (IS_ERR(new)) { | 3578 | if (IS_ERR(new)) { |
| 3577 | cgroup_put(cgrp); | 3579 | cgroup_put(cgrp); |
| 3578 | return PTR_ERR(new); | 3580 | return PTR_ERR(new); |
| @@ -81,7 +81,6 @@ CONFIG_INPUT_JOYSTICK=y · 80 unmodified lines | |||
| 81 | CONFIG_INPUT_MISC=y | 81 | CONFIG_INPUT_MISC=y |
| 82 | CONFIG_INPUT_TABLET=y | 82 | CONFIG_INPUT_TABLET=y |
| 83 | CONFIG_INPUT_UINPUT=y | 83 | CONFIG_INPUT_UINPUT=y |
| 84 | CONFIG_ION=y | ||
| 85 | CONFIG_JOYSTICK_XPAD=y | 84 | CONFIG_JOYSTICK_XPAD=y |
| 86 | CONFIG_JOYSTICK_XPAD_FF=y | 85 | CONFIG_JOYSTICK_XPAD_FF=y |
| 87 | CONFIG_JOYSTICK_XPAD_LEDS=y | 86 | CONFIG_JOYSTICK_XPAD_LEDS=y |
| @@ -36,7 +36,7 @@ struct map_benchmark { · 35 unmodified lines | |||
| 36 | __s32 node; /* which numa node this benchmark will run on */ | 36 | __s32 node; /* which numa node this benchmark will run on */ |
| 37 | __u32 dma_bits; /* DMA addressing capability */ | 37 | __u32 dma_bits; /* DMA addressing capability */ |
| 38 | __u32 dma_dir; /* DMA data direction */ | 38 | __u32 dma_dir; /* DMA data direction */ |
| 39 | __u64 expansion[10]; /* For future use */ | 39 | __u8 expansion[84]; /* For future use */ |
| 40 | }; | 40 | }; |
| 41 | 41 | ||
| 42 | struct map_benchmark_data { | 42 | struct map_benchmark_data { |
| @@ -147,8 +147,10 @@ static int do_map_benchmark(struct map_benchmark_data *map) · 104 unmodified lines | |||
| 147 | atomic64_set(&map->sum_sq_unmap, 0); | 147 | atomic64_set(&map->sum_sq_unmap, 0); |
| 148 | atomic64_set(&map->loops, 0); | 148 | atomic64_set(&map->loops, 0); |
| 149 | 149 | ||
| 150 | for (i = 0; i < threads; i++) | 150 | for (i = 0; i < threads; i++) { |
| 151 | get_task_struct(tsk[i]); | ||
| 151 | wake_up_process(tsk[i]); | 152 | wake_up_process(tsk[i]); |
| 153 | } | ||
| 152 | 154 | ||
| 153 | msleep_interruptible(map->bparam.seconds * 1000); | 155 | msleep_interruptible(map->bparam.seconds * 1000); |
| 154 | 156 | ||
| @@ -183,6 +185,8 @@ static int do_map_benchmark(struct map_benchmark_data *map) · 28 unmodified lines | |||
| 183 | } | 185 | } |
| 184 | 186 | ||
| 185 | out: | 187 | out: |
| 188 | for (i = 0; i < threads; i++) | ||
| 189 | put_task_struct(tsk[i]); | ||
| 186 | put_device(map->dev); | 190 | put_device(map->dev); |
| 187 | kfree(tsk); | 191 | kfree(tsk); |
| 188 | return ret; | 192 | return ret; |
| @@ -209,26 +209,18 @@ static void exit_to_user_mode_prepare(struct pt_regs *regs) · 208 unmodified lines | |||
| 209 | lockdep_sys_exit(); | 209 | lockdep_sys_exit(); |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | #ifndef _TIF_SINGLESTEP | ||
| 213 | static inline bool report_single_step(unsigned long work) | ||
| 214 | { | ||
| 215 | return false; | ||
| 216 | } | ||
| 217 | #else | ||
| 218 | /* | 212 | /* |
| 219 | * If SYSCALL_EMU is set, then the only reason to report is when | 213 | * 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 |
| 221 | * instruction has been already reported in syscall_enter_from_user_mode(). | 215 | * instruction has been already reported in syscall_enter_from_user_mode(). |
| 222 | */ | 216 | */ |
| 223 | static inline bool report_single_step(unsigned long work) | 217 | static inline bool report_single_step(unsigned long work) |
| 224 | { | 218 | { |
| 225 | if (!(work & SYSCALL_WORK_SYSCALL_EMU)) | 219 | if (work & SYSCALL_WORK_SYSCALL_EMU) |
| 226 | return false; | 220 | return false; |
| 227 | 221 | ||
| 228 | return !!(current_thread_info()->flags & _TIF_SINGLESTEP); | 222 | return work & SYSCALL_WORK_SYSCALL_EXIT_TRAP; |
| 229 | } | 223 | } |
| 230 | #endif | ||
| 231 | |||
| 232 | 224 | ||
| 233 | static void syscall_exit_work(struct pt_regs *regs, unsigned long work) | 225 | static void syscall_exit_work(struct pt_regs *regs, unsigned long work) |
| 234 | { | 226 | { |
| @@ -50,10 +50,10 @@ bool syscall_user_dispatch(struct pt_regs *regs) · 49 unmodified lines | |||
| 50 | if (unlikely(__get_user(state, sd->selector))) | 50 | if (unlikely(__get_user(state, sd->selector))) |
| 51 | do_exit(SIGSEGV); | 51 | do_exit(SIGSEGV); |
| 52 | 52 | ||
| 53 | if (likely(state == PR_SYS_DISPATCH_OFF)) | 53 | if (likely(state == SYSCALL_DISPATCH_FILTER_ALLOW)) |
| 54 | return false; | 54 | return false; |
| 55 | 55 | ||
| 56 | if (state != PR_SYS_DISPATCH_ON) | 56 | if (state != SYSCALL_DISPATCH_FILTER_BLOCK) |
| 57 | do_exit(SIGSYS); | 57 | do_exit(SIGSYS); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| @@ -819,9 +819,8 @@ void __init fork_init(void) · 818 unmodified lines | |||
| 819 | init_task.signal->rlim[RLIMIT_SIGPENDING] = | 819 | init_task.signal->rlim[RLIMIT_SIGPENDING] = |
| 820 | init_task.signal->rlim[RLIMIT_NPROC]; | 820 | init_task.signal->rlim[RLIMIT_NPROC]; |
| 821 | 821 | ||
| 822 | for (i = 0; i < UCOUNT_COUNTS; i++) { | 822 | for (i = 0; i < UCOUNT_COUNTS; i++) |
| 823 | init_user_ns.ucount_max[i] = max_threads/2; | 823 | init_user_ns.ucount_max[i] = max_threads/2; |
| 824 | } | ||
| 825 | 824 | ||
| 826 | #ifdef CONFIG_VMAP_STACK | 825 | #ifdef CONFIG_VMAP_STACK |
| 827 | cpuhp_setup_state(CPUHP_BP_PREPARE_DYN, "fork:vm_stack_cache", | 826 | 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 | |||
| 1654 | { | 1653 | { |
| 1655 | enum pid_type type; | 1654 | enum pid_type type; |
| 1656 | 1655 | ||
| 1657 | for (type = PIDTYPE_PID; type < PIDTYPE_MAX; ++type) { | 1656 | for (type = PIDTYPE_PID; type < PIDTYPE_MAX; ++type) |
| 1658 | INIT_HLIST_NODE(&task->pid_links[type]); | 1657 | INIT_HLIST_NODE(&task->pid_links[type]); |
| 1659 | } | ||
| 1660 | } | 1658 | } |
| 1661 | 1659 | ||
| 1662 | static inline void | 1660 | static inline void |
| @@ -763,6 +763,29 @@ static struct futex_pi_state *alloc_pi_state(void) · 762 unmodified lines | |||
| 763 | return pi_state; | 763 | return pi_state; |
| 764 | } | 764 | } |
| 765 | 765 | ||
| 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 | |||
| 766 | static void get_pi_state(struct futex_pi_state *pi_state) | 789 | static void get_pi_state(struct futex_pi_state *pi_state) |
| 767 | { | 790 | { |
| 768 | WARN_ON_ONCE(!refcount_inc_not_zero(&pi_state->refcount)); | 791 | 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 | |||
| 785 | * and has cleaned up the pi_state already | 808 | * and has cleaned up the pi_state already |
| 786 | */ | 809 | */ |
| 787 | if (pi_state->owner) { | 810 | if (pi_state->owner) { |
| 788 | struct task_struct *owner; | ||
| 789 | unsigned long flags; | 811 | unsigned long flags; |
| 790 | 812 | ||
| 791 | raw_spin_lock_irqsave(&pi_state->pi_mutex.wait_lock, flags); | 813 | raw_spin_lock_irqsave(&pi_state->pi_mutex.wait_lock, flags); |
| 792 | owner = pi_state->owner; | 814 | pi_state_update_owner(pi_state, NULL); |
| 793 | if (owner) { | 815 | rt_mutex_proxy_unlock(&pi_state->pi_mutex); |
| 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); | ||
| 799 | raw_spin_unlock_irqrestore(&pi_state->pi_mutex.wait_lock, flags); | 816 | raw_spin_unlock_irqrestore(&pi_state->pi_mutex.wait_lock, flags); |
| 800 | } | 817 | } |
| 801 | 818 | ||
| @@ -941,7 +958,8 @@ static inline void exit_pi_state_list(struct task_struct *curr) { } · 139 unmodified lines | |||
| 941 | * FUTEX_OWNER_DIED bit. See [4] | 958 | * FUTEX_OWNER_DIED bit. See [4] |
| 942 | * | 959 | * |
| 943 | * [10] There is no transient state which leaves owner and user space | 960 | * [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(). | ||
| 945 | * | 963 | * |
| 946 | * | 964 | * |
| 947 | * Serialization and lifetime rules: | 965 | * 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 | |||
| 1521 | ret = -EINVAL; | 1539 | ret = -EINVAL; |
| 1522 | } | 1540 | } |
| 1523 | 1541 | ||
| 1524 | if (ret) | 1542 | if (!ret) { |
| 1525 | goto out_unlock; | 1543 | /* |
| 1526 | 1544 | * This is a point of no return; once we modified the uval | |
| 1527 | /* | 1545 | * there is no going back and subsequent operations must |
| 1528 | * This is a point of no return; once we modify the uval there is no | 1546 | * not fail. |
| 1529 | * going back and subsequent operations must not fail. | 1547 | */ |
| 1530 | */ | 1548 | pi_state_update_owner(pi_state, new_owner); |
| 1531 | 1549 | postunlock = __rt_mutex_futex_unlock(&pi_state->pi_mutex, &wake_q); | |
| 1532 | raw_spin_lock(&pi_state->owner->pi_lock); | 1550 | } |
| 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); | ||
| 1544 | 1551 | ||
| 1545 | out_unlock: | 1552 | out_unlock: |
| 1546 | raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock); | 1553 | 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 | |||
| 2323 | spin_unlock(q->lock_ptr); | 2330 | spin_unlock(q->lock_ptr); |
| 2324 | } | 2331 | } |
| 2325 | 2332 | ||
| 2326 | static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, | 2333 | static int __fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, |
| 2327 | struct task_struct *argowner) | 2334 | struct task_struct *argowner) |
| 2328 | { | 2335 | { |
| 2329 | struct futex_pi_state *pi_state = q->pi_state; | 2336 | struct futex_pi_state *pi_state = q->pi_state; |
| 2330 | u32 uval, curval, newval; | ||
| 2331 | struct task_struct *oldowner, *newowner; | 2337 | struct task_struct *oldowner, *newowner; |
| 2332 | u32 newtid; | 2338 | u32 uval, curval, newval, newtid; |
| 2333 | int ret, err = 0; | 2339 | int err = 0; |
| 2334 | |||
| 2335 | lockdep_assert_held(q->lock_ptr); | ||
| 2336 | |||
| 2337 | raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock); | ||
| 2338 | 2340 | ||
| 2339 | oldowner = pi_state->owner; | 2341 | oldowner = pi_state->owner; |
| 2340 | 2342 | ||
| @@ -2368,14 +2370,12 @@ retry: · 27 unmodified lines | |||
| 2368 | * We raced against a concurrent self; things are | 2370 | * We raced against a concurrent self; things are |
| 2369 | * already fixed up. Nothing to do. | 2371 | * already fixed up. Nothing to do. |
| 2370 | */ | 2372 | */ |
| 2371 | ret = 0; | 2373 | return 0; |
| 2372 | goto out_unlock; | ||
| 2373 | } | 2374 | } |
| 2374 | 2375 | ||
| 2375 | if (__rt_mutex_futex_trylock(&pi_state->pi_mutex)) { | 2376 | if (__rt_mutex_futex_trylock(&pi_state->pi_mutex)) { |
| 2376 | /* We got the lock after all, nothing to fix. */ | 2377 | /* We got the lock. pi_state is correct. Tell caller. */ |
| 2377 | ret = 0; | 2378 | return 1; |
| 2378 | goto out_unlock; | ||
| 2379 | } | 2379 | } |
| 2380 | 2380 | ||
| 2381 | /* | 2381 | /* |
| @@ -2402,8 +2402,7 @@ retry: · 20 unmodified lines | |||
| 2402 | * We raced against a concurrent self; things are | 2402 | * We raced against a concurrent self; things are |
| 2403 | * already fixed up. Nothing to do. | 2403 | * already fixed up. Nothing to do. |
| 2404 | */ | 2404 | */ |
| 2405 | ret = 0; | 2405 | return 1; |
| 2406 | goto out_unlock; | ||
| 2407 | } | 2406 | } |
| 2408 | newowner = argowner; | 2407 | newowner = argowner; |
| 2409 | } | 2408 | } |
| @@ -2433,22 +2432,9 @@ retry: · 23 unmodified lines | |||
| 2433 | * We fixed up user space. Now we need to fix the pi_state | 2432 | * We fixed up user space. Now we need to fix the pi_state |
| 2434 | * itself. | 2433 | * itself. |
| 2435 | */ | 2434 | */ |
| 2436 | if (pi_state->owner != NULL) { | 2435 | pi_state_update_owner(pi_state, newowner); |
| 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 | } | ||
| 2442 | 2436 | ||
| 2443 | pi_state->owner = newowner; | 2437 | return argowner == current; |
| 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; | ||
| 2452 | 2438 | ||
| 2453 | /* | 2439 | /* |
| 2454 | * In order to reschedule or handle a page fault, we need to drop the | 2440 | * In order to reschedule or handle a page fault, we need to drop the |
| @@ -2469,17 +2455,16 @@ handle_err: · 14 unmodified lines | |||
| 2469 | 2455 | ||
| 2470 | switch (err) { | 2456 | switch (err) { |
| 2471 | case -EFAULT: | 2457 | case -EFAULT: |
| 2472 | ret = fault_in_user_writeable(uaddr); | 2458 | err = fault_in_user_writeable(uaddr); |
| 2473 | break; | 2459 | break; |
| 2474 | 2460 | ||
| 2475 | case -EAGAIN: | 2461 | case -EAGAIN: |
| 2476 | cond_resched(); | 2462 | cond_resched(); |
| 2477 | ret = 0; | 2463 | err = 0; |
| 2478 | break; | 2464 | break; |
| 2479 | 2465 | ||
| 2480 | default: | 2466 | default: |
| 2481 | WARN_ON_ONCE(1); | 2467 | WARN_ON_ONCE(1); |
| 2482 | ret = err; | ||
| 2483 | break; | 2468 | break; |
| 2484 | } | 2469 | } |
| 2485 | 2470 | ||
| @@ -2489,17 +2474,44 @@ handle_err: · 3 unmodified lines | |||
| 2489 | /* | 2474 | /* |
| 2490 | * Check if someone else fixed it for us: | 2475 | * Check if someone else fixed it for us: |
| 2491 | */ | 2476 | */ |
| 2492 | if (pi_state->owner != oldowner) { | 2477 | if (pi_state->owner != oldowner) |
| 2493 | ret = 0; | 2478 | return argowner == current; |
| 2494 | goto out_unlock; | ||
| 2495 | } | ||
| 2496 | 2479 | ||
| 2497 | if (ret) | 2480 | /* Retry if err was -EAGAIN or the fault in succeeded */ |
| 2498 | goto out_unlock; | 2481 | if (!err) |
| 2482 | goto retry; | ||
| 2499 | 2483 | ||
| 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)); | ||
| 2501 | 2501 | ||
| 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); | ||
| 2503 | raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock); | 2515 | raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock); |
| 2504 | return ret; | 2516 | return ret; |
| 2505 | } | 2517 | } |
| @@ -2523,8 +2535,6 @@ static long futex_wait_restart(struct restart_block *restart); · 17 unmodified lines | |||
| 2523 | */ | 2535 | */ |
| 2524 | static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked) | 2536 | static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked) |
| 2525 | { | 2537 | { |
| 2526 | int ret = 0; | ||
| 2527 | |||
| 2528 | if (locked) { | 2538 | if (locked) { |
| 2529 | /* | 2539 | /* |
| 2530 | * Got the lock. We might not be the anticipated owner if we | 2540 | * 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 | |||
| 2535 | * stable state, anything else needs more attention. | 2545 | * stable state, anything else needs more attention. |
| 2536 | */ | 2546 | */ |
| 2537 | if (q->pi_state->owner != current) | 2547 | if (q->pi_state->owner != current) |
| 2538 | ret = fixup_pi_state_owner(uaddr, q, current); | 2548 | return fixup_pi_state_owner(uaddr, q, current); |
| 2539 | return ret ? ret : locked; | 2549 | return 1; |
| 2540 | } | 2550 | } |
| 2541 | 2551 | ||
| 2542 | /* | 2552 | /* |
| @@ -2547,23 +2557,17 @@ static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked) · 4 unmodified lines | |||
| 2547 | * Another speculative read; pi_state->owner == current is unstable | 2557 | * Another speculative read; pi_state->owner == current is unstable |
| 2548 | * but needs our attention. | 2558 | * but needs our attention. |
| 2549 | */ | 2559 | */ |
| 2550 | if (q->pi_state->owner == current) { | 2560 | if (q->pi_state->owner == current) |
| 2551 | ret = fixup_pi_state_owner(uaddr, q, NULL); | 2561 | return fixup_pi_state_owner(uaddr, q, NULL); |
| 2552 | return ret; | ||
| 2553 | } | ||
| 2554 | 2562 | ||
| 2555 | /* | 2563 | /* |
| 2556 | * Paranoia check. If we did not take the lock, then we should not be | 2564 | * 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. |
| 2558 | */ | 2566 | */ |
| 2559 | if (rt_mutex_owner(&q->pi_state->pi_mutex) == current) { | 2567 | if (WARN_ON_ONCE(rt_mutex_owner(&q->pi_state->pi_mutex) == current)) |
| 2560 | printk(KERN_ERR "fixup_owner: ret = %d pi-mutex: %p " | 2568 | return fixup_pi_state_owner(uaddr, q, current); |
| 2561 | "pi-state %p\n", ret, | ||
| 2562 | q->pi_state->pi_mutex.owner, | ||
| 2563 | q->pi_state->owner); | ||
| 2564 | } | ||
| 2565 | 2569 | ||
| 2566 | return ret; | 2570 | return 0; |
| 2567 | } | 2571 | } |
| 2568 | 2572 | ||
| 2569 | /** | 2573 | /** |
| @@ -2771,7 +2775,6 @@ static int futex_lock_pi(u32 __user *uaddr, unsigned int flags, · 201 unmodified lines | |||
| 2771 | ktime_t *time, int trylock) | 2775 | ktime_t *time, int trylock) |
| 2772 | { | 2776 | { |
| 2773 | struct hrtimer_sleeper timeout, *to; | 2777 | struct hrtimer_sleeper timeout, *to; |
| 2774 | struct futex_pi_state *pi_state = NULL; | ||
| 2775 | struct task_struct *exiting = NULL; | 2778 | struct task_struct *exiting = NULL; |
| 2776 | struct rt_mutex_waiter rt_waiter; | 2779 | struct rt_mutex_waiter rt_waiter; |
| 2777 | struct futex_hash_bucket *hb; | 2780 | struct futex_hash_bucket *hb; |
| @@ -2907,23 +2910,8 @@ no_block: · 129 unmodified lines | |||
| 2907 | if (res) | 2910 | if (res) |
| 2908 | ret = (res < 0) ? res : 0; | 2911 | ret = (res < 0) ? res : 0; |
| 2909 | 2912 | ||
| 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 | |||
| 2919 | /* Unqueue and drop the lock */ | 2913 | /* Unqueue and drop the lock */ |
| 2920 | unqueue_me_pi(&q); | 2914 | 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 | |||
| 2927 | goto out; | 2915 | goto out; |
| 2928 | 2916 | ||
| 2929 | out_unlock_put_key: | 2917 | out_unlock_put_key: |
| @@ -3183,7 +3171,6 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags, · 253 unmodified lines | |||
| 3183 | u32 __user *uaddr2) | 3171 | u32 __user *uaddr2) |
| 3184 | { | 3172 | { |
| 3185 | struct hrtimer_sleeper timeout, *to; | 3173 | struct hrtimer_sleeper timeout, *to; |
| 3186 | struct futex_pi_state *pi_state = NULL; | ||
| 3187 | struct rt_mutex_waiter rt_waiter; | 3174 | struct rt_mutex_waiter rt_waiter; |
| 3188 | struct futex_hash_bucket *hb; | 3175 | struct futex_hash_bucket *hb; |
| 3189 | union futex_key key2 = FUTEX_KEY_INIT; | 3176 | 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 | |||
| 3261 | if (q.pi_state && (q.pi_state->owner != current)) { | 3248 | if (q.pi_state && (q.pi_state->owner != current)) { |
| 3262 | spin_lock(q.lock_ptr); | 3249 | spin_lock(q.lock_ptr); |
| 3263 | ret = fixup_pi_state_owner(uaddr2, &q, current); | 3250 | 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 | } | ||
| 3268 | /* | 3251 | /* |
| 3269 | * Drop the reference to the pi state which | 3252 | * Drop the reference to the pi state which |
| 3270 | * the requeue_pi() code acquired for us. | 3253 | * the requeue_pi() code acquired for us. |
| 3271 | */ | 3254 | */ |
| 3272 | put_pi_state(q.pi_state); | 3255 | put_pi_state(q.pi_state); |
| 3273 | spin_unlock(q.lock_ptr); | 3256 | 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; | ||
| 3274 | } | 3262 | } |
| 3275 | } else { | 3263 | } else { |
| 3276 | struct rt_mutex *pi_mutex; | 3264 | struct rt_mutex *pi_mutex; |
| @@ -3301,25 +3289,10 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags, · 24 unmodified lines | |||
| 3301 | if (res) | 3289 | if (res) |
| 3302 | ret = (res < 0) ? res : 0; | 3290 | ret = (res < 0) ? res : 0; |
| 3303 | 3291 | ||
| 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 | |||
| 3314 | /* Unqueue and drop the lock. */ | 3292 | /* Unqueue and drop the lock. */ |
| 3315 | unqueue_me_pi(&q); | 3293 | unqueue_me_pi(&q); |
| 3316 | } | 3294 | } |
| 3317 | 3295 | ||
| 3318 | if (pi_state) { | ||
| 3319 | rt_mutex_futex_unlock(&pi_state->pi_mutex); | ||
| 3320 | put_pi_state(pi_state); | ||
| 3321 | } | ||
| 3322 | |||
| 3323 | if (ret == -EINTR) { | 3296 | if (ret == -EINTR) { |
| 3324 | /* | 3297 | /* |
| 3325 | * We've already been requeued, but cannot restart by calling | 3298 | * We've already been requeued, but cannot restart by calling |
| @@ -4,7 +4,7 @@ menu "GCOV-based kernel profiling" · 3 unmodified lines | |||
| 4 | config GCOV_KERNEL | 4 | config GCOV_KERNEL |
| 5 | bool "Enable gcov-based kernel profiling" | 5 | bool "Enable gcov-based kernel profiling" |
| 6 | depends on DEBUG_FS | 6 | depends on DEBUG_FS |
| 7 | select CONSTRUCTORS if !UML | 7 | select CONSTRUCTORS |
| 8 | default n | 8 | default n |
| 9 | help | 9 | help |
| 10 | This option enables gcov-based code profiling (e.g. for code coverage | 10 | This option enables gcov-based code profiling (e.g. for code coverage |
| @@ -2859,3 +2859,4 @@ bool irq_check_status_bit(unsigned int irq, unsigned int bitmask) · 2858 unmodified lines | |||
| 2859 | rcu_read_unlock(); | 2859 | rcu_read_unlock(); |
| 2860 | return res; | 2860 | return res; |
| 2861 | } | 2861 | } |
| 2862 | EXPORT_SYMBOL_GPL(irq_check_status_bit); | ||
| @@ -402,7 +402,7 @@ int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, · 401 unmodified lines | |||
| 402 | struct msi_domain_ops *ops = info->ops; | 402 | struct msi_domain_ops *ops = info->ops; |
| 403 | struct irq_data *irq_data; | 403 | struct irq_data *irq_data; |
| 404 | struct msi_desc *desc; | 404 | struct msi_desc *desc; |
| 405 | msi_alloc_info_t arg; | 405 | msi_alloc_info_t arg = { }; |
| 406 | int i, ret, virq; | 406 | int i, ret, virq; |
| 407 | bool can_reserve; | 407 | bool can_reserve; |
| 408 | 408 | ||
| @@ -436,22 +436,22 @@ int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, · 27 unmodified lines | |||
| 436 | 436 | ||
| 437 | can_reserve = msi_check_reservation_mode(domain, info, dev); | 437 | can_reserve = msi_check_reservation_mode(domain, info, dev); |
| 438 | 438 | ||
| 439 | for_each_msi_entry(desc, dev) { | 439 | /* |
| 440 | virq = desc->irq; | 440 | * This flag is set by the PCI layer as we need to activate |
| 441 | if (desc->nvec_used == 1) | 441 | * the MSI entries before the PCI layer enables MSI in the |
| 442 | dev_dbg(dev, "irq %d for MSI\n", virq); | 442 | * card. Otherwise the card latches a random msi message. |
| 443 | else | 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; | ||
| 444 | dev_dbg(dev, "irq [%d-%d] for MSI\n", | 450 | dev_dbg(dev, "irq [%d-%d] for MSI\n", |
| 445 | virq, virq + desc->nvec_used - 1); | 451 | virq, virq + desc->nvec_used - 1); |
| 446 | /* | 452 | } |
| 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; | ||
| 453 | 453 | ||
| 454 | irq_data = irq_domain_get_irq_data(domain, desc->irq); | 454 | irq_data = irq_domain_get_irq_data(domain, i); |
| 455 | if (!can_reserve) { | 455 | if (!can_reserve) { |
| 456 | irqd_clr_can_reserve(irq_data); | 456 | irqd_clr_can_reserve(irq_data); |
| 457 | if (domain->flags & IRQ_DOMAIN_MSI_NOMASK_QUIRK) | 457 | 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 | |||
| 462 | goto cleanup; | 462 | goto cleanup; |
| 463 | } | 463 | } |
| 464 | 464 | ||
| 465 | skip_activate: | ||
| 465 | /* | 466 | /* |
| 466 | * If these interrupts use reservation mode, clear the activated bit | 467 | * If these interrupts use reservation mode, clear the activated bit |
| 467 | * so request_irq() will assign the final vector. | 468 | * so request_irq() will assign the final vector. |
| 468 | */ | 469 | */ |
| 469 | if (can_reserve) { | 470 | if (can_reserve) { |
| 470 | for_each_msi_entry(desc, dev) { | 471 | for_each_msi_vector(desc, i, dev) { |
| 471 | irq_data = irq_domain_get_irq_data(domain, desc->irq); | 472 | irq_data = irq_domain_get_irq_data(domain, i); |
| 472 | irqd_clr_activated(irq_data); | 473 | irqd_clr_activated(irq_data); |
| 473 | } | 474 | } |
| 474 | } | 475 | } |
| 475 | return 0; | 476 | return 0; |
| 476 | 477 | ||
| 477 | cleanup: | 478 | cleanup: |
| 478 | for_each_msi_entry(desc, dev) { | 479 | for_each_msi_vector(desc, i, dev) { |
| 479 | struct irq_data *irqd; | 480 | irq_data = irq_domain_get_irq_data(domain, i); |
| 480 | 481 | if (irqd_is_activated(irq_data)) | |
| 481 | if (desc->irq == virq) | 482 | irq_domain_deactivate_irq(irq_data); |
| 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); | ||
| 487 | } | 483 | } |
| 488 | msi_domain_free_irqs(domain, dev); | 484 | msi_domain_free_irqs(domain, dev); |
| 489 | return ret; | 485 | return ret; |
| @@ -1134,7 +1134,6 @@ int kernel_kexec(void) · 1133 unmodified lines | |||
| 1134 | 1134 | ||
| 1135 | #ifdef CONFIG_KEXEC_JUMP | 1135 | #ifdef CONFIG_KEXEC_JUMP |
| 1136 | if (kexec_image->preserve_context) { | 1136 | if (kexec_image->preserve_context) { |
| 1137 | lock_system_sleep(); | ||
| 1138 | pm_prepare_console(); | 1137 | pm_prepare_console(); |
| 1139 | error = freeze_processes(); | 1138 | error = freeze_processes(); |
| 1140 | if (error) { | 1139 | if (error) { |
| @@ -1197,7 +1196,6 @@ int kernel_kexec(void) · 56 unmodified lines | |||
| 1197 | thaw_processes(); | 1196 | thaw_processes(); |
| 1198 | Restore_console: | 1197 | Restore_console: |
| 1199 | pm_restore_console(); | 1198 | pm_restore_console(); |
| 1200 | unlock_system_sleep(); | ||
| 1201 | } | 1199 | } |
| 1202 | #endif | 1200 | #endif |
| 1203 | 1201 | ||
| @@ -1954,28 +1954,48 @@ bool __weak arch_kprobe_on_func_entry(unsigned long offset) · 1953 unmodified lines | |||
| 1954 | return !offset; | 1954 | return !offset; |
| 1955 | } | 1955 | } |
| 1956 | 1956 | ||
| 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) | ||
| 1958 | { | 1971 | { |
| 1959 | kprobe_opcode_t *kp_addr = _kprobe_addr(addr, sym, offset); | 1972 | kprobe_opcode_t *kp_addr = _kprobe_addr(addr, sym, offset); |
| 1960 | 1973 | ||
| 1961 | if (IS_ERR(kp_addr)) | 1974 | if (IS_ERR(kp_addr)) |
| 1962 | return false; | 1975 | return PTR_ERR(kp_addr); |
| 1963 | 1976 | ||
| 1964 | if (!kallsyms_lookup_size_offset((unsigned long)kp_addr, NULL, &offset) || | 1977 | if (!kallsyms_lookup_size_offset((unsigned long)kp_addr, NULL, &offset)) |
| 1965 | !arch_kprobe_on_func_entry(offset)) | 1978 | return -ENOENT; |
| 1966 | return false; | ||
| 1967 | 1979 | ||
| 1968 | return true; | 1980 | if (!arch_kprobe_on_func_entry(offset)) |
| 1981 | return -EINVAL; | ||
| 1982 | |||
| 1983 | return 0; | ||
| 1969 | } | 1984 | } |
| 1970 | 1985 | ||
| 1971 | int register_kretprobe(struct kretprobe *rp) | 1986 | int register_kretprobe(struct kretprobe *rp) |
| 1972 | { | 1987 | { |
| 1973 | int ret = 0; | 1988 | int ret; |
| 1974 | struct kretprobe_instance *inst; | 1989 | struct kretprobe_instance *inst; |
| 1975 | int i; | 1990 | int i; |
| 1976 | void *addr; | 1991 | void *addr; |
| 1977 | 1992 | ||
| 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)) | ||
| 1979 | return -EINVAL; | 1999 | return -EINVAL; |
| 1980 | 2000 | ||
| 1981 | if (kretprobe_blacklist_size) { | 2001 | if (kretprobe_blacklist_size) { |
| @@ -294,7 +294,7 @@ static int kthread(void *_create) · 293 unmodified lines | |||
| 294 | do_exit(ret); | 294 | do_exit(ret); |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 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 */ |
| 298 | int tsk_fork_get_node(struct task_struct *tsk) | 298 | int tsk_fork_get_node(struct task_struct *tsk) |
| 299 | { | 299 | { |
| 300 | #ifdef CONFIG_NUMA | 300 | #ifdef CONFIG_NUMA |
| @@ -493,11 +493,36 @@ struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data), · 192 unmodified lines | |||
| 493 | return p; | 493 | return p; |
| 494 | kthread_bind(p, cpu); | 494 | kthread_bind(p, cpu); |
| 495 | /* CPU hotplug need to bind once again when unparking the thread. */ | 495 | /* CPU hotplug need to bind once again when unparking the thread. */ |
| 496 | set_bit(KTHREAD_IS_PER_CPU, &to_kthread(p)->flags); | ||
| 497 | to_kthread(p)->cpu = cpu; | 496 | to_kthread(p)->cpu = cpu; |
| 498 | return p; | 497 | return p; |
| 499 | } | 498 | } |
| 500 | 499 | ||
| 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 | |||
| 501 | /** | 526 | /** |
| 502 | * kthread_unpark - unpark a thread created by kthread_create(). | 527 | * kthread_unpark - unpark a thread created by kthread_create(). |
| 503 | * @k: thread created by kthread_create(). | 528 | * @k: thread created by kthread_create(). |
| @@ -79,7 +79,7 @@ module_param(lock_stat, int, 0644); · 78 unmodified lines | |||
| 79 | DEFINE_PER_CPU(unsigned int, lockdep_recursion); | 79 | DEFINE_PER_CPU(unsigned int, lockdep_recursion); |
| 80 | EXPORT_PER_CPU_SYMBOL_GPL(lockdep_recursion); | 80 | EXPORT_PER_CPU_SYMBOL_GPL(lockdep_recursion); |
| 81 | 81 | ||
| 82 | static inline bool lockdep_enabled(void) | 82 | static __always_inline bool lockdep_enabled(void) |
| 83 | { | 83 | { |
| 84 | if (!debug_locks) | 84 | if (!debug_locks) |
| 85 | return false; | 85 | return false; |
| @@ -5271,12 +5271,15 @@ static void __lock_unpin_lock(struct lockdep_map *lock, struct pin_cookie cookie · 5185 unmodified lines | |||
| 5271 | /* | 5271 | /* |
| 5272 | * Check whether we follow the irq-flags state precisely: | 5272 | * Check whether we follow the irq-flags state precisely: |
| 5273 | */ | 5273 | */ |
| 5274 | static void check_flags(unsigned long flags) | 5274 | static noinstr void check_flags(unsigned long flags) |
| 5275 | { | 5275 | { |
| 5276 | #if defined(CONFIG_PROVE_LOCKING) && defined(CONFIG_DEBUG_LOCKDEP) | 5276 | #if defined(CONFIG_PROVE_LOCKING) && defined(CONFIG_DEBUG_LOCKDEP) |
| 5277 | if (!debug_locks) | 5277 | if (!debug_locks) |
| 5278 | return; | 5278 | return; |
| 5279 | 5279 | ||
| 5280 | /* Get the warning out.. */ | ||
| 5281 | instrumentation_begin(); | ||
| 5282 | |||
| 5280 | if (irqs_disabled_flags(flags)) { | 5283 | if (irqs_disabled_flags(flags)) { |
| 5281 | if (DEBUG_LOCKS_WARN_ON(lockdep_hardirqs_enabled())) { | 5284 | if (DEBUG_LOCKS_WARN_ON(lockdep_hardirqs_enabled())) { |
| 5282 | printk("possible reason: unannotated irqs-off.\n"); | 5285 | printk("possible reason: unannotated irqs-off.\n"); |
| @@ -5304,6 +5307,8 @@ static void check_flags(unsigned long flags) · 21 unmodified lines | |||
| 5304 | 5307 | ||
| 5305 | if (!debug_locks) | 5308 | if (!debug_locks) |
| 5306 | print_irqtrace_events(current); | 5309 | print_irqtrace_events(current); |
| 5310 | |||
| 5311 | instrumentation_end(); | ||
| 5307 | #endif | 5312 | #endif |
| 5308 | } | 5313 | } |
| 5309 | 5314 | ||
| @@ -1716,8 +1716,7 @@ void rt_mutex_init_proxy_locked(struct rt_mutex *lock, · 1715 unmodified lines | |||
| 1716 | * possible because it belongs to the pi_state which is about to be freed | 1716 | * possible because it belongs to the pi_state which is about to be freed |
| 1717 | * and it is not longer visible to other tasks. | 1717 | * and it is not longer visible to other tasks. |
| 1718 | */ | 1718 | */ |
| 1719 | void rt_mutex_proxy_unlock(struct rt_mutex *lock, | 1719 | void rt_mutex_proxy_unlock(struct rt_mutex *lock) |
| 1720 | struct task_struct *proxy_owner) | ||
| 1721 | { | 1720 | { |
| 1722 | debug_rt_mutex_proxy_unlock(lock); | 1721 | debug_rt_mutex_proxy_unlock(lock); |
| 1723 | rt_mutex_set_owner(lock, NULL); | 1722 | rt_mutex_set_owner(lock, NULL); |
| @@ -133,8 +133,7 @@ enum rtmutex_chainwalk { · 132 unmodified lines | |||
| 133 | extern struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock); | 133 | extern struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock); |
| 134 | extern void rt_mutex_init_proxy_locked(struct rt_mutex *lock, | 134 | extern void rt_mutex_init_proxy_locked(struct rt_mutex *lock, |
| 135 | struct task_struct *proxy_owner); | 135 | struct task_struct *proxy_owner); |
| 136 | extern void rt_mutex_proxy_unlock(struct rt_mutex *lock, | 136 | extern void rt_mutex_proxy_unlock(struct rt_mutex *lock); |
| 137 | struct task_struct *proxy_owner); | ||
| 138 | extern void rt_mutex_init_waiter(struct rt_mutex_waiter *waiter); | 137 | extern void rt_mutex_init_waiter(struct rt_mutex_waiter *waiter); |
| 139 | extern int __rt_mutex_start_proxy_lock(struct rt_mutex *lock, | 138 | extern int __rt_mutex_start_proxy_lock(struct rt_mutex *lock, |
| 140 | struct rt_mutex_waiter *waiter, | 139 | struct rt_mutex_waiter *waiter, |
| @@ -497,10 +497,10 @@ static int swap_writer_finish(struct swap_map_handle *handle, · 496 unmodified lines | |||
| 497 | unsigned int flags, int error) | 497 | unsigned int flags, int error) |
| 498 | { | 498 | { |
| 499 | if (!error) { | 499 | if (!error) { |
| 500 | flush_swap_writer(handle); | ||
| 501 | pr_info("S"); | 500 | pr_info("S"); |
| 502 | error = mark_swapfiles(handle, flags); | 501 | error = mark_swapfiles(handle, flags); |
| 503 | pr_cont("|\n"); | 502 | pr_cont("|\n"); |
| 503 | flush_swap_writer(handle); | ||
| 504 | } | 504 | } |
| 505 | 505 | ||
| 506 | if (error) | 506 | if (error) |
| @@ -1291,11 +1291,16 @@ static size_t info_print_prefix(const struct printk_info *info, bool syslog, · 1290 unmodified lines | |||
| 1291 | * done: | 1291 | * done: |
| 1292 | * | 1292 | * |
| 1293 | * - Add prefix for each line. | 1293 | * - Add prefix for each line. |
| 1294 | * - Drop truncated lines that no longer fit into the buffer. | ||
| 1294 | * - Add the trailing newline that has been removed in vprintk_store(). | 1295 | * - 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; | ||
| 1296 | * | 1300 | * |
| 1297 | * Return: The length of the updated/prepared text, including the added | 1301 | * 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. | ||
| 1299 | */ | 1304 | */ |
| 1300 | static size_t record_print_text(struct printk_record *r, bool syslog, | 1305 | static size_t record_print_text(struct printk_record *r, bool syslog, |
| 1301 | bool time) | 1306 | bool time) |
| @@ -1338,26 +1343,31 @@ static size_t record_print_text(struct printk_record *r, bool syslog, · 36 unmodified lines | |||
| 1338 | 1343 | ||
| 1339 | /* | 1344 | /* |
| 1340 | * Truncate the text if there is not enough space to add the | 1345 | * 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. |
| 1342 | */ | 1347 | */ |
| 1343 | if (len + prefix_len + text_len + 1 > buf_size) { | 1348 | if (len + prefix_len + text_len + 1 + 1 > buf_size) { |
| 1344 | /* Drop even the current line if no space. */ | 1349 | /* 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) |
| 1346 | break; | 1351 | break; |
| 1347 | 1352 | ||
| 1348 | text_len = buf_size - len - prefix_len - 1; | 1353 | text_len = buf_size - len - prefix_len - 1 - 1; |
| 1349 | truncated = true; | 1354 | truncated = true; |
| 1350 | } | 1355 | } |
| 1351 | 1356 | ||
| 1352 | memmove(text + prefix_len, text, text_len); | 1357 | memmove(text + prefix_len, text, text_len); |
| 1353 | memcpy(text, prefix, prefix_len); | 1358 | memcpy(text, prefix, prefix_len); |
| 1354 | 1359 | ||
| 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 | */ | ||
| 1355 | len += prefix_len + line_len + 1; | 1366 | len += prefix_len + line_len + 1; |
| 1356 | |||
| 1357 | if (text_len == line_len) { | 1367 | if (text_len == line_len) { |
| 1358 | /* | 1368 | /* |
| 1359 | * Add the trailing newline removed in | 1369 | * This is the last line. Add the trailing newline |
| 1360 | * vprintk_store(). | 1370 | * removed in vprintk_store(). |
| 1361 | */ | 1371 | */ |
| 1362 | text[prefix_len + line_len] = '\n'; | 1372 | text[prefix_len + line_len] = '\n'; |
| 1363 | break; | 1373 | break; |
| @@ -1382,6 +1392,14 @@ static size_t record_print_text(struct printk_record *r, bool syslog, · 18 unmodified lines | |||
| 1382 | text_len -= line_len + 1; | 1392 | text_len -= line_len + 1; |
| 1383 | } | 1393 | } |
| 1384 | 1394 | ||
| 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 | |||
| 1385 | return len; | 1403 | return len; |
| 1386 | } | 1404 | } |
| 1387 | 1405 | ||
| @@ -3427,7 +3445,7 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog, · 2039 unmodified lines | |||
| 3427 | while (prb_read_valid_info(prb, seq, &info, &line_count)) { | 3445 | while (prb_read_valid_info(prb, seq, &info, &line_count)) { |
| 3428 | if (r.info->seq >= dumper->next_seq) | 3446 | if (r.info->seq >= dumper->next_seq) |
| 3429 | break; | 3447 | 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); |
| 3431 | seq = r.info->seq + 1; | 3449 | seq = r.info->seq + 1; |
| 3432 | } | 3450 | } |
| 3433 | 3451 | ||
| @@ -3437,7 +3455,7 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog, · 3 unmodified lines | |||
| 3437 | &info, &line_count)) { | 3455 | &info, &line_count)) { |
| 3438 | if (r.info->seq >= dumper->next_seq) | 3456 | if (r.info->seq >= dumper->next_seq) |
| 3439 | break; | 3457 | 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); |
| 3441 | seq = r.info->seq + 1; | 3459 | seq = r.info->seq + 1; |
| 3442 | } | 3460 | } |
| 3443 | 3461 | ||
| @@ -1718,7 +1718,7 @@ static bool copy_data(struct prb_data_ring *data_ring, · 1717 unmodified lines | |||
| 1718 | 1718 | ||
| 1719 | /* Caller interested in the line count? */ | 1719 | /* Caller interested in the line count? */ |
| 1720 | if (line_count) | 1720 | if (line_count) |
| 1721 | *line_count = count_lines(data, data_size); | 1721 | *line_count = count_lines(data, len); |
| 1722 | 1722 | ||
| 1723 | /* Caller interested in the data content? */ | 1723 | /* Caller interested in the data content? */ |
| 1724 | if (!buf || !buf_size) | 1724 | if (!buf || !buf_size) |
| @@ -241,7 +241,7 @@ static int __noreturn rcu_tasks_kthread(void *arg) · 240 unmodified lines | |||
| 241 | } | 241 | } |
| 242 | } | 242 | } |
| 243 | 243 | ||
| 244 | /* Spawn RCU-tasks grace-period kthread, e.g., at core_initcall() time. */ | 244 | /* Spawn RCU-tasks grace-period kthread. */ |
| 245 | static void __init rcu_spawn_tasks_kthread_generic(struct rcu_tasks *rtp) | 245 | static void __init rcu_spawn_tasks_kthread_generic(struct rcu_tasks *rtp) |
| 246 | { | 246 | { |
| 247 | struct task_struct *t; | 247 | struct task_struct *t; |
| @@ -564,7 +564,6 @@ static int __init rcu_spawn_tasks_kthread(void) · 316 unmodified lines | |||
| 564 | rcu_spawn_tasks_kthread_generic(&rcu_tasks); | 564 | rcu_spawn_tasks_kthread_generic(&rcu_tasks); |
| 565 | return 0; | 565 | return 0; |
| 566 | } | 566 | } |
| 567 | core_initcall(rcu_spawn_tasks_kthread); | ||
| 568 | 567 | ||
| 569 | #if !defined(CONFIG_TINY_RCU) | 568 | #if !defined(CONFIG_TINY_RCU) |
| 570 | void show_rcu_tasks_classic_gp_kthread(void) | 569 | void show_rcu_tasks_classic_gp_kthread(void) |
| @@ -692,7 +691,6 @@ static int __init rcu_spawn_tasks_rude_kthread(void) · 121 unmodified lines | |||
| 692 | rcu_spawn_tasks_kthread_generic(&rcu_tasks_rude); | 691 | rcu_spawn_tasks_kthread_generic(&rcu_tasks_rude); |
| 693 | return 0; | 692 | return 0; |
| 694 | } | 693 | } |
| 695 | core_initcall(rcu_spawn_tasks_rude_kthread); | ||
| 696 | 694 | ||
| 697 | #if !defined(CONFIG_TINY_RCU) | 695 | #if !defined(CONFIG_TINY_RCU) |
| 698 | void show_rcu_tasks_rude_gp_kthread(void) | 696 | void show_rcu_tasks_rude_gp_kthread(void) |
| @@ -968,6 +966,11 @@ static void rcu_tasks_trace_pregp_step(void) · 269 unmodified lines | |||
| 968 | static void rcu_tasks_trace_pertask(struct task_struct *t, | 966 | static void rcu_tasks_trace_pertask(struct task_struct *t, |
| 969 | struct list_head *hop) | 967 | struct list_head *hop) |
| 970 | { | 968 | { |
| 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 | |||
| 971 | WRITE_ONCE(t->trc_reader_special.b.need_qs, false); | 974 | WRITE_ONCE(t->trc_reader_special.b.need_qs, false); |
| 972 | WRITE_ONCE(t->trc_reader_checked, false); | 975 | WRITE_ONCE(t->trc_reader_checked, false); |
| 973 | t->trc_ipi_to_cpu = -1; | 976 | t->trc_ipi_to_cpu = -1; |
| @@ -1193,7 +1196,6 @@ static int __init rcu_spawn_tasks_trace_kthread(void) · 219 unmodified lines | |||
| 1193 | rcu_spawn_tasks_kthread_generic(&rcu_tasks_trace); | 1196 | rcu_spawn_tasks_kthread_generic(&rcu_tasks_trace); |
| 1194 | return 0; | 1197 | return 0; |
| 1195 | } | 1198 | } |
| 1196 | core_initcall(rcu_spawn_tasks_trace_kthread); | ||
| 1197 | 1199 | ||
| 1198 | #if !defined(CONFIG_TINY_RCU) | 1200 | #if !defined(CONFIG_TINY_RCU) |
| 1199 | void show_rcu_tasks_trace_gp_kthread(void) | 1201 | void show_rcu_tasks_trace_gp_kthread(void) |
| @@ -1222,6 +1224,21 @@ void show_rcu_tasks_gp_kthreads(void) · 22 unmodified lines | |||
| 1222 | } | 1224 | } |
| 1223 | #endif /* #ifndef CONFIG_TINY_RCU */ | 1225 | #endif /* #ifndef CONFIG_TINY_RCU */ |
| 1224 | 1226 | ||
| 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 | |||
| 1225 | #else /* #ifdef CONFIG_TASKS_RCU_GENERIC */ | 1242 | #else /* #ifdef CONFIG_TASKS_RCU_GENERIC */ |
| 1226 | static inline void rcu_tasks_bootup_oddness(void) {} | 1243 | static inline void rcu_tasks_bootup_oddness(void) {} |
| 1227 | void show_rcu_tasks_gp_kthreads(void) {} | 1244 | void show_rcu_tasks_gp_kthreads(void) {} |
| @@ -1796,13 +1796,28 @@ static inline bool rq_has_pinned_tasks(struct rq *rq) · 1795 unmodified lines | |||
| 1796 | */ | 1796 | */ |
| 1797 | static inline bool is_cpu_allowed(struct task_struct *p, int cpu) | 1797 | static inline bool is_cpu_allowed(struct task_struct *p, int cpu) |
| 1798 | { | 1798 | { |
| 1799 | /* When not in the task's cpumask, no point in looking further. */ | ||
| 1799 | if (!cpumask_test_cpu(cpu, p->cpus_ptr)) | 1800 | if (!cpumask_test_cpu(cpu, p->cpus_ptr)) |
| 1800 | return false; | 1801 | return false; |
| 1801 | 1802 | ||
| 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)) | ||
| 1803 | return cpu_online(cpu); | 1805 | return cpu_online(cpu); |
| 1804 | 1806 | ||
| 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); | ||
| 1806 | } | 1821 | } |
| 1807 | 1822 | ||
| 1808 | /* | 1823 | /* |
| @@ -2327,7 +2342,9 @@ static int __set_cpus_allowed_ptr(struct task_struct *p, · 518 unmodified lines | |||
| 2327 | 2342 | ||
| 2328 | if (p->flags & PF_KTHREAD || is_migration_disabled(p)) { | 2343 | if (p->flags & PF_KTHREAD || is_migration_disabled(p)) { |
| 2329 | /* | 2344 | /* |
| 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. | ||
| 2331 | * | 2348 | * |
| 2332 | * Specifically, migration_disabled() tasks must not fail the | 2349 | * Specifically, migration_disabled() tasks must not fail the |
| 2333 | * cpumask_any_and_distribute() pick below, esp. so on | 2350 | * 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 | |||
| 2371 | 2388 | ||
| 2372 | __do_set_cpus_allowed(p, new_mask, flags); | 2389 | __do_set_cpus_allowed(p, new_mask, flags); |
| 2373 | 2390 | ||
| 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 | |||
| 2384 | return affine_move_task(rq, p, &rf, dest_cpu, flags); | 2391 | return affine_move_task(rq, p, &rf, dest_cpu, flags); |
| 2385 | 2392 | ||
| 2386 | out: | 2393 | out: |
| @@ -3121,6 +3128,13 @@ bool cpus_share_cache(int this_cpu, int that_cpu) · 734 unmodified lines | |||
| 3121 | 3128 | ||
| 3122 | static inline bool ttwu_queue_cond(int cpu, int wake_flags) | 3129 | static inline bool ttwu_queue_cond(int cpu, int wake_flags) |
| 3123 | { | 3130 | { |
| 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 | |||
| 3124 | /* | 3138 | /* |
| 3125 | * If the CPU does not share cache, then queue the task on the | 3139 | * If the CPU does not share cache, then queue the task on the |
| 3126 | * remote rqs wakelist to avoid accessing remote data. | 3140 | * remote rqs wakelist to avoid accessing remote data. |
| @@ -7390,8 +7404,14 @@ static void balance_push(struct rq *rq) · 4263 unmodified lines | |||
| 7390 | /* | 7404 | /* |
| 7391 | * Both the cpu-hotplug and stop task are in this case and are | 7405 | * Both the cpu-hotplug and stop task are in this case and are |
| 7392 | * required to complete the hotplug process. | 7406 | * required to complete the hotplug process. |
| 7407 | * | ||
| 7408 | * XXX: the idle task does not match kthread_is_per_cpu() due to | ||
| 7409 | * histerical raisins. | ||
| 7393 | */ | 7410 | */ |
| 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 | |||
| 7395 | /* | 7415 | /* |
| 7396 | * If this is the idle task on the outgoing CPU try to wake | 7416 | * If this is the idle task on the outgoing CPU try to wake |
| 7397 | * up the hotplug control thread which might wait for the | 7417 | * up the hotplug control thread which might wait for the |
| @@ -7423,7 +7443,7 @@ static void balance_push(struct rq *rq) · 25 unmodified lines | |||
| 7423 | /* | 7443 | /* |
| 7424 | * At this point need_resched() is true and we'll take the loop in | 7444 | * At this point need_resched() is true and we'll take the loop in |
| 7425 | * schedule(). The next pick is obviously going to be the stop task | 7445 | * 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. |
| 7427 | */ | 7447 | */ |
| 7428 | raw_spin_lock(&rq->lock); | 7448 | raw_spin_lock(&rq->lock); |
| 7429 | } | 7449 | } |
| @@ -7434,10 +7454,13 @@ static void balance_push_set(int cpu, bool on) · 4 unmodified lines | |||
| 7434 | struct rq_flags rf; | 7454 | struct rq_flags rf; |
| 7435 | 7455 | ||
| 7436 | rq_lock_irqsave(rq, &rf); | 7456 | rq_lock_irqsave(rq, &rf); |
| 7437 | if (on) | 7457 | rq->balance_push = on; |
| 7458 | if (on) { | ||
| 7459 | WARN_ON_ONCE(rq->balance_callback); | ||
| 7438 | rq->balance_callback = &balance_push_callback; | 7460 | rq->balance_callback = &balance_push_callback; |
| 7439 | else | 7461 | } else if (rq->balance_callback == &balance_push_callback) { |
| 7440 | rq->balance_callback = NULL; | 7462 | rq->balance_callback = NULL; |
| 7463 | } | ||
| 7441 | rq_unlock_irqrestore(rq, &rf); | 7464 | rq_unlock_irqrestore(rq, &rf); |
| 7442 | } | 7465 | } |
| 7443 | 7466 | ||
| @@ -7555,6 +7578,10 @@ int sched_cpu_activate(unsigned int cpu) · 111 unmodified lines | |||
| 7555 | struct rq *rq = cpu_rq(cpu); | 7578 | struct rq *rq = cpu_rq(cpu); |
| 7556 | struct rq_flags rf; | 7579 | struct rq_flags rf; |
| 7557 | 7580 | ||
| 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 | */ | ||
| 7558 | balance_push_set(cpu, false); | 7585 | balance_push_set(cpu, false); |
| 7559 | 7586 | ||
| 7560 | #ifdef CONFIG_SCHED_SMT | 7587 | #ifdef CONFIG_SCHED_SMT |
| @@ -7603,17 +7630,27 @@ int sched_cpu_deactivate(unsigned int cpu) · 42 unmodified lines | |||
| 7603 | nohz_balance_exit_idle(rq); | 7630 | nohz_balance_exit_idle(rq); |
| 7604 | 7631 | ||
| 7605 | set_cpu_active(cpu, false); | 7632 | 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 | |||
| 7606 | /* | 7642 | /* |
| 7607 | * We've cleared cpu_active_mask, wait for all preempt-disabled and RCU | 7643 | * We've cleared cpu_active_mask / set balance_push, wait for all |
| 7608 | * users of this state to go away such that all new such users will | 7644 | * preempt-disabled and RCU users of this state to go away such that |
| 7609 | * observe it. | 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(). | ||
| 7610 | * | 7649 | * |
| 7611 | * Do sync before park smpboot threads to take care the rcu boost case. | 7650 | * Do sync before park smpboot threads to take care the rcu boost case. |
| 7612 | */ | 7651 | */ |
| 7613 | synchronize_rcu(); | 7652 | synchronize_rcu(); |
| 7614 | 7653 | ||
| 7615 | balance_push_set(cpu, true); | ||
| 7616 | |||
| 7617 | rq_lock_irqsave(rq, &rf); | 7654 | rq_lock_irqsave(rq, &rf); |
| 7618 | if (rq->rd) { | 7655 | if (rq->rd) { |
| 7619 | update_rq_clock(rq); | 7656 | update_rq_clock(rq); |
| @@ -7694,6 +7731,25 @@ static void calc_load_migrate(struct rq *rq) · 74 unmodified lines | |||
| 7694 | atomic_long_add(delta, &calc_load_tasks); | 7731 | atomic_long_add(delta, &calc_load_tasks); |
| 7695 | } | 7732 | } |
| 7696 | 7733 | ||
| 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 | |||
| 7697 | int sched_cpu_dying(unsigned int cpu) | 7753 | int sched_cpu_dying(unsigned int cpu) |
| 7698 | { | 7754 | { |
| 7699 | struct rq *rq = cpu_rq(cpu); | 7755 | struct rq *rq = cpu_rq(cpu); |
| @@ -7703,9 +7759,18 @@ int sched_cpu_dying(unsigned int cpu) · 3 unmodified lines | |||
| 7703 | sched_tick_stop(cpu); | 7759 | sched_tick_stop(cpu); |
| 7704 | 7760 | ||
| 7705 | rq_lock_irqsave(rq, &rf); | 7761 | 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 | } | ||
| 7707 | rq_unlock_irqrestore(rq, &rf); | 7766 | rq_unlock_irqrestore(rq, &rf); |
| 7708 | 7767 | ||
| 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 | |||
| 7709 | calc_load_migrate(rq); | 7774 | calc_load_migrate(rq); |
| 7710 | update_max_interval(); | 7775 | update_max_interval(); |
| 7711 | hrtick_clear(rq); | 7776 | hrtick_clear(rq); |
| @@ -975,6 +975,7 @@ struct rq { · 974 unmodified lines | |||
| 975 | unsigned long cpu_capacity_orig; | 975 | unsigned long cpu_capacity_orig; |
| 976 | 976 | ||
| 977 | struct callback_head *balance_callback; | 977 | struct callback_head *balance_callback; |
| 978 | unsigned char balance_push; | ||
| 978 | 979 | ||
| 979 | unsigned char nohz_idle_balance; | 980 | unsigned char nohz_idle_balance; |
| 980 | unsigned char idle_balance; | 981 | unsigned char idle_balance; |
| @@ -2550,6 +2550,9 @@ bool get_signal(struct ksignal *ksig) · 2549 unmodified lines | |||
| 2550 | struct signal_struct *signal = current->signal; | 2550 | struct signal_struct *signal = current->signal; |
| 2551 | int signr; | 2551 | int signr; |
| 2552 | 2552 | ||
| 2553 | if (unlikely(current->task_works)) | ||
| 2554 | task_work_run(); | ||
| 2555 | |||
| 2553 | /* | 2556 | /* |
| 2554 | * For non-generic architectures, check for TIF_NOTIFY_SIGNAL so | 2557 | * For non-generic architectures, check for TIF_NOTIFY_SIGNAL so |
| 2555 | * that the arch handlers don't all have to do it. If we get here | 2558 | * 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 | |||
| 3701 | return true; | 3704 | return true; |
| 3702 | } | 3705 | } |
| 3703 | 3706 | ||
| 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) | ||
| 3705 | { | 3709 | { |
| 3706 | #ifdef CONFIG_COMPAT | 3710 | #ifdef CONFIG_COMPAT |
| 3707 | /* | 3711 | /* |
| @@ -188,6 +188,7 @@ __smpboot_create_thread(struct smp_hotplug_thread *ht, unsigned int cpu) · 187 unmodified lines | |||
| 188 | kfree(td); | 188 | kfree(td); |
| 189 | return PTR_ERR(tsk); | 189 | return PTR_ERR(tsk); |
| 190 | } | 190 | } |
| 191 | kthread_set_per_cpu(tsk, cpu); | ||
| 191 | /* | 192 | /* |
| 192 | * Park the thread so that it could start right on the CPU | 193 | * Park the thread so that it could start right on the CPU |
| 193 | * when it is available. | 194 | * when it is available. |
| @@ -498,11 +498,11 @@ out: · 497 unmodified lines | |||
| 498 | static void sync_hw_clock(struct work_struct *work); | 498 | static void sync_hw_clock(struct work_struct *work); |
| 499 | static DECLARE_WORK(sync_work, sync_hw_clock); | 499 | static DECLARE_WORK(sync_work, sync_hw_clock); |
| 500 | static struct hrtimer sync_hrtimer; | 500 | 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) |
| 502 | 502 | ||
| 503 | static enum hrtimer_restart sync_timer_callback(struct hrtimer *timer) | 503 | static enum hrtimer_restart sync_timer_callback(struct hrtimer *timer) |
| 504 | { | 504 | { |
| 505 | queue_work(system_power_efficient_wq, &sync_work); | 505 | queue_work(system_freezable_power_efficient_wq, &sync_work); |
| 506 | 506 | ||
| 507 | return HRTIMER_NORESTART; | 507 | return HRTIMER_NORESTART; |
| 508 | } | 508 | } |
| @@ -512,7 +512,7 @@ static void sched_sync_hw_clock(unsigned long offset_nsec, bool retry) · 3 unmodified lines | |||
| 512 | ktime_t exp = ktime_set(ktime_get_real_seconds(), 0); | 512 | ktime_t exp = ktime_set(ktime_get_real_seconds(), 0); |
| 513 | 513 | ||
| 514 | if (retry) | 514 | 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); |
| 516 | else | 516 | else |
| 517 | exp = ktime_add_ns(exp, SYNC_PERIOD_NS - offset_nsec); | 517 | exp = ktime_add_ns(exp, SYNC_PERIOD_NS - offset_nsec); |
| 518 | 518 | ||
| @@ -668,7 +668,7 @@ void ntp_notify_cmos_timer(void) · 149 unmodified lines | |||
| 668 | * just a pointless work scheduled. | 668 | * just a pointless work scheduled. |
| 669 | */ | 669 | */ |
| 670 | if (ntp_synced() && !hrtimer_is_queued(&sync_hrtimer)) | 670 | 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); |
| 672 | } | 672 | } |
| 673 | 673 | ||
| 674 | static void __init ntp_init_cmos_sync(void) | 674 | static void __init ntp_init_cmos_sync(void) |
| @@ -991,8 +991,7 @@ EXPORT_SYMBOL_GPL(ktime_get_seconds); · 990 unmodified lines | |||
| 991 | /** | 991 | /** |
| 992 | * ktime_get_real_seconds - Get the seconds portion of CLOCK_REALTIME | 992 | * ktime_get_real_seconds - Get the seconds portion of CLOCK_REALTIME |
| 993 | * | 993 | * |
| 994 | * Returns the wall clock seconds since 1970. This replaces the | 994 | * Returns the wall clock seconds since 1970. |
| 995 | * get_seconds() interface which is not y2038 safe on 32bit systems. | ||
| 996 | * | 995 | * |
| 997 | * For 64bit systems the fast access to tk->xtime_sec is preserved. On | 996 | * For 64bit systems the fast access to tk->xtime_sec is preserved. On |
| 998 | * 32bit systems the access must be protected with the sequence | 997 | * 32bit systems the access must be protected with the sequence |
| @@ -538,7 +538,7 @@ config KPROBE_EVENTS · 537 unmodified lines | |||
| 538 | config KPROBE_EVENTS_ON_NOTRACE | 538 | config KPROBE_EVENTS_ON_NOTRACE |
| 539 | bool "Do NOT protect notrace function from kprobe events" | 539 | bool "Do NOT protect notrace function from kprobe events" |
| 540 | depends on KPROBE_EVENTS | 540 | depends on KPROBE_EVENTS |
| 541 | depends on KPROBES_ON_FTRACE | 541 | depends on DYNAMIC_FTRACE |
| 542 | default n | 542 | default n |
| 543 | help | 543 | help |
| 544 | This is only for the developers who want to debug ftrace itself | 544 | This is only for the developers who want to debug ftrace itself |
| @@ -96,9 +96,6 @@ unsigned int trace_call_bpf(struct trace_event_call *call, void *ctx) · 95 unmodified lines | |||
| 96 | { | 96 | { |
| 97 | unsigned int ret; | 97 | unsigned int ret; |
| 98 | 98 | ||
| 99 | if (in_nmi()) /* not supported yet */ | ||
| 100 | return 1; | ||
| 101 | |||
| 102 | cant_sleep(); | 99 | cant_sleep(); |
| 103 | 100 | ||
| 104 | if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1)) { | 101 | if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1)) { |
| @@ -394,7 +394,6 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list) · 393 unmodified lines | |||
| 394 | } | 394 | } |
| 395 | 395 | ||
| 396 | if (t->ret_stack == NULL) { | 396 | if (t->ret_stack == NULL) { |
| 397 | atomic_set(&t->tracing_graph_pause, 0); | ||
| 398 | atomic_set(&t->trace_overrun, 0); | 397 | atomic_set(&t->trace_overrun, 0); |
| 399 | t->curr_ret_stack = -1; | 398 | t->curr_ret_stack = -1; |
| 400 | t->curr_ret_depth = -1; | 399 | t->curr_ret_depth = -1; |
| @@ -489,7 +488,6 @@ static DEFINE_PER_CPU(struct ftrace_ret_stack *, idle_ret_stack); · 88 unmodified lines | |||
| 489 | static void | 488 | static void |
| 490 | graph_init_task(struct task_struct *t, struct ftrace_ret_stack *ret_stack) | 489 | graph_init_task(struct task_struct *t, struct ftrace_ret_stack *ret_stack) |
| 491 | { | 490 | { |
| 492 | atomic_set(&t->tracing_graph_pause, 0); | ||
| 493 | atomic_set(&t->trace_overrun, 0); | 491 | atomic_set(&t->trace_overrun, 0); |
| 494 | t->ftrace_timestamp = 0; | 492 | t->ftrace_timestamp = 0; |
| 495 | /* make curr_ret_stack visible before we add the ret_stack */ | 493 | /* make curr_ret_stack visible before we add the ret_stack */ |
| @@ -2745,7 +2745,7 @@ trace_event_buffer_lock_reserve(struct trace_buffer **current_rb, · 2744 unmodified lines | |||
| 2745 | (entry = this_cpu_read(trace_buffered_event))) { | 2745 | (entry = this_cpu_read(trace_buffered_event))) { |
| 2746 | /* Try to use the per cpu buffer first */ | 2746 | /* Try to use the per cpu buffer first */ |
| 2747 | val = this_cpu_inc_return(trace_buffered_event_cnt); | 2747 | val = this_cpu_inc_return(trace_buffered_event_cnt); |
| 2748 | if (val == 1) { | 2748 | if ((len < (PAGE_SIZE - sizeof(*entry))) && val == 1) { |
| 2749 | trace_event_setup(entry, type, flags, pc); | 2749 | trace_event_setup(entry, type, flags, pc); |
| 2750 | entry->array[0] = len; | 2750 | entry->array[0] = len; |
| 2751 | return entry; | 2751 | return entry; |
| @@ -1212,7 +1212,8 @@ system_enable_read(struct file *filp, char __user *ubuf, size_t cnt, · 1211 unmodified lines | |||
| 1212 | mutex_lock(&event_mutex); | 1212 | mutex_lock(&event_mutex); |
| 1213 | list_for_each_entry(file, &tr->events, list) { | 1213 | list_for_each_entry(file, &tr->events, list) { |
| 1214 | call = file->event_call; | 1214 | 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) | ||
| 1216 | continue; | 1217 | continue; |
| 1217 | 1218 | ||
| 1218 | if (system && strcmp(call->class->system, system->name) != 0) | 1219 | if (system && strcmp(call->class->system, system->name) != 0) |
| @@ -562,6 +562,8 @@ static int __irqsoff_tracer_init(struct trace_array *tr) · 561 unmodified lines | |||
| 562 | /* non overwrite screws up the latency tracers */ | 562 | /* non overwrite screws up the latency tracers */ |
| 563 | set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1); | 563 | set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1); |
| 564 | set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, 1); | 564 | 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); | ||
| 565 | 567 | ||
| 566 | tr->max_latency = 0; | 568 | tr->max_latency = 0; |
| 567 | irqsoff_trace = tr; | 569 | irqsoff_trace = tr; |
| @@ -583,11 +585,13 @@ static void __irqsoff_tracer_reset(struct trace_array *tr) · 15 unmodified lines | |||
| 583 | { | 585 | { |
| 584 | int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT; | 586 | int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT; |
| 585 | int overwrite_flag = save_flags & TRACE_ITER_OVERWRITE; | 587 | int overwrite_flag = save_flags & TRACE_ITER_OVERWRITE; |
| 588 | int pause_flag = save_flags & TRACE_ITER_PAUSE_ON_TRACE; | ||
| 586 | 589 | ||
| 587 | stop_irqsoff_tracer(tr, is_graph(tr)); | 590 | stop_irqsoff_tracer(tr, is_graph(tr)); |
| 588 | 591 | ||
| 589 | set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, lat_flag); | 592 | set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, lat_flag); |
| 590 | set_tracer_flag(tr, TRACE_ITER_OVERWRITE, overwrite_flag); | 593 | set_tracer_flag(tr, TRACE_ITER_OVERWRITE, overwrite_flag); |
| 594 | set_tracer_flag(tr, TRACE_ITER_PAUSE_ON_TRACE, pause_flag); | ||
| 591 | ftrace_reset_array_ops(tr); | 595 | ftrace_reset_array_ops(tr); |
| 592 | 596 | ||
| 593 | irqsoff_busy = false; | 597 | irqsoff_busy = false; |
| @@ -221,9 +221,9 @@ bool trace_kprobe_on_func_entry(struct trace_event_call *call) · 220 unmodified lines | |||
| 221 | { | 221 | { |
| 222 | struct trace_kprobe *tk = trace_kprobe_primary_from_call(call); | 222 | struct trace_kprobe *tk = trace_kprobe_primary_from_call(call); |
| 223 | 223 | ||
| 224 | return tk ? kprobe_on_func_entry(tk->rp.kp.addr, | 224 | return tk ? (kprobe_on_func_entry(tk->rp.kp.addr, |
| 225 | tk->rp.kp.addr ? NULL : tk->rp.kp.symbol_name, | 225 | 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; |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | bool trace_kprobe_error_injectable(struct trace_event_call *call) | 229 | 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 | |||
| 434 | return 0; | 434 | return 0; |
| 435 | } | 435 | } |
| 436 | 436 | ||
| 437 | #if defined(CONFIG_KPROBES_ON_FTRACE) && \ | 437 | #if defined(CONFIG_DYNAMIC_FTRACE) && \ |
| 438 | !defined(CONFIG_KPROBE_EVENTS_ON_NOTRACE) | 438 | !defined(CONFIG_KPROBE_EVENTS_ON_NOTRACE) |
| 439 | static bool __within_notrace_func(unsigned long addr) | 439 | static bool __within_notrace_func(unsigned long addr) |
| 440 | { | 440 | { |
| @@ -828,9 +828,11 @@ static int trace_kprobe_create(int argc, const char *argv[]) · 387 unmodified lines | |||
| 828 | } | 828 | } |
| 829 | if (is_return) | 829 | if (is_return) |
| 830 | flags |= TPARG_FL_RETURN; | 830 | 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) | ||
| 832 | flags |= TPARG_FL_FENTRY; | 833 | 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) { | ||
| 834 | trace_probe_log_err(0, BAD_RETPROBE); | 836 | trace_probe_log_err(0, BAD_RETPROBE); |
| 835 | goto parse_error; | 837 | goto parse_error; |
| 836 | } | 838 | } |
| @@ -1848,12 +1848,6 @@ static void worker_attach_to_pool(struct worker *worker, · 1847 unmodified lines | |||
| 1848 | { | 1848 | { |
| 1849 | mutex_lock(&wq_pool_attach_mutex); | 1849 | mutex_lock(&wq_pool_attach_mutex); |
| 1850 | 1850 | ||
| 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 | |||
| 1857 | /* | 1851 | /* |
| 1858 | * The wq_pool_attach_mutex ensures %POOL_DISASSOCIATED remains | 1852 | * The wq_pool_attach_mutex ensures %POOL_DISASSOCIATED remains |
| 1859 | * stable across this function. See the comments above the flag | 1853 | * 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 | |||
| 1861 | */ | 1855 | */ |
| 1862 | if (pool->flags & POOL_DISASSOCIATED) | 1856 | if (pool->flags & POOL_DISASSOCIATED) |
| 1863 | worker->flags |= WORKER_UNBOUND; | 1857 | 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); | ||
| 1864 | 1863 | ||
| 1865 | list_add_tail(&worker->node, &pool->workers); | 1864 | list_add_tail(&worker->node, &pool->workers); |
| 1866 | worker->pool = pool; | 1865 | worker->pool = pool; |
| @@ -1883,6 +1882,7 @@ static void worker_detach_from_pool(struct worker *worker) · 16 unmodified lines | |||
| 1883 | 1882 | ||
| 1884 | mutex_lock(&wq_pool_attach_mutex); | 1883 | mutex_lock(&wq_pool_attach_mutex); |
| 1885 | 1884 | ||
| 1885 | kthread_set_per_cpu(worker->task, -1); | ||
| 1886 | list_del(&worker->node); | 1886 | list_del(&worker->node); |
| 1887 | worker->pool = NULL; | 1887 | worker->pool = NULL; |
| 1888 | 1888 | ||
| @@ -4919,8 +4919,10 @@ static void unbind_workers(int cpu) · 3030 unmodified lines | |||
| 4919 | 4919 | ||
| 4920 | raw_spin_unlock_irq(&pool->lock); | 4920 | raw_spin_unlock_irq(&pool->lock); |
| 4921 | 4921 | ||
| 4922 | for_each_pool_worker(worker, pool) | 4922 | for_each_pool_worker(worker, pool) { |
| 4923 | WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, cpu_active_mask) < 0); | 4923 | kthread_set_per_cpu(worker->task, -1); |
| 4924 | WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, cpu_possible_mask) < 0); | ||
| 4925 | } | ||
| 4924 | 4926 | ||
| 4925 | mutex_unlock(&wq_pool_attach_mutex); | 4927 | mutex_unlock(&wq_pool_attach_mutex); |
| 4926 | 4928 | ||
| @@ -4972,9 +4974,11 @@ static void rebind_workers(struct worker_pool *pool) · 45 unmodified lines | |||
| 4972 | * of all workers first and then clear UNBOUND. As we're called | 4974 | * of all workers first and then clear UNBOUND. As we're called |
| 4973 | * from CPU_ONLINE, the following shouldn't fail. | 4975 | * from CPU_ONLINE, the following shouldn't fail. |
| 4974 | */ | 4976 | */ |
| 4975 | for_each_pool_worker(worker, pool) | 4977 | for_each_pool_worker(worker, pool) { |
| 4978 | kthread_set_per_cpu(worker->task, pool->cpu); | ||
| 4976 | WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, | 4979 | WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, |
| 4977 | pool->attrs->cpumask) < 0); | 4980 | pool->attrs->cpumask) < 0); |
| 4981 | } | ||
| 4978 | 4982 | ||
| 4979 | raw_spin_lock_irq(&pool->lock); | 4983 | raw_spin_lock_irq(&pool->lock); |
| 4980 | 4984 | ||