Skip to content

Commit d5629d1

Browse files
iii-igregkh
authored andcommitted
s390/bpf: Fix bpf_arch_text_poke() with new_addr == NULL again
commit 6a5abf8 upstream. Commit 7ded842 ("s390/bpf: Fix bpf_plt pointer arithmetic") has accidentally removed the critical piece of commit c730fce ("s390/bpf: Fix bpf_arch_text_poke() with new_addr == NULL"), causing intermittent kernel panics in e.g. perf's on_switch() prog to reappear. Restore the fix and add a comment. Fixes: 7ded842 ("s390/bpf: Fix bpf_plt pointer arithmetic") Cc: stable@vger.kernel.org Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Link: https://lore.kernel.org/r/20250716194524.48109-2-iii@linux.ibm.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 11c19d4 commit d5629d1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

arch/s390/net/bpf_jit_comp.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,15 @@ static void bpf_jit_plt(struct bpf_plt *plt, void *ret, void *target)
544544
{
545545
memcpy(plt, &bpf_plt, sizeof(*plt));
546546
plt->ret = ret;
547-
plt->target = target;
547+
/*
548+
* (target == NULL) implies that the branch to this PLT entry was
549+
* patched and became a no-op. However, some CPU could have jumped
550+
* to this PLT entry before patching and may be still executing it.
551+
*
552+
* Since the intention in this case is to make the PLT entry a no-op,
553+
* make the target point to the return label instead of NULL.
554+
*/
555+
plt->target = target ?: ret;
548556
}
549557

550558
/*

0 commit comments

Comments
 (0)