bpf: Make sure bpf_disable_instrumentation() is safe vs preemption.
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Sat, 27 Nov 2021 16:32:00 +0000 (17:32 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Dec 2021 09:57:09 +0000 (10:57 +0100)
commite76da2e8a09a4ee289e0e90e61092f84feaeb120
tree5827ece8f127a0dc5e9c36a0ce65e38ff5b3a793
parent9c983fd7cf97ee1329c5ce70674abf06b99c2222
bpf: Make sure bpf_disable_instrumentation() is safe vs preemption.

commit 79364031c5b4365ca28ac0fa00acfab5bf465be1 upstream.

The initial implementation of migrate_disable() for mainline was a
wrapper around preempt_disable(). RT kernels substituted this with a
real migrate disable implementation.

Later on mainline gained true migrate disable support, but neither
documentation nor affected code were updated.

Remove stale comments claiming that migrate_disable() is PREEMPT_RT only.

Don't use __this_cpu_inc() in the !PREEMPT_RT path because preemption is
not disabled and the RMW operation can be preempted.

Fixes: 74d862b682f51 ("sched: Make migrate_disable/enable() independent of RT")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20211127163200.10466-3-bigeasy@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/bpf.h
include/linux/filter.h