Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.231.193 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796100176; b=F4zRSDQACezOsLS5YlxOstHO+KENX5VZewMczq/cSLK4a9X2NBXUts+QlCC0zh7sM5X6 RSszdzdKvA/tbVZrOV1I97PjlBhUhsh9NYMqCQ1e3A1DXsilNjMnNmTX+ZHcMpJkPckLO zwABIvGQzSJkdEC9m+kTcwZXLANsAdFYkN5zPv+u9aSdPXkmjIGUwUqSStpqv8tW08fz8 UWsOJAiDGvFods1FXkZSUM/6GCV3uonTcr0378mcsuhbI+MqQGW5qyjLgn03KB5GJl/7z DEY9pHbLjcv0qm88fqALpEpleGThW6khJXjM29DketzxRSasYcKrRARg7TaRyzXtLmQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796100176; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: X-Developer-Signature:X-Developer-Key:Content-Transfer-Encoding; bh=y8/CXf5w4KLwz0Gpl9UUQ9W56P0/AMw6kUtZ4aAw1wY=; b=EqAfSpINob/mf70FpEcGeW7ERKAvLvC9cvD173uZ474ChMyGfGqtwFNhPIQkgxIJtNO1 /heEviwwYhxzYdN979ngn/93WbSD53g08Ih36MJFPtYEJrDIh7kZx9ef79IG5WXX8wAXg R8ginBvLGGd6sBdpztTTy2UQhm6CGLHIlex/T0KO7+qGZBT+Nb44rll92TFiN7trsdxTq hJHcT4fE7EwpPDX8l7+FOn6z6zDrPQ4CbTqChoZvyx6mQly28HwSpmoy0BOcWrPltmqFW 8DvkZdsNt4Z9Jm626rXNisny0OiIb7k7fE2Ng88qBNXPFFfwln3gRLKV4ShERlLFxJQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=k1TGpi5W; arc=none smtp.remote-ip=74.125.231.193 Received: from mail-oi2-f1.google.com (mail-oi2-f1.google.com [74.125.231.193]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8818606A320 for ; Tue, 1 Dec 2026 04:42:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C8818606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=k1TGpi5W Received: by mail-oi2-f1.google.com with SMTP id 5614622812f47-539d2baa897so3923197b6e.0 for ; Mon, 30 Nov 2026 20:42:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796100175; x=1796704975; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=y8/CXf5w4KLwz0Gpl9UUQ9W56P0/AMw6kUtZ4aAw1wY=; b=k1TGpi5W2cljdqu/qAXYCR1WUPqWUTsvgcm9GN6RSRB8nIbQbRYTNcczh+5xEyk4s4 ar8ba6kT9BCTm3YtKCzLinr+60xAQrOyv7yWwsWNKOu12Lu0GLARmyI8ZX/4pG///Ghu jeKKhNeVCU1SnffIbgD2E7tkoNDXH6sjdKWEyCy35M4zrSE8nsi1+sKpruhtgmJQoFPh HNUVZx1G0OIfV7O7n2tIcfad1ldEd3mcKD6INupPv9xA16yw34t6FgcNNXhIQVTqvIZ6 nsKPX1GBe3c0Opo1ilblw6vkjNbykVJ2lyZTAHuAYU8bP5VrBASAxwk03VpfAMV0pUm7 F0bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796100175; x=1796704975; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=y8/CXf5w4KLwz0Gpl9UUQ9W56P0/AMw6kUtZ4aAw1wY=; b=SS4va1lEuHbCm+662kl7Ieyv5wInfrnhh8E+Ix+zLIDQvwsTysDt+fYtSNveeb5gBD XV5tJBJcjQBgr9qtsjdrXeLmqPjPwIfPOFC3PUWDhzpLGb4Go4lSmvg3c9Tb4H6SHPlT tJzelrtxvKve1NQyZKtbITR3JUkU6Pb/SzZ5aTdLj+FWzgqc3ctdhIYnwJc9Dp3QBqjS JWl21cvySFhskNSEI/dXB3VcZ//TuKShR9LvQXCvT+VT4P6VdAveliU/pXuJbj0sDsRp jM9TduFAK+FBzpoQJ/QaZqxzrVvRtqq2q6G3HxUaIBo3QwQU8ZVtpUyXR3lcuimQtLB6 NC3w== X-Gm-Message-State: APuU4Z+n1zgcVCYbV2r/hEDqzDd1M6Dxdi6lRr6gkoz3OaqbYVZBmukQ Wc1r0H4E2SJzlpmt+xwCO5BrXQ0TgDjd1b6CP36tja+2wlVufbOWnTp31Un09aWzI4k= X-Gm-Gg: AZFdTZcbuJoLTUQri0EfzzpCwE2VmNTIy8Ulv7HGt97gIt4t6AzwUd+rg0ZcW5mPuAh 5KiijorBxzIUaubMSe4D5OIv68F2v6SaG4yL5MM9ktNObIoOL2ip+L/HaIIRa0n71swxqfDwmV/ si4f0U1dmbiPm4/iCRwFRM6mS8IMrSUE++Ro6Lax2HvISGHeypQe8VeSeGDAdqdLgeCqpYP71Bd QV5hEllzbIrfUcmEGktV0NoAheIcqFKdlzcRBoIAOIdo+lW8R4c3UysY473PcfJbsl2w81GLhRs NY3Zo8uMU5JweVrnK15EceNCPUpm1ujPZ3Gdy69D+i9gAkNnVtT6gYY3yva/Wync/Dx4L+kNSvw 6v8hNUIJC9EdAvzwrCVKsvl+r+Pt+v4oexKsl0TALzGc5JRRNQ4DAZlxXm6Cdwze+lvQNUCdc+T 7Jmm4W4W8tCugkbWSInK7ehxRfewaY63HRK00TeYqJ2pj2rFxbvp9040DUE1L4qYv++N366wYHZ D/XUdSh8pannY+9nFSYtIBWMEhBdcBO5MOd6AD6ilpdgxzyYuw0X4qzDbKtDL1pTnTAGiZQNSy4 NU5itYRSDUbgr9iQbCyTY5kWgvr4A/n/gZIrtfhZZypGCjehQ50XXsDDKLKP/A5XZBT3I0kbwJK VQbgCtGzKPniOm0Ql7mwPmHbYbeogcvvpg/r+7aEtDtgWYkXdeercFz/cew== X-Received: by 2002:a05:6808:c12b:b0:572:86c8:6b4c with SMTP id 5614622812f47-57a07d19c74mr35553282b6e.6.1796100174729; Mon, 30 Nov 2026 20:42:54 -0800 (PST) Received: from localhost ([2a03:2880:10ff:53::]) by smtp.gmail.com with ESMTPSA id 5614622812f47-57a35655a5bsm26872926b6e.13.2026.11.30.20.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 20:42:53 -0800 (PST) From: Kumar Kartikeya Dwivedi To: bpf@vger.kernel.org Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Eduard Zingerman , Emil Tsalapatis , Ihor Solodrai , kkd@meta.com, kernel-team@meta.com Subject: [PATCH bpf-next v1 56/73] bpf, arm64: Return to cancel_goto at cancel_exit Date: Tue, 1 Dec 2026 05:39:23 +0100 Message-ID: <4e1716756dec0d2da119d6946b804f040774bd5f.1796099738.git.memxor@gmail.com> X-Mailer: git-send-email 2.53.1 In-Reply-To: References: X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=14422; h=from:subject:message-id; bh=aD2mqVUES9C+uBZtoeQP68tQdN2iaAfEhQpYCskesTA=; b=owGbwMvMwCXmrmtenRyi38x4Wi2JIZvPb5HU52+nlHc6HTLeO7vp0X19m3vbzt48GXSsS7N5e8qi j//ndZSyMIhxMciKKbKU/N/HZHyi8neg7TJumDmsTCBDGLg4BWAiAa8YGTa8Nr6btKxb8WBLkdJZfd tTdxbu0T0jqDnHZ0ez+6Kw63MY/ikvy9xRH+Aw5eo9YZnA2b58bK7Bzx8WrioVf55w8MSSuewA X-Developer-Key: i=memxor@gmail.com; a=openpgp; fpr=B34BD741DE8494B76E2F717880EF20021D46C59B Content-Transfer-Encoding: 8bit Teach the arm64 JIT the two insns, as on x86-64. cancel_exit emits the code of unwind_exit with bpf_cancel_fixup() in place of bpf_unwind_fixup(). cancel_goto is an exception table entry for the call before it, like unwind_goto, with a key of its own. After the call of a helper or a kfunc, each of the two has a landing after the epilogue, because a helper returns R0 in x0 alone: bl helper returns to ret_addr mov x8, x0 ... mov x8, x0; b A <- unwind_goto A: { .insn = ret_addr - 1 } mov x8, x0; b B <- cancel_goto B: { .insn = ret_addr - 2 } Both keys are inside the four bytes of the bl. No insn starts there, so a fault cannot hit either entry. Three cases need care: - The exception table is sorted by address. When a call has both insns, the unwind_goto adds no entry itself. The cancel_goto after it adds both entries, its own first. - The two landings of such a call stand in the order of the insns, which is the order in which build_landings() gets to them. - A cancel_goto never follows an access to arena, and the JIT fails if it finds one there. The lookup changes as on x86-64. It is one function for both keys, it adds BPF_CB_PAD_OFF or BPF_CB_CANCEL_OFF to the address of the stub of bpf_call_cb(), and both lookups become notrace and are put on the kprobe blacklist. The verifier emits neither insn yet. Signed-off-by: Kumar Kartikeya Dwivedi --- arch/arm64/net/bpf_jit_comp.c | 175 +++++++++++++++++++++++++--------- 1 file changed, 132 insertions(+), 43 deletions(-) diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index 86f49bf96036..18ec626762f6 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1655,11 +1656,14 @@ static int add_exception_handler(const struct bpf_verifier_env *env, return 0; } -/* unwind_goto after the call of a helper or a kfunc, which return r0 in x0 alone */ -static bool unwind_goto_after_helper(const struct bpf_insn *insn) +/* Whether @insn, unwind_goto or cancel_goto, follows the call of a helper or a kfunc */ +static bool goto_after_helper(const struct bpf_insn *insn) { const struct bpf_insn *call = insn - 1; + /* 'call; unwind_goto; cancel_goto' */ + if (bpf_is_cancel_goto(insn) && bpf_is_unwind_goto(call)) + call--; return call->code == (BPF_JMP | BPF_CALL) && call->src_reg != BPF_PSEUDO_CALL; } @@ -1674,8 +1678,15 @@ static bool unwind_goto_after_helper(const struct bpf_insn *insn) * a helper, see build_landings(). * After an access to arena, ret_addr is the end of the code of the access, and * a fault in the access goes to the target, see bpf_fault_unwind_target(). + * + * cancel_goto is the same for cancel_exit, with the entry at ret_addr - 2, + * because the unwind_goto of the same call has the one at ret_addr - 1. Both + * keys are inside the call insn. cancel_goto never follows an access to arena. */ -static int add_unwind_exentry(struct jit_ctx *ctx, int ret_addr, int target) +#define UNWIND_EXKEY 1 +#define CANCEL_EXKEY 2 + +static int add_unwind_exentry(struct jit_ctx *ctx, int ret_addr, int target, int key) { struct exception_table_entry *ex; off_t ins_offset; @@ -1689,7 +1700,7 @@ static int add_unwind_exentry(struct jit_ctx *ctx, int ret_addr, int target) return -EINVAL; ex = &ctx->prog->aux->extable[ctx->exentry_idx]; - ins_offset = (long)&ctx->ro_image[ret_addr] - 1 - (long)&ex->insn; + ins_offset = (long)&ctx->ro_image[ret_addr] - key - (long)&ex->insn; if (WARN_ON_ONCE(ins_offset >= 0 || ins_offset < INT_MIN)) return -ERANGE; @@ -1704,10 +1715,39 @@ static int add_unwind_exentry(struct jit_ctx *ctx, int ret_addr, int target) } /* - * The landings of the pads after the calls of helpers and kfuncs, past the - * epilogue, where nothing falls into them: 'mov x8, x0; b pad' each, see the - * unwind_goto case of build_insn(). They go in after the body, when the pads - * are placed and the entries are in, and each fills in the fixup of its entry. + * Add the extable entry of @insn, an unwind_goto or cancel_goto after a call + * that returns to @ret_addr. If the insn gets a landing, *@landing is the index + * of the entry, and build_landings() fills in the fixup. + */ +static int add_goto_exentry(struct jit_ctx *ctx, const struct bpf_insn *insn, int ret_addr, + int *landing) +{ + int i = insn - ctx->prog->insnsi; + int target = ctx->offset[i + 1 + bpf_jmp_offset(insn)]; + + if (goto_after_helper(insn)) { + *landing = ctx->exentry_idx; + target = ret_addr; + } + return add_unwind_exentry(ctx, ret_addr, target, + bpf_is_cancel_goto(insn) ? CANCEL_EXKEY : UNWIND_EXKEY); +} + +/* + * Emit the landings after the epilogue. r0 is x8, so 'mov x8, x0' follows a + * call. A helper or a kfunc that leaves through its unwind label skips the mov, + * so an unwind_goto or cancel_goto after its call gets a landing, which does + * the mov and branches to the target: + * + * bl helper returns to ret_addr + * mov x8, x0 + * ... + * + * mov x8, x0; b pad <- unwind_exit returns here, key ret_addr - 1 + * mov x8, x0; b cancel_pad <- cancel_exit returns here, key ret_addr - 2 + * + * build_insn() has added the entries. Each landing fills in the fixup of its + * entry. */ static int build_landings(struct jit_ctx *ctx) { @@ -1718,8 +1758,9 @@ static int build_landings(struct jit_ctx *ctx) const struct bpf_insn *insn = &prog->insnsi[i]; int ret_addr, jmp_offset; - if (!bpf_is_unwind_goto(insn) || !unwind_goto_after_helper(insn)) + if (!bpf_is_pad_goto(insn) || !goto_after_helper(insn)) continue; + /* unwind_goto emits no code, so this also holds for the cancel_goto after it */ ret_addr = ctx->offset[i] - 1; if (ctx->image) { struct exception_table_entry *ex; @@ -1738,40 +1779,59 @@ static int build_landings(struct jit_ctx *ctx) } /* - * The verifier made sure that unwind_goto follows a call in a prog. When the - * kernel called an async callback, it's exit. A helper that calls a callback - * has a pad when it wants one, see bpf_call_cb(). + * Where a frame that leaves with unwind_exit, @key UNWIND_EXKEY, or with + * cancel_exit, @key CANCEL_EXKEY, returns to. + * The verifier made sure that unwind_goto follows a call in a prog, and + * cancel_goto where the callee has cancel_exit. When the kernel called an async + * callback, it's exit. A helper that calls a callback has a pad when it wants + * one, see bpf_call_cb(). */ -u64 bpf_unwind_target(u64 ret_addr) +static u64 unwind_target(u64 ret_addr, int key) { const struct exception_table_entry *e; - e = search_bpf_extables(ret_addr - 1); + e = search_bpf_extables(ret_addr - key); if (e) return ret_addr + e->fixup; /* - * The pad of a helper that called a callback with bpf_call_cb(): its - * entries are the EX_TYPE_BPF ones of the kernel and module tables. - * Anything else at a return address is some caller's own fixup, and - * what a JIT keyed there is a fixup of the insn after the call. + * A helper that called the frame with bpf_call_cb() has an EX_TYPE_BPF + * entry at the return address itself. An entry of another type there + * is the fixup of the insn after some call. The entry points to the + * stub of the helper's unwind label, which has one entry point for + * unwind_exit and one for cancel_exit. */ e = search_kernel_exception_table(ret_addr); if (!e) e = search_module_extables(ret_addr); if (e && e->type == EX_TYPE_BPF) - return (unsigned long)&e->fixup + e->fixup; + return (unsigned long)&e->fixup + e->fixup + + (key == CANCEL_EXKEY ? BPF_CB_CANCEL_OFF : BPF_CB_PAD_OFF); /* * No pad. That is how it ends when the kernel called an async callback * or the main prog of an extension: it's exit. A call in a prog of what * can unwind has unwind_goto behind it, which is an entry also when the - * pad is the next insn. So a return address in a prog without an entry - * is an unwind_exit that gets lost: the verifier sent it to a pad. + * pad is the next insn, and cancel_goto behind a call of what has + * cancel_exit. So a return address in a prog without an entry is an + * unwind_exit or a cancel_exit that gets lost: the verifier sent it to + * a pad. */ scoped_guard(rcu) WARN_ON_ONCE(bpf_prog_ksym_find(ret_addr - 1)); return ret_addr; } +u64 notrace bpf_unwind_target(u64 ret_addr) +{ + return unwind_target(ret_addr, UNWIND_EXKEY); +} +NOKPROBE_SYMBOL(bpf_unwind_target); + +u64 notrace bpf_cancel_target(u64 ret_addr) +{ + return unwind_target(ret_addr, CANCEL_EXKEY); +} +NOKPROBE_SYMBOL(bpf_cancel_target); + /* * Return where a program continues after a fault in an access to arena whose * code ends at @end: at the target of the unwind_goto after the access, or at @@ -1779,7 +1839,7 @@ u64 bpf_unwind_target(u64 ret_addr) */ u64 bpf_fault_unwind_target(u64 end) { - const struct exception_table_entry *e = search_bpf_extables(end - 1); + const struct exception_table_entry *e = search_bpf_extables(end - UNWIND_EXKEY); return e ? end + e->fixup : end; } @@ -1792,12 +1852,21 @@ static long bpf_unwind_fixup(u64 lr) return bpf_unwind_target(ret_addr) - ret_addr; } +/* The same for cancel_exit */ +static long bpf_cancel_fixup(u64 lr) +{ + u64 ret_addr = ptrauth_strip_kernel_insn_pac(lr); + + return bpf_cancel_target(ret_addr) - ret_addr; +} + /* - * unwind_exit: return to the pad. LR in the frame record is signed. Instead of - * signing the address of the pad, let the epilogue authenticate LR as it is and - * add the offset of the pad to it. r0 and r2 are returned. + * unwind_exit, cancel_exit: return to the pad. LR in the frame record is + * signed. Instead of signing the address of the pad, let the epilogue + * authenticate LR as it is and add the offset of the pad to it, which @fixup + * returns. r0 and r2 are returned. */ -static void emit_unwind_exit(struct jit_ctx *ctx) +static void emit_unwind_exit(struct jit_ctx *ctx, long (*fixup)(u64 lr)) { const u8 tmp = bpf2a64[TMP_REG_1]; const u8 r0 = bpf2a64[BPF_REG_0]; @@ -1805,7 +1874,7 @@ static void emit_unwind_exit(struct jit_ctx *ctx) emit(A64_PUSH(r0, r2, A64_SP), ctx); emit(A64_LDR64I(A64_R(0), A64_FP, 8), ctx); - emit_call((u64)bpf_unwind_fixup, ctx); + emit_call((u64)fixup, ctx); emit(A64_MOV(1, tmp, A64_R(0)), ctx); emit(A64_POP(r0, r2, A64_SP), ctx); build_epilogue(ctx, false, true); @@ -2427,37 +2496,57 @@ static int build_insn(const struct bpf_verifier_env *env, const struct bpf_insn if (emit_bpf_tail_call(ctx)) return -EFAULT; break; - /* unwind_goto. The verifier expanded may_goto. */ + /* unwind_goto, cancel_goto. The verifier expanded may_goto. */ case BPF_JMP | BPF_JCOND: case BPF_JMP32 | BPF_JCOND: { + bool cancel_goto = bpf_is_cancel_goto(insn); + /* 'call; unwind_goto; cancel_goto', and this is the second one */ + bool after_unwind = cancel_goto && bpf_is_unwind_goto(insn - 1); + int landing[2] = { -1, -1 }; int ret_addr = ctx->idx - 1; - int target = ctx->offset[i + 1 + bpf_jmp_offset(insn)]; + int j; /* - * 'bl foo; mov x8, x0' is in front. After the call of a subprog - * the pad doesn't miss the mov: r0 is x8 in the subprog too, its - * epilogue copies x8 to x0 and leaves x8 as it is. A helper that - * leaves to the pad returns r0 in x0 alone, so the pad after its - * call is entered through a landing past the epilogue, see - * build_landings(), which fills in the fixup of the entry. + * The extable is sorted by address, and the entry of cancel_goto has + * the lower one. So unwind_goto adds no entry when cancel_goto follows + * it: the cancel_goto adds both entries, its own first. */ - if (unwind_goto_after_helper(insn)) { - ctx->landing_ex[ctx->landing_idx++] = ctx->exentry_idx; - target = ret_addr; - } else if (BPF_CLASS(insn[-1].code) != BPF_JMP) { + if (!cancel_goto && i + 1 < ctx->prog->len && bpf_is_cancel_goto(insn + 1)) + break; + if (BPF_CLASS(insn[-1 - after_unwind].code) != BPF_JMP) { + if (cancel_goto) { + pr_err_once("cancel_goto at insn %d follows no call\n", i); + return -EFAULT; + } /* After an access to arena. Its last insn is the one that can fault. */ ret_addr = ctx->idx; } - ret = add_unwind_exentry(ctx, ret_addr, target); + /* + * Else 'bl foo; mov x8, x0' is in front. After the call of a subprog + * the target doesn't miss the mov: r0 is x8 in the subprog too, and + * its epilogue copies x8 to x0 and leaves x8 as it is. After the + * call of a helper the entry points to a landing. + */ + ret = add_goto_exentry(ctx, insn, ret_addr, &landing[after_unwind]); + if (!ret && after_unwind) + ret = add_goto_exentry(ctx, insn - 1, ret_addr, &landing[0]); if (ret) return ret; + /* build_landings() emits the landings in the order of the insns */ + for (j = 0; j < 2; j++) + if (landing[j] >= 0) + ctx->landing_ex[ctx->landing_idx++] = landing[j]; break; } /* function return */ case BPF_JMP | BPF_EXIT: if (bpf_is_unwind_exit(insn) && bpf_prog_can_unwind(ctx->prog)) { - emit_unwind_exit(ctx); + emit_unwind_exit(ctx, bpf_unwind_fixup); + break; + } + if (bpf_is_cancel_exit(insn) && bpf_prog_can_unwind(ctx->prog)) { + emit_unwind_exit(ctx, bpf_cancel_fixup); break; } /* Optimization: when last instruction is EXIT, @@ -2812,8 +2901,8 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr goto out_off; for (i = 1; i < prog->len; i++) - if (bpf_is_unwind_goto(&prog->insnsi[i]) && - unwind_goto_after_helper(&prog->insnsi[i])) + if (bpf_is_pad_goto(&prog->insnsi[i]) && + goto_after_helper(&prog->insnsi[i])) nr_landings++; if (nr_landings) { ctx.landing_ex = kvzalloc_objs(int, nr_landings); -- 2.53.1-Meta