From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj2-f3.google.com (mail-pj2-f3.google.com [74.125.227.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9242E4B3384 for ; Mon, 7 Sep 2026 13:06:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.227.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788786400; cv=none; b=kqzqqs8ePWP+VK0+Sf7HEM30stiQ9puiboUMxkkAx+nChlJj02s9haF5npg96foETfF93zeZdn+dHREKS45uPmVoK+yMAg/+gXn66qYB25WtEVL8gHO3BJcO7ePKewJQ4jGH3gvZesMuNWvIGanHiTmaE7Mmt4AGZFpIt+OQhKU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788786400; c=relaxed/simple; bh=KVlall24y0p+qSno+YoVUQqAPfLtfndwd2+UzHAoFPA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=glsZKXCypDOQmv8ql+mYQBMzIwDYEFC6KdIsUqne/Z9TZWloZMY6S8/th3nh/DRbWShKqcZ27Mx22xBlckbPuxfznHNLWtCcB92YrJHz4jIkuxhbZiCYIW2G5TcoJU3lKAHCgw6rvgSTeX6WgLx25fI+DbvazJwJ6I0YjX86ZDk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=H3qWyb9H; arc=none smtp.client-ip=74.125.227.131 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.b="H3qWyb9H" Received: by mail-pj2-f3.google.com with SMTP id 98e67ed59e1d1-3859292bb51so165313a91.1 for ; Mon, 07 Sep 2026 06:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788786394; x=1789391194; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=riOSU4dH10zq3tO5Dx537AG40XCcFzKoLCwwWkJ2TP8=; b=H3qWyb9HYdUXJ65laXKBATV1baqz1RgE7zo0b3nN9AwTcM5Bt7qRTW9J36gxaYzzNV GELDpAAL3tt4ZvdmFhSzX2zvdFGCasxYHrj6SbjdJRL6Dwr1LCiYj4DBXrTH6yOHWkKI Awa5OTOnpMG/iCsflOls/EnjN5bVePxtYOIoCOCuSpQ/GvRJb4+yuTuSO67ay+//8VG/ 6Po5xHLKnq/4TvsEDO0m+KLup5Ct02olWGNMcavO1zXLzjnPvVJz7N9SQ/f+pQafDB7R //y2yGMAkZpwiEXwLp0jF448C80y3JcjHGbTinlWEHkUjjZUNkTc3GqbKcKPo1z9cBAm 8XgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788786394; x=1789391194; h=content-transfer-encoding:mime-version: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=riOSU4dH10zq3tO5Dx537AG40XCcFzKoLCwwWkJ2TP8=; b=Bihj2iiMuTL7sweDX9FEOLHJNSiePfkNsIrWcQ0GhfsEQifLLf39jJGgZ6PsLmrimy o7IBG4mSzRDXbE912R7jjaGS0cldQQruRcJDaSLI7vwBp6I3yf/tJqZ/865d/SBXs7NM QPU3S6YEtTTEMYcLwni8naUQGbQIH5dF3NTHAD8c4uojhvqFyZLKDFuUOFNcOpFpRN2G V1PCC9q7wC2Ix8VSsIjJlS9WoyhlEa2hdWH/bEcvmFbL0LAH9+ndG1Eqvb06Wz0ReIRz PVHtjv5/ASimk70xZ6RJpjHscqlrcVGEvbf8Eq72FJ7tM4kJZn1CguSHQPKSFuEOxeS/ Rl/w== X-Forwarded-Encrypted: i=1; AKwUvBzZUwM3C5uk9shRCI8gVe5N35b2w7je061ICnANxGbVlMF57n5oR+Mo7TAt2J/hlgN3ZGUgs8XpUbxJPh8=@vger.kernel.org X-Gm-Message-State: AFuF++n9+rJiKeAEKOF6918ZHN+wU+8ae9lXavPqAZfBe651lf4S59OE my/GwvWQnkATqX6Mcf+OARZbsi5o+mrRHM6MBgDtWLH7ymMRk+VcTow= X-Gm-Gg: AYBFou0v23GsrLBABFrJVxDR5f7/uVvE0WVdyFq5nFneQF1W8XyeUg/jtx2wHCJ0FAB +TwuIcMWn3YY1o7UkTD/bXOt/3L292F4UuE3hdbVyaGWSvHFWlTsxxaz9CvF6GJ/7gAY+hVa8Id wjyhHjDUWf2U9n+e1qtkRBNb7YsBfF/8Rk6u6drjXN6GBtkomwa2k8lrD5LyNi2KgtH4Q6W8Vur RvZqhNvPkJgYGUDPp/V84fZD1r3XP0IWF6L+MMsmMPwLnJONx9m9SNrUm36wVW5UgluUfwN6e/H iCmD51xfqTYO9N1mwBs3Wv/KcWwoKGYwWnRTAWdKpi1OeJ2Pi0m121w4xlBtQNdJXtYtgFvEz9n Cm/OmnXoTWPgc35OLgrzij0eANJhlCuvFpgEeLkXUu2Q/GuyO6lF/6dTP7Ox81OlIO7WxICgloE 5+vtXpI8aWOfQT05m9gXPRqwzR8cOwoW/dQGcbQwaABfVSEPJr9Yo2dnXJK/nfpPymVPr2cGg1P 1QHFOZgmZKwTTkrGnipgln31bI= X-Received: by 2002:a17:90b:4b83:b0:398:9bd3:d6d2 with SMTP id 98e67ed59e1d1-39b8bec8c1fmr661379a91.12.1788786394289; Mon, 07 Sep 2026 06:06:34 -0700 (PDT) Received: from ydg-Zenbook-14-UM3406GA ([2001:2d8:6467:d689:c773:5f09:906c:a72b]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b07b197a9sm26742398a91.0.2026.09.07.06.06.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 06:06:33 -0700 (PDT) From: Donggeun Yoo To: Alexei Starovoitov , Andrii Nakryiko , Catalin Marinas , Daniel Borkmann , Eduard Zingerman , Emil Tsalapatis , Ihor Solodrai , Jiri Olsa , Kumar Kartikeya Dwivedi , Mark Rutland , Martin KaFai Lau , Puranjay Mohan , Shuah Khan , Song Liu , Will Deacon , Xu Kuohai , Yonghong Song Cc: bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, donggeunyoo.kernel@gmail.com Subject: [PATCH bpf v3 0/2] bpf, arm64: fix the exception callback's frame pointer Date: Mon, 7 Sep 2026 22:06:22 +0900 Message-ID: <20260907130624.611942-1-donggeunyoo.kernel@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The arm64 JIT does not set BPF_REG_FP in the prologue of an exception callback, so the callback runs with whatever x25 held when bpf_throw() was called. A callback that materializes the register, for instance to pass the address of a local variable to a helper, then works on the frame of the subprogram that threw. Patch 1 sets ctx->fp_used on that path, the same fix commit b114fcee766d ("bpf, arm64: Fix fp initialization for exception boundary") made for the exception boundary. Patch 2 adds a selftest that reaches the case. Tested on aarch64 under QEMU with vmtest.sh, on the base below. Without patch 1 the new test panics the kernel, because the address handed to the helper lands on the helper's own saved return address: pc : 0x1234 lr : 0x1234 Call trace: 0x1234 (P) bpf_test_run+0x188/0x3e0 bpf_prog_test_run_skb+0x47c/0x998 __sys_bpf+0xbdc/0xdd8 Kernel panic - not syncing: Oops: Fatal exception in interrupt 0x1234 is the value the callback reads, so the helper wrote it over its own return address. With patch 1 applied the whole group passes: #117/11 exceptions/exception_throw_subprog_stack_cb:OK #117 exceptions:OK Summary: 1/118 PASSED, 0 SKIPPED, 0/0 FAILED Not tested on other architectures. v1: https://lore.kernel.org/bpf/20260904070210.4163193-1-donggeunyoo.kernel@gmail.com/ v2: https://lore.kernel.org/bpf/20260907054235.473103-1-donggeunyoo.kernel@gmail.com/ v2 -> v3: - patch 2: use the standard multi-line comment style - patch 1: no change, added the Acked-by Nothing compiled changed, so the numbers above are still v2's. v1 -> v2: - rebase onto bpf/master; CI could not apply v1 - spell the three new declarations u64 rather than __u64, to match the rest of progs/exceptions.c - no change to patch 1 Donggeun Yoo (2): bpf, arm64: set up the frame pointer for the exception callback selftests/bpf: cover the exception callback using its own BPF stack arch/arm64/net/bpf_jit_comp.c | 2 ++ .../selftests/bpf/prog_tests/exceptions.c | 1 + .../testing/selftests/bpf/progs/exceptions.c | 30 +++++++++++++++++++ 3 files changed, 33 insertions(+) base-commit: df2908090cda368b01ff43709f51890076c56157 -- 2.53.0