@@ -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/*
@@ -605,17 +613,15 @@ static void bpf_jit_prologue(struct bpf_jit *jit, struct bpf_prog *fp,
605613 }
606614 /* Setup stack and backchain */
607615 if (is_first_pass (jit ) || (jit -> seen & SEEN_STACK )) {
608- if (is_first_pass (jit ) || (jit -> seen & SEEN_FUNC ))
609- /* lgr %w1,%r15 (backchain) */
610- EMIT4 (0xb9040000 , REG_W1 , REG_15 );
616+ /* lgr %w1,%r15 (backchain) */
617+ EMIT4 (0xb9040000 , REG_W1 , REG_15 );
611618 /* la %bfp,STK_160_UNUSED(%r15) (BPF frame pointer) */
612619 EMIT4_DISP (0x41000000 , BPF_REG_FP , REG_15 , STK_160_UNUSED );
613620 /* aghi %r15,-STK_OFF */
614621 EMIT4_IMM (0xa70b0000 , REG_15 , - (STK_OFF + stack_depth ));
615- if (is_first_pass (jit ) || (jit -> seen & SEEN_FUNC ))
616- /* stg %w1,152(%r15) (backchain) */
617- EMIT6_DISP_LH (0xe3000000 , 0x0024 , REG_W1 , REG_0 ,
618- REG_15 , 152 );
622+ /* stg %w1,152(%r15) (backchain) */
623+ EMIT6_DISP_LH (0xe3000000 , 0x0024 , REG_W1 , REG_0 ,
624+ REG_15 , 152 );
619625 }
620626}
621627
0 commit comments