android_kernel_xiaomi_sm7250/kernel
Steven Rostedt (VMware) 47ab2c7413 tracepoint: Add tracepoint_probe_register_may_exist() for BPF tracing
commit 9913d5745bd720c4266805c8d29952a3702e4eca upstream.

All internal use cases for tracepoint_probe_register() is set to not ever
be called with the same function and data. If it is, it is considered a
bug, as that means the accounting of handling tracepoints is corrupted.
If the function and data for a tracepoint is already registered when
tracepoint_probe_register() is called, it will call WARN_ON_ONCE() and
return with EEXISTS.

The BPF system call can end up calling tracepoint_probe_register() with
the same data, which now means that this can trigger the warning because
of a user space process. As WARN_ON_ONCE() should not be called because
user space called a system call with bad data, there needs to be a way to
register a tracepoint without triggering a warning.

Enter tracepoint_probe_register_may_exist(), which can be called, but will
not cause a WARN_ON() if the probe already exists. It will still error out
with EEXIST, which will then be sent to the user space that performed the
BPF system call.

This keeps the previous testing for issues with other users of the
tracepoint code, while letting BPF call it with duplicated data and not
warn about it.

Link: https://lore.kernel.org/lkml/20210626135845.4080-1-penguin-kernel@I-love.SAKURA.ne.jp/
Link: https://syzkaller.appspot.com/bug?id=41f4318cf01762389f4d1c1c459da4f542fe5153

Cc: stable@vger.kernel.org
Fixes: c4f6699dfc ("bpf: introduce BPF_RAW_TRACEPOINT")
Reported-by: syzbot <syzbot+721aa903751db87aa244@syzkaller.appspotmail.com>
Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tested-by: syzbot+721aa903751db87aa244@syzkaller.appspotmail.com
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-20 16:15:42 +02:00
..
bpf bpf: Add BPF_F_ANY_ALIGNMENT. 2021-06-10 13:24:08 +02:00
cgroup cgroup1: don't allow '\n' in renaming 2021-06-16 11:54:59 +02:00
configs
debug kdb: Make memory allocations more robust 2021-03-04 09:39:31 +01:00
dma swiotlb: fix "x86: Don't panic if can not alloc buffer for swiotlb" 2020-11-18 19:18:51 +01:00
events perf: Fix data race between pin_count increment/decrement 2021-06-16 11:55:01 +02:00
gcov gcov: add support for GCC 10.1 2020-09-17 13:45:31 +02:00
irq genirq/matrix: Prevent allocation counter corruption 2021-05-22 10:59:14 +02:00
livepatch
locking locking/mutex: clear MUTEX_FLAGS if wait_list is empty due to signal 2021-05-26 11:48:32 +02:00
power PM: hibernate: flush swap writer after marking 2021-02-03 23:23:24 +01:00
printk printk: fix deadlock when kernel panic 2021-03-04 09:39:57 +01:00
rcu
sched sched/fair: Make sure to update tg contrib for blocked load 2021-06-16 11:55:01 +02:00
time posix-timers: Preserve return value in clock_adjtime32() 2021-05-22 10:59:21 +02:00
trace tracepoint: Add tracepoint_probe_register_may_exist() for BPF tracing 2021-07-20 16:15:42 +02:00
.gitignore
acct.c
async.c
audit_fsnotify.c
audit_tree.c
audit_watch.c audit: CONFIG_CHANGE don't log internal bookkeeping as an event 2020-10-01 13:14:33 +02:00
audit.c
audit.h
auditfilter.c
auditsc.c
backtracetest.c
bounds.c
capability.c
compat.c
configs.c
context_tracking.c
cpu_pm.c
cpu.c kernel/cpu: add arch override for clear_tasks_mm_cpumask() mm handling 2020-12-30 11:25:45 +01:00
crash_core.c
crash_dump.c
cred.c
delayacct.c
dma.c
exec_domain.c
exit.c futex: Mark the begin of futex exit explicitly 2021-01-30 13:32:11 +01:00
extable.c
fail_function.c fail_function: Remove a redundant mutex unlock 2020-11-24 13:27:23 +01:00
fork.c futex: Split futex_mm_release() for exit/exec 2021-01-30 13:32:11 +01:00
freezer.c
futex.c mm, futex: fix shared futex pgoff on shmem huge page 2021-07-11 12:49:30 +02:00
groups.c
hung_task.c
iomem.c
irq_work.c
jump_label.c locking/static_key: Fix false positive warnings on concurrent dec/inc 2021-03-04 09:39:30 +01:00
kallsyms.c
kcmp.c
Kconfig.freezer
Kconfig.hz
Kconfig.locks
Kconfig.preempt
kcov.c
kexec_core.c kernel: kexec: remove the lock operation of system_transition_mutex 2021-02-03 23:23:23 +01:00
kexec_file.c kernel: kexec_file: fix error return code of kexec_calculate_store_digests() 2021-05-22 10:59:44 +02:00
kexec_internal.h
kexec.c
kmod.c
kprobes.c tracing/kprobe: Fix to support kretprobe events on unloaded modules 2021-02-13 13:51:13 +01:00
ksysfs.c
kthread.c kthread: prevent deadlock when kthread_mod_delayed_work() races with kthread_cancel_delayed_work_sync() 2021-07-11 12:49:31 +02:00
latencytop.c
Makefile elfcore: fix building with clang 2021-02-10 09:21:06 +01:00
memremap.c
module_signing.c
module-internal.h
module.c module: limit enabling module.sig_enforce 2021-06-30 08:48:28 -04:00
notifier.c
nsproxy.c
padata.c
panic.c
params.c
pid_namespace.c
pid.c
profile.c
ptrace.c ptrace: make ptrace() fail if the tracee changed its pid unexpectedly 2021-05-26 11:48:32 +02:00
range.c
reboot.c reboot: fix overflow parsing reboot cpu number 2020-11-18 19:18:52 +01:00
relay.c kernel/relay.c: fix memleak on destroy relay channel 2020-08-26 10:30:59 +02:00
resource.c
rseq.c
seccomp.c seccomp: Add missing return in non-void function 2021-03-04 09:39:54 +01:00
signal.c ptrace: fix task_join_group_stop() for the case when current is traced 2020-11-10 12:35:53 +01:00
smp.c smp: Fix smp_call_function_single_async prototype 2021-05-22 10:59:39 +02:00
smpboot.c kthread: Extract KTHREAD_IS_PER_CPU 2021-02-07 14:48:38 +01:00
smpboot.h
softirq.c
stacktrace.c
stop_machine.c
sys_ni.c
sys.c kernel/sys.c: avoid copying possible padding bytes in copy_to_user 2020-10-01 13:14:29 +02:00
sysctl_binary.c
sysctl.c sysctl: handle overflow in proc_get_long 2021-02-07 14:48:37 +01:00
task_work.c
taskstats.c
test_kprobes.c
torture.c
tracepoint.c tracepoint: Add tracepoint_probe_register_may_exist() for BPF tracing 2021-07-20 16:15:42 +02:00
tsacct.c
ucount.c
uid16.c
uid16.h
umh.c usermodehelper: reset umask to default before executing user process 2020-10-14 10:31:21 +02:00
up.c smp: Fix smp_call_function_single_async prototype 2021-05-22 10:59:39 +02:00
user_namespace.c
user-return-notifier.c
user.c
utsname_sysctl.c
utsname.c
watchdog_hld.c
watchdog.c
workqueue_internal.h
workqueue.c wq: handle VM suspension in stall detection 2021-06-16 11:54:57 +02:00