Showing the changes to kernel (21 of 868 files). Show all
Unified · Split
| @@ -1326,6 +1326,9 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · 1325 unmodified lines | ||
| 1326 | 1326 | case AUDIT_FIRST_USER_MSG2 ... AUDIT_LAST_USER_MSG2: |
| 1327 | 1327 | if (!audit_enabled && msg_type != AUDIT_USER_AVC) |
| 1328 | 1328 | return 0; |
| 1329 | + /* exit early if there isn't at least one character to print */ | |
| 1330 | + if (data_len < 2) | |
| 1331 | + return -EINVAL; | |
| 1329 | 1332 | |
| 1330 | 1333 | err = audit_filter(msg_type, AUDIT_FILTER_USER); |
| 1331 | 1334 | if (err == 1) { /* match or error */ |
| @@ -469,7 +469,7 @@ static int cpu_map_update_elem(struct bpf_map *map, void *key, void *value, · 468 unmodified lines | ||
| 469 | 469 | return -EOVERFLOW; |
| 470 | 470 | |
| 471 | 471 | /* Make sure CPU is a valid possible cpu */ |
| 472 | − if (!cpu_possible(key_cpu)) | |
| 472 | + if (key_cpu >= nr_cpumask_bits || !cpu_possible(key_cpu)) | |
| 473 | 473 | return -ENODEV; |
| 474 | 474 | |
| 475 | 475 | if (qsize == 0) { |
| @@ -2283,7 +2283,7 @@ static void bpf_link_show_fdinfo(struct seq_file *m, struct file *filp) · 2282 unmodified lines | ||
| 2283 | 2283 | } |
| 2284 | 2284 | #endif |
| 2285 | 2285 | |
| 2286 | −const struct file_operations bpf_link_fops = { | |
| 2286 | +static const struct file_operations bpf_link_fops = { | |
| 2287 | 2287 | #ifdef CONFIG_PROC_FS |
| 2288 | 2288 | .show_fdinfo = bpf_link_show_fdinfo, |
| 2289 | 2289 | #endif |
| @@ -3628,8 +3628,10 @@ static int link_update(union bpf_attr *attr) · 1338 unmodified lines | ||
| 3628 | 3628 | return PTR_ERR(link); |
| 3629 | 3629 | |
| 3630 | 3630 | new_prog = bpf_prog_get(attr->link_update.new_prog_fd); |
| 3631 | − if (IS_ERR(new_prog)) | |
| 3632 | − return PTR_ERR(new_prog); | |
| 3631 | + if (IS_ERR(new_prog)) { | |
| 3632 | + ret = PTR_ERR(new_prog); | |
| 3633 | + goto out_put_link; | |
| 3634 | + } | |
| 3633 | 3635 | |
| 3634 | 3636 | if (flags & BPF_F_REPLACE) { |
| 3635 | 3637 | old_prog = bpf_prog_get(attr->link_update.old_prog_fd); |
| @@ -3638,6 +3640,9 @@ static int link_update(union bpf_attr *attr) · 2 unmodified lines | ||
| 3638 | 3640 | old_prog = NULL; |
| 3639 | 3641 | goto out_put_progs; |
| 3640 | 3642 | } |
| 3643 | + } else if (attr->link_update.old_prog_fd) { | |
| 3644 | + ret = -EINVAL; | |
| 3645 | + goto out_put_progs; | |
| 3641 | 3646 | } |
| 3642 | 3647 | |
| 3643 | 3648 | #ifdef CONFIG_CGROUP_BPF |
| @@ -3653,6 +3658,8 @@ out_put_progs: · 9 unmodified lines | ||
| 3653 | 3658 | bpf_prog_put(old_prog); |
| 3654 | 3659 | if (ret) |
| 3655 | 3660 | bpf_prog_put(new_prog); |
| 3661 | +out_put_link: | |
| 3662 | + bpf_link_put(link); | |
| 3656 | 3663 | return ret; |
| 3657 | 3664 | } |
| 3658 | 3665 | |
| @@ -2118,6 +2118,15 @@ static bool register_is_const(struct bpf_reg_state *reg) · 2117 unmodified lines | ||
| 2118 | 2118 | return reg->type == SCALAR_VALUE && tnum_is_const(reg->var_off); |
| 2119 | 2119 | } |
| 2120 | 2120 | |
| 2121 | +static bool __is_pointer_value(bool allow_ptr_leaks, | |
| 2122 | + const struct bpf_reg_state *reg) | |
| 2123 | +{ | |
| 2124 | + if (allow_ptr_leaks) | |
| 2125 | + return false; | |
| 2126 | + | |
| 2127 | + return reg->type != SCALAR_VALUE; | |
| 2128 | +} | |
| 2129 | + | |
| 2121 | 2130 | static void save_register_state(struct bpf_func_state *state, |
| 2122 | 2131 | int spi, struct bpf_reg_state *reg) |
| 2123 | 2132 | { |
| @@ -2308,6 +2317,16 @@ static int check_stack_read(struct bpf_verifier_env *env, · 184 unmodified lines | ||
| 2308 | 2317 | * which resets stack/reg liveness for state transitions |
| 2309 | 2318 | */ |
| 2310 | 2319 | state->regs[value_regno].live |= REG_LIVE_WRITTEN; |
| 2320 | + } else if (__is_pointer_value(env->allow_ptr_leaks, reg)) { | |
| 2321 | + /* If value_regno==-1, the caller is asking us whether | |
| 2322 | + * it is acceptable to use this value as a SCALAR_VALUE | |
| 2323 | + * (e.g. for XADD). | |
| 2324 | + * We must not allow unprivileged callers to do that | |
| 2325 | + * with spilled pointers. | |
| 2326 | + */ | |
| 2327 | + verbose(env, "leaking pointer from stack off %d\n", | |
| 2328 | + off); | |
| 2329 | + return -EACCES; | |
| 2311 | 2330 | } |
| 2312 | 2331 | mark_reg_read(env, reg, reg->parent, REG_LIVE_READ64); |
| 2313 | 2332 | } else { |
| @@ -2673,15 +2692,6 @@ static int check_sock_access(struct bpf_verifier_env *env, int insn_idx, · 359 unmodified lines | ||
| 2673 | 2692 | return -EACCES; |
| 2674 | 2693 | } |
| 2675 | 2694 | |
| 2676 | −static bool __is_pointer_value(bool allow_ptr_leaks, | |
| 2677 | − const struct bpf_reg_state *reg) | |
| 2678 | −{ | |
| 2679 | − if (allow_ptr_leaks) | |
| 2680 | − return false; | |
| 2681 | − | |
| 2682 | − return reg->type != SCALAR_VALUE; | |
| 2683 | −} | |
| 2684 | − | |
| 2685 | 2695 | static struct bpf_reg_state *reg_state(struct bpf_verifier_env *env, int regno) |
| 2686 | 2696 | { |
| 2687 | 2697 | return cur_regs(env) + regno; |
| @@ -3089,7 +3099,7 @@ static int check_ptr_to_btf_access(struct bpf_verifier_env *env, · 401 unmodified lines | ||
| 3089 | 3099 | if (ret < 0) |
| 3090 | 3100 | return ret; |
| 3091 | 3101 | |
| 3092 | − if (atype == BPF_READ) { | |
| 3102 | + if (atype == BPF_READ && value_regno >= 0) { | |
| 3093 | 3103 | if (ret == SCALAR_VALUE) { |
| 3094 | 3104 | mark_reg_unknown(env, regs, value_regno); |
| 3095 | 3105 | return 0; |
| @@ -10487,6 +10497,7 @@ static int check_attach_btf_id(struct bpf_verifier_env *env) · 7391 unmodified lines | ||
| 10487 | 10497 | return -EINVAL; |
| 10488 | 10498 | } |
| 10489 | 10499 | env->ops = bpf_verifier_ops[tgt_prog->type]; |
| 10500 | + prog->expected_attach_type = tgt_prog->expected_attach_type; | |
| 10490 | 10501 | } |
| 10491 | 10502 | if (!tgt_prog->jited) { |
| 10492 | 10503 | verbose(env, "Can attach to only JITed progs\n"); |
| @@ -10831,6 +10842,13 @@ err_release_maps: · 338 unmodified lines | ||
| 10831 | 10842 | * them now. Otherwise free_used_maps() will release them. |
| 10832 | 10843 | */ |
| 10833 | 10844 | release_maps(env); |
| 10845 | + | |
| 10846 | + /* extension progs temporarily inherit the attach_type of their targets | |
| 10847 | + for verification purposes, so set it back to zero before returning | |
| 10848 | + */ | |
| 10849 | + if (env->prog->type == BPF_PROG_TYPE_EXT) | |
| 10850 | + env->prog->expected_attach_type = 0; | |
| 10851 | + | |
| 10834 | 10852 | *prog = env->prog; |
| 10835 | 10853 | err_unlock: |
| 10836 | 10854 | if (!is_priv) |
| @@ -7491,10 +7491,17 @@ static void perf_event_task_output(struct perf_event *event, · 7490 unmodified lines | ||
| 7491 | 7491 | goto out; |
| 7492 | 7492 | |
| 7493 | 7493 | task_event->event_id.pid = perf_event_pid(event, task); |
| 7494 | − task_event->event_id.ppid = perf_event_pid(event, current); | |
| 7495 | − | |
| 7496 | 7494 | task_event->event_id.tid = perf_event_tid(event, task); |
| 7497 | − task_event->event_id.ptid = perf_event_tid(event, current); | |
| 7495 | + | |
| 7496 | + if (task_event->event_id.header.type == PERF_RECORD_EXIT) { | |
| 7497 | + task_event->event_id.ppid = perf_event_pid(event, | |
| 7498 | + task->real_parent); | |
| 7499 | + task_event->event_id.ptid = perf_event_pid(event, | |
| 7500 | + task->real_parent); | |
| 7501 | + } else { /* PERF_RECORD_FORK */ | |
| 7502 | + task_event->event_id.ppid = perf_event_pid(event, current); | |
| 7503 | + task_event->event_id.ptid = perf_event_tid(event, current); | |
| 7504 | + } | |
| 7498 | 7505 | |
| 7499 | 7506 | task_event->event_id.time = perf_event_clock(event); |
| 7500 | 7507 | |
| @@ -219,6 +219,7 @@ repeat: · 218 unmodified lines | ||
| 219 | 219 | |
| 220 | 220 | write_unlock_irq(&tasklist_lock); |
| 221 | 221 | proc_flush_pid(thread_pid); |
| 222 | + put_pid(thread_pid); | |
| 222 | 223 | release_thread(p); |
| 223 | 224 | put_task_struct_rcu_user(p); |
| 224 | 225 | |
| @@ -740,8 +740,8 @@ static const struct file_operations kcov_fops = { · 739 unmodified lines | ||
| 740 | 740 | * kcov_remote_handle() with KCOV_SUBSYSTEM_COMMON as the subsystem id and an |
| 741 | 741 | * arbitrary 4-byte non-zero number as the instance id). This common handle |
| 742 | 742 | * then gets saved into the task_struct of the process that issued the |
| 743 | − * KCOV_REMOTE_ENABLE ioctl. When this proccess issues system calls that spawn | |
| 744 | − * kernel threads, the common handle must be retrived via kcov_common_handle() | |
| 743 | + * KCOV_REMOTE_ENABLE ioctl. When this process issues system calls that spawn | |
| 744 | + * kernel threads, the common handle must be retrieved via kcov_common_handle() | |
| 745 | 745 | * and passed to the spawned threads via custom annotations. Those kernel |
| 746 | 746 | * threads must in turn be annotated with kcov_remote_start(common_handle) and |
| 747 | 747 | * kcov_remote_stop(). All of the threads that are spawned by the same process |
| @@ -3635,13 +3635,10 @@ mark_held_locks(struct task_struct *curr, enum lock_usage_bit base_bit) · 3634 unmodified lines | ||
| 3635 | 3635 | /* |
| 3636 | 3636 | * Hardirqs will be enabled: |
| 3637 | 3637 | */ |
| 3638 | −static void __trace_hardirqs_on_caller(unsigned long ip) | |
| 3638 | +static void __trace_hardirqs_on_caller(void) | |
| 3639 | 3639 | { |
| 3640 | 3640 | struct task_struct *curr = current; |
| 3641 | 3641 | |
| 3642 | − /* we'll do an OFF -> ON transition: */ | |
| 3643 | − curr->hardirqs_enabled = 1; | |
| 3644 | − | |
| 3645 | 3642 | /* |
| 3646 | 3643 | * We are going to turn hardirqs on, so set the |
| 3647 | 3644 | * usage bit for all held locks: |
| @@ -3654,15 +3651,19 @@ static void __trace_hardirqs_on_caller(unsigned long ip) · 6 unmodified lines | ||
| 3654 | 3651 | * this bit from being set before) |
| 3655 | 3652 | */ |
| 3656 | 3653 | if (curr->softirqs_enabled) |
| 3657 | − if (!mark_held_locks(curr, LOCK_ENABLED_SOFTIRQ)) | |
| 3658 | − return; | |
| 3659 | − | |
| 3660 | − curr->hardirq_enable_ip = ip; | |
| 3661 | − curr->hardirq_enable_event = ++curr->irq_events; | |
| 3662 | − debug_atomic_inc(hardirqs_on_events); | |
| 3654 | + mark_held_locks(curr, LOCK_ENABLED_SOFTIRQ); | |
| 3663 | 3655 | } |
| 3664 | 3656 | |
| 3665 | −void lockdep_hardirqs_on(unsigned long ip) | |
| 3657 | +/** | |
| 3658 | + * lockdep_hardirqs_on_prepare - Prepare for enabling interrupts | |
| 3659 | + * @ip: Caller address | |
| 3660 | + * | |
| 3661 | + * Invoked before a possible transition to RCU idle from exit to user or | |
| 3662 | + * guest mode. This ensures that all RCU operations are done before RCU | |
| 3663 | + * stops watching. After the RCU transition lockdep_hardirqs_on() has to be | |
| 3664 | + * invoked to set the final state. | |
| 3665 | + */ | |
| 3666 | +void lockdep_hardirqs_on_prepare(unsigned long ip) | |
| 3666 | 3667 | { |
| 3667 | 3668 | if (unlikely(!debug_locks || current->lockdep_recursion)) |
| 3668 | 3669 | return; |
| @@ -3698,20 +3699,62 @@ void lockdep_hardirqs_on(unsigned long ip) · 29 unmodified lines | ||
| 3698 | 3699 | if (DEBUG_LOCKS_WARN_ON(current->hardirq_context)) |
| 3699 | 3700 | return; |
| 3700 | 3701 | |
| 3702 | + current->hardirq_chain_key = current->curr_chain_key; | |
| 3703 | + | |
| 3701 | 3704 | current->lockdep_recursion++; |
| 3702 | − __trace_hardirqs_on_caller(ip); | |
| 3705 | + __trace_hardirqs_on_caller(); | |
| 3703 | 3706 | lockdep_recursion_finish(); |
| 3704 | 3707 | } |
| 3705 | −NOKPROBE_SYMBOL(lockdep_hardirqs_on); | |
| 3708 | +EXPORT_SYMBOL_GPL(lockdep_hardirqs_on_prepare); | |
| 3709 | + | |
| 3710 | +void noinstr lockdep_hardirqs_on(unsigned long ip) | |
| 3711 | +{ | |
| 3712 | + struct task_struct *curr = current; | |
| 3713 | + | |
| 3714 | + if (unlikely(!debug_locks || curr->lockdep_recursion)) | |
| 3715 | + return; | |
| 3716 | + | |
| 3717 | + if (curr->hardirqs_enabled) { | |
| 3718 | + /* | |
| 3719 | + * Neither irq nor preemption are disabled here | |
| 3720 | + * so this is racy by nature but losing one hit | |
| 3721 | + * in a stat is not a big deal. | |
| 3722 | + */ | |
| 3723 | + __debug_atomic_inc(redundant_hardirqs_on); | |
| 3724 | + return; | |
| 3725 | + } | |
| 3726 | + | |
| 3727 | + /* | |
| 3728 | + * We're enabling irqs and according to our state above irqs weren't | |
| 3729 | + * already enabled, yet we find the hardware thinks they are in fact | |
| 3730 | + * enabled.. someone messed up their IRQ state tracing. | |
| 3731 | + */ | |
| 3732 | + if (DEBUG_LOCKS_WARN_ON(!irqs_disabled())) | |
| 3733 | + return; | |
| 3734 | + | |
| 3735 | + /* | |
| 3736 | + * Ensure the lock stack remained unchanged between | |
| 3737 | + * lockdep_hardirqs_on_prepare() and lockdep_hardirqs_on(). | |
| 3738 | + */ | |
| 3739 | + DEBUG_LOCKS_WARN_ON(current->hardirq_chain_key != | |
| 3740 | + current->curr_chain_key); | |
| 3741 | + | |
| 3742 | + /* we'll do an OFF -> ON transition: */ | |
| 3743 | + curr->hardirqs_enabled = 1; | |
| 3744 | + curr->hardirq_enable_ip = ip; | |
| 3745 | + curr->hardirq_enable_event = ++curr->irq_events; | |
| 3746 | + debug_atomic_inc(hardirqs_on_events); | |
| 3747 | +} | |
| 3748 | +EXPORT_SYMBOL_GPL(lockdep_hardirqs_on); | |
| 3706 | 3749 | |
| 3707 | 3750 | /* |
| 3708 | 3751 | * Hardirqs were disabled: |
| 3709 | 3752 | */ |
| 3710 | −void lockdep_hardirqs_off(unsigned long ip) | |
| 3753 | +void noinstr lockdep_hardirqs_off(unsigned long ip) | |
| 3711 | 3754 | { |
| 3712 | 3755 | struct task_struct *curr = current; |
| 3713 | 3756 | |
| 3714 | − if (unlikely(!debug_locks || current->lockdep_recursion)) | |
| 3757 | + if (unlikely(!debug_locks || curr->lockdep_recursion)) | |
| 3715 | 3758 | return; |
| 3716 | 3759 | |
| 3717 | 3760 | /* |
| @@ -3729,10 +3772,11 @@ void lockdep_hardirqs_off(unsigned long ip) · 11 unmodified lines | ||
| 3729 | 3772 | curr->hardirq_disable_ip = ip; |
| 3730 | 3773 | curr->hardirq_disable_event = ++curr->irq_events; |
| 3731 | 3774 | debug_atomic_inc(hardirqs_off_events); |
| 3732 | − } else | |
| 3775 | + } else { | |
| 3733 | 3776 | debug_atomic_inc(redundant_hardirqs_off); |
| 3777 | + } | |
| 3734 | 3778 | } |
| 3735 | −NOKPROBE_SYMBOL(lockdep_hardirqs_off); | |
| 3779 | +EXPORT_SYMBOL_GPL(lockdep_hardirqs_off); | |
| 3736 | 3780 | |
| 3737 | 3781 | /* |
| 3738 | 3782 | * Softirqs will be enabled: |
| @@ -4408,8 +4452,8 @@ static void print_unlock_imbalance_bug(struct task_struct *curr, · 669 unmodified lines | ||
| 4408 | 4452 | dump_stack(); |
| 4409 | 4453 | } |
| 4410 | 4454 | |
| 4411 | −static int match_held_lock(const struct held_lock *hlock, | |
| 4412 | − const struct lockdep_map *lock) | |
| 4455 | +static noinstr int match_held_lock(const struct held_lock *hlock, | |
| 4456 | + const struct lockdep_map *lock) | |
| 4413 | 4457 | { |
| 4414 | 4458 | if (hlock->instance == lock) |
| 4415 | 4459 | return 1; |
| @@ -4696,7 +4740,7 @@ __lock_release(struct lockdep_map *lock, unsigned long ip) · 280 unmodified lines | ||
| 4696 | 4740 | return 0; |
| 4697 | 4741 | } |
| 4698 | 4742 | |
| 4699 | −static nokprobe_inline | |
| 4743 | +static __always_inline | |
| 4700 | 4744 | int __lock_is_held(const struct lockdep_map *lock, int read) |
| 4701 | 4745 | { |
| 4702 | 4746 | struct task_struct *curr = current; |
| @@ -4956,7 +5000,7 @@ void lock_release(struct lockdep_map *lock, unsigned long ip) · 253 unmodified lines | ||
| 4956 | 5000 | } |
| 4957 | 5001 | EXPORT_SYMBOL_GPL(lock_release); |
| 4958 | 5002 | |
| 4959 | −int lock_is_held_type(const struct lockdep_map *lock, int read) | |
| 5003 | +noinstr int lock_is_held_type(const struct lockdep_map *lock, int read) | |
| 4960 | 5004 | { |
| 4961 | 5005 | unsigned long flags; |
| 4962 | 5006 | int ret = 0; |
| @@ -898,6 +898,13 @@ static int software_resume(void) · 897 unmodified lines | ||
| 898 | 898 | error = freeze_processes(); |
| 899 | 899 | if (error) |
| 900 | 900 | goto Close_Finish; |
| 901 | + | |
| 902 | + error = freeze_kernel_threads(); | |
| 903 | + if (error) { | |
| 904 | + thaw_processes(); | |
| 905 | + goto Close_Finish; | |
| 906 | + } | |
| 907 | + | |
| 901 | 908 | error = load_image_and_restore(); |
| 902 | 909 | thaw_processes(); |
| 903 | 910 | Finish: |
| @@ -1232,13 +1232,8 @@ static void uclamp_fork(struct task_struct *p) · 1231 unmodified lines | ||
| 1232 | 1232 | return; |
| 1233 | 1233 | |
| 1234 | 1234 | for_each_clamp_id(clamp_id) { |
| 1235 | − unsigned int clamp_value = uclamp_none(clamp_id); | |
| 1236 | − | |
| 1237 | − /* By default, RT tasks always get 100% boost */ | |
| 1238 | − if (unlikely(rt_task(p) && clamp_id == UCLAMP_MIN)) | |
| 1239 | − clamp_value = uclamp_none(UCLAMP_MAX); | |
| 1240 | − | |
| 1241 | − uclamp_se_set(&p->uclamp_req[clamp_id], clamp_value, false); | |
| 1235 | + uclamp_se_set(&p->uclamp_req[clamp_id], | |
| 1236 | + uclamp_none(clamp_id), false); | |
| 1242 | 1237 | } |
| 1243 | 1238 | } |
| 1244 | 1239 | |
| @@ -1989,8 +1989,12 @@ bool do_notify_parent(struct task_struct *tsk, int sig) · 1988 unmodified lines | ||
| 1989 | 1989 | if (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN) |
| 1990 | 1990 | sig = 0; |
| 1991 | 1991 | } |
| 1992 | + /* | |
| 1993 | + * Send with __send_signal as si_pid and si_uid are in the | |
| 1994 | + * parent's namespaces. | |
| 1995 | + */ | |
| 1992 | 1996 | if (valid_signal(sig) && sig) |
| 1993 | − __group_send_sig_info(sig, &info, tsk->parent); | |
| 1997 | + __send_signal(sig, &info, tsk->parent, PIDTYPE_TGID, false); | |
| 1994 | 1998 | __wake_up_parent(tsk, tsk->parent); |
| 1995 | 1999 | spin_unlock_irqrestore(&psig->siglock, flags); |
| 1996 | 2000 | |
| @@ -466,7 +466,6 @@ config PROFILE_ANNOTATED_BRANCHES · 465 unmodified lines | ||
| 466 | 466 | config PROFILE_ALL_BRANCHES |
| 467 | 467 | bool "Profile all if conditionals" if !FORTIFY_SOURCE |
| 468 | 468 | select TRACE_BRANCH_PROFILING |
| 469 | − imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives | |
| 470 | 469 | help |
| 471 | 470 | This tracer profiles all branch conditions. Every if () |
| 472 | 471 | taken in the kernel is recorded whether it hit or miss. |
| @@ -5165,6 +5165,7 @@ int unregister_ftrace_direct(unsigned long ip, unsigned long addr) · 5164 unmodified lines | ||
| 5165 | 5165 | list_del_rcu(&direct->next); |
| 5166 | 5166 | synchronize_rcu_tasks(); |
| 5167 | 5167 | kfree(direct); |
| 5168 | + kfree(entry); | |
| 5168 | 5169 | ftrace_direct_func_count--; |
| 5169 | 5170 | } |
| 5170 | 5171 | } |
| @@ -113,22 +113,42 @@ static int preemptirq_delay_run(void *data) · 112 unmodified lines | ||
| 113 | 113 | |
| 114 | 114 | for (i = 0; i < s; i++) |
| 115 | 115 | (testfuncs[i])(i); |
| 116 | + | |
| 117 | + set_current_state(TASK_INTERRUPTIBLE); | |
| 118 | + while (!kthread_should_stop()) { | |
| 119 | + schedule(); | |
| 120 | + set_current_state(TASK_INTERRUPTIBLE); | |
| 121 | + } | |
| 122 | + | |
| 123 | + __set_current_state(TASK_RUNNING); | |
| 124 | + | |
| 116 | 125 | return 0; |
| 117 | 126 | } |
| 118 | 127 | |
| 119 | −static struct task_struct *preemptirq_start_test(void) | |
| 128 | +static int preemptirq_run_test(void) | |
| 120 | 129 | { |
| 130 | + struct task_struct *task; | |
| 131 | + | |
| 121 | 132 | char task_name[50]; |
| 122 | 133 | |
| 123 | 134 | snprintf(task_name, sizeof(task_name), "%s_test", test_mode); |
| 124 | − return kthread_run(preemptirq_delay_run, NULL, task_name); | |
| 135 | + task = kthread_run(preemptirq_delay_run, NULL, task_name); | |
| 136 | + if (IS_ERR(task)) | |
| 137 | + return PTR_ERR(task); | |
| 138 | + if (task) | |
| 139 | + kthread_stop(task); | |
| 140 | + return 0; | |
| 125 | 141 | } |
| 126 | 142 | |
| 127 | 143 | |
| 128 | 144 | static ssize_t trigger_store(struct kobject *kobj, struct kobj_attribute *attr, |
| 129 | 145 | const char *buf, size_t count) |
| 130 | 146 | { |
| 131 | − preemptirq_start_test(); | |
| 147 | + ssize_t ret; | |
| 148 | + | |
| 149 | + ret = preemptirq_run_test(); | |
| 150 | + if (ret) | |
| 151 | + return ret; | |
| 132 | 152 | return count; |
| 133 | 153 | } |
| 134 | 154 | |
| @@ -148,11 +168,9 @@ static struct kobject *preemptirq_delay_kobj; · 13 unmodified lines | ||
| 148 | 168 | |
| 149 | 169 | static int __init preemptirq_delay_init(void) |
| 150 | 170 | { |
| 151 | − struct task_struct *test_task; | |
| 152 | 171 | int retval; |
| 153 | 172 | |
| 154 | − test_task = preemptirq_start_test(); | |
| 155 | − retval = PTR_ERR_OR_ZERO(test_task); | |
| 173 | + retval = preemptirq_run_test(); | |
| 156 | 174 | if (retval != 0) |
| 157 | 175 | return retval; |
| 158 | 176 | |
| @@ -947,7 +947,8 @@ int __trace_bputs(unsigned long ip, const char *str) · 946 unmodified lines | ||
| 947 | 947 | EXPORT_SYMBOL_GPL(__trace_bputs); |
| 948 | 948 | |
| 949 | 949 | #ifdef CONFIG_TRACER_SNAPSHOT |
| 950 | −void tracing_snapshot_instance_cond(struct trace_array *tr, void *cond_data) | |
| 950 | +static void tracing_snapshot_instance_cond(struct trace_array *tr, | |
| 951 | + void *cond_data) | |
| 951 | 952 | { |
| 952 | 953 | struct tracer *tracer = tr->current_trace; |
| 953 | 954 | unsigned long flags; |
| @@ -8525,6 +8526,19 @@ static int allocate_trace_buffers(struct trace_array *tr, int size) · 7571 unmodified lines | ||
| 8525 | 8526 | */ |
| 8526 | 8527 | allocate_snapshot = false; |
| 8527 | 8528 | #endif |
| 8529 | + | |
| 8530 | + /* | |
| 8531 | + * Because of some magic with the way alloc_percpu() works on | |
| 8532 | + * x86_64, we need to synchronize the pgd of all the tables, | |
| 8533 | + * otherwise the trace events that happen in x86_64 page fault | |
| 8534 | + * handlers can't cope with accessing the chance that a | |
| 8535 | + * alloc_percpu()'d memory might be touched in the page fault trace | |
| 8536 | + * event. Oh, and we need to audit all other alloc_percpu() and vmalloc() | |
| 8537 | + * calls in tracing, because something might get triggered within a | |
| 8538 | + * page fault trace event! | |
| 8539 | + */ | |
| 8540 | + vmalloc_sync_mappings(); | |
| 8541 | + | |
| 8528 | 8542 | return 0; |
| 8529 | 8543 | } |
| 8530 | 8544 | |
| @@ -95,24 +95,20 @@ trace_boot_add_kprobe_event(struct xbc_node *node, const char *event) · 94 unmodified lines | ||
| 95 | 95 | struct xbc_node *anode; |
| 96 | 96 | char buf[MAX_BUF_LEN]; |
| 97 | 97 | const char *val; |
| 98 | − int ret; | |
| 98 | + int ret = 0; | |
| 99 | 99 | |
| 100 | − kprobe_event_cmd_init(&cmd, buf, MAX_BUF_LEN); | |
| 100 | + xbc_node_for_each_array_value(node, "probes", anode, val) { | |
| 101 | + kprobe_event_cmd_init(&cmd, buf, MAX_BUF_LEN); | |
| 101 | 102 | |
| 102 | − ret = kprobe_event_gen_cmd_start(&cmd, event, NULL); | |
| 103 | − if (ret) | |
| 104 | − return ret; | |
| 103 | + ret = kprobe_event_gen_cmd_start(&cmd, event, val); | |
| 104 | + if (ret) | |
| 105 | + break; | |
| 105 | 106 | |
| 106 | − xbc_node_for_each_array_value(node, "probes", anode, val) { | |
| 107 | − ret = kprobe_event_add_field(&cmd, val); | |
| 107 | + ret = kprobe_event_gen_cmd_end(&cmd); | |
| 108 | 108 | if (ret) |
| 109 | − return ret; | |
| 109 | + pr_err("Failed to add probe: %s\n", buf); | |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | − ret = kprobe_event_gen_cmd_end(&cmd); | |
| 113 | − if (ret) | |
| 114 | − pr_err("Failed to add probe: %s\n", buf); | |
| 115 | − | |
| 116 | 112 | return ret; |
| 117 | 113 | } |
| 118 | 114 | #else |
| @@ -3320,6 +3320,9 @@ static void __destroy_hist_field(struct hist_field *hist_field) · 3319 unmodified lines | ||
| 3320 | 3320 | kfree(hist_field->name); |
| 3321 | 3321 | kfree(hist_field->type); |
| 3322 | 3322 | |
| 3323 | + kfree(hist_field->system); | |
| 3324 | + kfree(hist_field->event_name); | |
| 3325 | + | |
| 3323 | 3326 | kfree(hist_field); |
| 3324 | 3327 | } |
| 3325 | 3328 | |
| @@ -4382,6 +4385,7 @@ static struct hist_field *create_var(struct hist_trigger_data *hist_data, · 1056 unmodified lines | ||
| 4382 | 4385 | goto out; |
| 4383 | 4386 | } |
| 4384 | 4387 | |
| 4388 | + var->ref = 1; | |
| 4385 | 4389 | var->flags = HIST_FIELD_FL_VAR; |
| 4386 | 4390 | var->var.idx = idx; |
| 4387 | 4391 | var->var.hist_data = var->hist_data = hist_data; |
| @@ -5011,6 +5015,9 @@ static void destroy_field_vars(struct hist_trigger_data *hist_data) · 623 unmodified lines | ||
| 5011 | 5015 | |
| 5012 | 5016 | for (i = 0; i < hist_data->n_field_vars; i++) |
| 5013 | 5017 | destroy_field_var(hist_data->field_vars[i]); |
| 5018 | + | |
| 5019 | + for (i = 0; i < hist_data->n_save_vars; i++) | |
| 5020 | + destroy_field_var(hist_data->save_vars[i]); | |
| 5014 | 5021 | } |
| 5015 | 5022 | |
| 5016 | 5023 | static void save_field_var(struct hist_trigger_data *hist_data, |
| @@ -453,7 +453,7 @@ static bool __within_notrace_func(unsigned long addr) · 452 unmodified lines | ||
| 453 | 453 | |
| 454 | 454 | static bool within_notrace_func(struct trace_kprobe *tk) |
| 455 | 455 | { |
| 456 | − unsigned long addr = addr = trace_kprobe_address(tk); | |
| 456 | + unsigned long addr = trace_kprobe_address(tk); | |
| 457 | 457 | char symname[KSYM_NAME_LEN], *p; |
| 458 | 458 | |
| 459 | 459 | if (!__within_notrace_func(addr)) |
| @@ -940,6 +940,9 @@ EXPORT_SYMBOL_GPL(kprobe_event_cmd_init); · 480 unmodified lines | ||
| 940 | 940 | * complete command or only the first part of it; in the latter case, |
| 941 | 941 | * kprobe_event_add_fields() can be used to add more fields following this. |
| 942 | 942 | * |
| 943 | + * Unlikely the synth_event_gen_cmd_start(), @loc must be specified. This | |
| 944 | + * returns -EINVAL if @loc == NULL. | |
| 945 | + * | |
| 943 | 946 | * Return: 0 if successful, error otherwise. |
| 944 | 947 | */ |
| 945 | 948 | int __kprobe_event_gen_cmd_start(struct dynevent_cmd *cmd, bool kretprobe, |
| @@ -953,6 +956,9 @@ int __kprobe_event_gen_cmd_start(struct dynevent_cmd *cmd, bool kretprobe, · 7 unmodified lines | ||
| 953 | 956 | if (cmd->type != DYNEVENT_TYPE_KPROBE) |
| 954 | 957 | return -EINVAL; |
| 955 | 958 | |
| 959 | + if (!loc) | |
| 960 | + return -EINVAL; | |
| 961 | + | |
| 956 | 962 | if (kretprobe) |
| 957 | 963 | snprintf(buf, MAX_EVENT_NAME_LEN, "r:kprobes/%s", name); |
| 958 | 964 | else |
| @@ -19,6 +19,24 @@ · 18 unmodified lines | ||
| 19 | 19 | /* Per-cpu variable to prevent redundant calls when IRQs already off */ |
| 20 | 20 | static DEFINE_PER_CPU(int, tracing_irq_cpu); |
| 21 | 21 | |
| 22 | +/* | |
| 23 | + * Like trace_hardirqs_on() but without the lockdep invocation. This is | |
| 24 | + * used in the low level entry code where the ordering vs. RCU is important | |
| 25 | + * and lockdep uses a staged approach which splits the lockdep hardirq | |
| 26 | + * tracking into a RCU on and a RCU off section. | |
| 27 | + */ | |
| 28 | +void trace_hardirqs_on_prepare(void) | |
| 29 | +{ | |
| 30 | + if (this_cpu_read(tracing_irq_cpu)) { | |
| 31 | + if (!in_nmi()) | |
| 32 | + trace_irq_enable(CALLER_ADDR0, CALLER_ADDR1); | |
| 33 | + tracer_hardirqs_on(CALLER_ADDR0, CALLER_ADDR1); | |
| 34 | + this_cpu_write(tracing_irq_cpu, 0); | |
| 35 | + } | |
| 36 | +} | |
| 37 | +EXPORT_SYMBOL(trace_hardirqs_on_prepare); | |
| 38 | +NOKPROBE_SYMBOL(trace_hardirqs_on_prepare); | |
| 39 | + | |
| 22 | 40 | void trace_hardirqs_on(void) |
| 23 | 41 | { |
| 24 | 42 | if (this_cpu_read(tracing_irq_cpu)) { |
| @@ -28,11 +46,31 @@ void trace_hardirqs_on(void) · 3 unmodified lines | ||
| 28 | 46 | this_cpu_write(tracing_irq_cpu, 0); |
| 29 | 47 | } |
| 30 | 48 | |
| 49 | + lockdep_hardirqs_on_prepare(CALLER_ADDR0); | |
| 31 | 50 | lockdep_hardirqs_on(CALLER_ADDR0); |
| 32 | 51 | } |
| 33 | 52 | EXPORT_SYMBOL(trace_hardirqs_on); |
| 34 | 53 | NOKPROBE_SYMBOL(trace_hardirqs_on); |
| 35 | 54 | |
| 55 | +/* | |
| 56 | + * Like trace_hardirqs_off() but without the lockdep invocation. This is | |
| 57 | + * used in the low level entry code where the ordering vs. RCU is important | |
| 58 | + * and lockdep uses a staged approach which splits the lockdep hardirq | |
| 59 | + * tracking into a RCU on and a RCU off section. | |
| 60 | + */ | |
| 61 | +void trace_hardirqs_off_prepare(void) | |
| 62 | +{ | |
| 63 | + if (!this_cpu_read(tracing_irq_cpu)) { | |
| 64 | + this_cpu_write(tracing_irq_cpu, 1); | |
| 65 | + tracer_hardirqs_off(CALLER_ADDR0, CALLER_ADDR1); | |
| 66 | + if (!in_nmi()) | |
| 67 | + trace_irq_disable(CALLER_ADDR0, CALLER_ADDR1); | |
| 68 | + } | |
| 69 | + | |
| 70 | +} | |
| 71 | +EXPORT_SYMBOL(trace_hardirqs_off_prepare); | |
| 72 | +NOKPROBE_SYMBOL(trace_hardirqs_off_prepare); | |
| 73 | + | |
| 36 | 74 | void trace_hardirqs_off(void) |
| 37 | 75 | { |
| 38 | 76 | if (!this_cpu_read(tracing_irq_cpu)) { |
| @@ -56,6 +94,7 @@ __visible void trace_hardirqs_on_caller(unsigned long caller_addr) · 17 unmodified lines | ||
| 56 | 94 | this_cpu_write(tracing_irq_cpu, 0); |
| 57 | 95 | } |
| 58 | 96 | |
| 97 | + lockdep_hardirqs_on_prepare(CALLER_ADDR0); | |
| 59 | 98 | lockdep_hardirqs_on(CALLER_ADDR0); |
| 60 | 99 | } |
| 61 | 100 | EXPORT_SYMBOL(trace_hardirqs_on_caller); |
| @@ -283,7 +283,7 @@ int tracing_map_add_key_field(struct tracing_map *map, · 282 unmodified lines | ||
| 283 | 283 | return idx; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | −void tracing_map_array_clear(struct tracing_map_array *a) | |
| 286 | +static void tracing_map_array_clear(struct tracing_map_array *a) | |
| 287 | 287 | { |
| 288 | 288 | unsigned int i; |
| 289 | 289 | |
| @@ -294,7 +294,7 @@ void tracing_map_array_clear(struct tracing_map_array *a) · 4 unmodified lines | ||
| 294 | 294 | memset(a->pages[i], 0, PAGE_SIZE); |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | −void tracing_map_array_free(struct tracing_map_array *a) | |
| 297 | +static void tracing_map_array_free(struct tracing_map_array *a) | |
| 298 | 298 | { |
| 299 | 299 | unsigned int i; |
| 300 | 300 | |
| @@ -316,7 +316,7 @@ void tracing_map_array_free(struct tracing_map_array *a) · 15 unmodified lines | ||
| 316 | 316 | kfree(a); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | −struct tracing_map_array *tracing_map_array_alloc(unsigned int n_elts, | |
| 319 | +static struct tracing_map_array *tracing_map_array_alloc(unsigned int n_elts, | |
| 320 | 320 | unsigned int entry_size) |
| 321 | 321 | { |
| 322 | 322 | struct tracing_map_array *a; |
| @@ -544,6 +544,11 @@ EXPORT_SYMBOL_GPL(fork_usermode_blob); · 543 unmodified lines | ||
| 544 | 544 | * Runs a user-space application. The application is started |
| 545 | 545 | * asynchronously if wait is not set, and runs as a child of system workqueues. |
| 546 | 546 | * (ie. it runs with full root capabilities and optimized affinity). |
| 547 | + * | |
| 548 | + * Note: successful return value does not guarantee the helper was called at | |
| 549 | + * all. You can't rely on sub_info->{init,cleanup} being called even for | |
| 550 | + * UMH_WAIT_* wait modes as STATIC_USERMODEHELPER_PATH="" turns all helpers | |
| 551 | + * into a successful no-op. | |
| 547 | 552 | */ |
| 548 | 553 | int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait) |
| 549 | 554 | { |