diff --git a/patches.suse/s390-kprobes-fix-current_kprobe-never-cleared-after-kprobes-reenter.patch b/patches.suse/s390-kprobes-fix-current_kprobe-never-cleared-after-kprobes-reenter.patch new file mode 100644 index 0000000..014d35a --- /dev/null +++ b/patches.suse/s390-kprobes-fix-current_kprobe-never-cleared-after-kprobes-reenter.patch @@ -0,0 +1,54 @@ +From: Vasily Gorbik +Date: Wed, 1 Mar 2023 17:58:06 +0100 +Subject: s390/kprobes: fix current_kprobe never cleared after kprobes reenter +Git-commit: cd57953936f2213dfaccce10d20f396956222c7d +Patch-mainline: v6.3-rc1 +References: git-fixes bsc#1211688 + +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 b9599798f953 ("[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: b9599798f953 ("[S390] kprobes: activation and deactivation") +Reviewed-by: Heiko Carstens +Signed-off-by: Vasily Gorbik +Signed-off-by: Heiko Carstens +Acked-by: Miroslav Franc +--- + arch/s390/kernel/kprobes.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c +index c505c0ee5f47..e53192a5d593 100644 +--- a/arch/s390/kernel/kprobes.c ++++ b/arch/s390/kernel/kprobes.c +@@ -233,6 +233,7 @@ static void pop_kprobe(struct kprobe_ctlblk *kcb) + { + __this_cpu_write(current_kprobe, kcb->prev_kprobe.kp); + kcb->kprobe_status = kcb->prev_kprobe.status; ++ kcb->prev_kprobe.kp = NULL; + } + NOKPROBE_SYMBOL(pop_kprobe); + diff --git a/series.conf b/series.conf index b5ad4b7..a9e9f67 100644 --- a/series.conf +++ b/series.conf @@ -19349,6 +19349,7 @@ patches.suse/rtc-allow-rtc_read_alarm-without-read_alarm-callback.patch patches.suse/s390-extmem-return-correct-segment-type-in-__segment_load.patch patches.suse/s390-kprobes-fix-irq-mask-clobbering-on-kprobe-reenter-from-post_handler.patch + patches.suse/s390-kprobes-fix-current_kprobe-never-cleared-after-kprobes-reenter.patch patches.suse/nvme-auth-fix-an-error-code-in-nvme_auth_process_dhc.patch patches.suse/nvme-fabrics-show-well-known-discovery-name.patch patches.suse/ACPI-x86-utils-Add-Cezanne-to-the-list-for-forcing-S.patch