linux/arch
Vasily Gorbik cd57953936 s390/kprobes: fix current_kprobe never cleared after kprobes reenter
Recent test_kprobe_missed kprobes kunit test uncovers the following
problem. Once kprobe is triggered from another kprobe (kprobe reenter),
all future kprobes on this cpu are considered as kprobe reenter, thus
pre_handler and post_handler are not being called and kprobes are counted
as "missed".

Commit b9599798f9 ("[S390] kprobes: activation and deactivation")
introduced a simpler scheme for kprobes (de)activation and status
tracking by using push_kprobe/pop_kprobe, which supposed to work for
both initial kprobe entry as well as kprobe reentry and helps to avoid
handling those two cases differently. The problem is that a sequence of
calls in case of kprobes reenter:
push_kprobe() <- NULL (current_kprobe)
push_kprobe() <- kprobe1 (current_kprobe)
pop_kprobe() -> kprobe1 (current_kprobe)
pop_kprobe() -> kprobe1 (current_kprobe)
leaves "kprobe1" as "current_kprobe" on this cpu, instead of setting it
to NULL. In fact push_kprobe/pop_kprobe can only store a single state
(there is just one prev_kprobe in kprobe_ctlblk). Which is a hack but
sufficient, there is no need to have another prev_kprobe just to store
NULL. To make a simple and backportable fix simply reset "prev_kprobe"
when kprobe is poped from this "stack". No need to worry about
"kprobe_status" in this case, because its value is only checked when
current_kprobe != NULL.

Cc: stable@vger.kernel.org
Fixes: b9599798f9 ("[S390] kprobes: activation and deactivation")
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2023-03-02 15:33:11 +01:00
..
alpha Scheduler updates in this cycle are: 2023-02-20 17:41:08 -08:00
arc arch/idle: Change arch_cpu_idle() behavior: always exit with IRQs disabled 2023-01-13 11:48:15 +01:00
arm Networking changes for 6.3. 2023-02-21 18:24:12 -08:00
arm64 Networking changes for 6.3. 2023-02-21 18:24:12 -08:00
csky arch/idle: Change arch_cpu_idle() behavior: always exit with IRQs disabled 2023-01-13 11:48:15 +01:00
hexagon arch/idle: Change arch_cpu_idle() behavior: always exit with IRQs disabled 2023-01-13 11:48:15 +01:00
ia64 Scheduler updates in this cycle are: 2023-02-20 17:41:08 -08:00
loongarch Networking changes for 6.3. 2023-02-21 18:24:12 -08:00
m68k m68k updates for v6.3 2023-02-21 15:17:34 -08:00
microblaze arch/idle: Change arch_cpu_idle() behavior: always exit with IRQs disabled 2023-01-13 11:48:15 +01:00
mips Power management updates for 6.3-rc1 2023-02-21 12:13:58 -08:00
nios2 arch/idle: Change arch_cpu_idle() behavior: always exit with IRQs disabled 2023-01-13 11:48:15 +01:00
openrisc arch/idle: Change arch_cpu_idle() behavior: always exit with IRQs disabled 2023-01-13 11:48:15 +01:00
parisc Scheduler updates in this cycle are: 2023-02-20 17:41:08 -08:00
powerpc Scheduler updates in this cycle are: 2023-02-20 17:41:08 -08:00
riscv Networking changes for 6.3. 2023-02-21 18:24:12 -08:00
s390 s390/kprobes: fix current_kprobe never cleared after kprobes reenter 2023-03-02 15:33:11 +01:00
sh Networking changes for 6.3. 2023-02-21 18:24:12 -08:00
sparc Scheduler updates in this cycle are: 2023-02-20 17:41:08 -08:00
um arch/idle: Change arch_cpu_idle() behavior: always exit with IRQs disabled 2023-01-13 11:48:15 +01:00
x86 Networking changes for 6.3. 2023-02-21 18:24:12 -08:00
xtensa Linux 6.2-rc6 2023-01-31 15:01:20 +01:00
.gitignore
Kconfig arm64 fixes for -rc1 2022-12-16 13:46:41 -06:00