From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Borislav Petkov" <bp@alien8.de>
Cc: <bpf@vger.kernel.org>, "Puranjay Mohan" <puranjay@kernel.org>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"Andy Lutomirski" <luto@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Thomas Gleixner" <tglx@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>, <kkd@meta.com>,
<kernel-team@meta.com>, <x86@kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf-next v1 1/3] x86/mm: Resolve BPF exception fixups for user address faults under SMAP
Date: Mon, 23 Nov 2026 06:58:13 +0000 [thread overview]
Message-ID: <DN2E8Q9V38IF.3O738M7NGLSAL@gmail.com> (raw)
In-Reply-To: <CAP01T75Qps8bKFZAU2gN-3UJTB1aWw46NG5c-sm6K028rSc9sA@mail.gmail.com>
On Sun, Nov 22, 2026 at 07:56 PM Kumar Kartikeya Dwivedi <memxor@gmail.com> wrote:
> On Mon, 23 Nov 2026 at 03:55, Borislav Petkov <bp@alien8.de> wrote:
>> "the only line of defense is for is_bpf_text_address() to really DTRT."
Boris,
SMAP stays on. The SMAP branch in do_user_addr_fault() runs only with
AC clear, after the CPU refused the load.
A wrong answer from is_bpf_text_address() can hide an oops,
but it cannot expose user memory, so your concerns are unsound.
> In fact, for kernel address faults, we already invoke it for exception
> handling. This change would simply extend that to user address faults,
> optionally for BPF code; otherwise, we panic as usual.
Not quite. See:
fixup_exception(regs)
search_exception_tables(regs->ip)
search_bpf_extables(ip)
bpf_prog_ksym_find(ip) progs only, no trampolines
search_extable(ip) exact match of the insn
Here is the alternative
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index aa88370..9fe8705 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1263,7 +1263,16 @@ void do_user_addr_fault(struct pt_regs *regs,
!(error_code & X86_PF_USER) &&
!(regs->flags & X86_EFLAGS_AC))) {
/*
- * No extable entry here. This was a kernel access to an
+ * The CPU refused the access. If the BPF JIT marked this load
+ * as one that may fault, skip it and zero the destination.
+ */
+ if (!user_mode(regs) && !(error_code & X86_PF_WRITE) &&
+ ex_get_fixup_type(regs->ip) == EX_TYPE_BPF &&
+ fixup_exception(regs, X86_TRAP_PF, error_code, address))
+ return;
+
+ /*
+ * No other fixups here. This was a kernel access to an
* invalid pointer. get_kernel_nofault() will not get here.
*/
page_fault_oops(regs, error_code, address);
next prev parent reply other threads:[~2026-11-23 6:58 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 2:49 [PATCH bpf-next v1 0/3] bpf, x86: Drop the PROBE_MEM address range check under SMAP Kumar Kartikeya Dwivedi
2026-10-09 2:49 ` [PATCH bpf-next v1 1/3] x86/mm: Resolve BPF exception fixups for user address faults " Kumar Kartikeya Dwivedi
2026-10-09 3:03 ` sashiko-bot
2026-10-09 4:13 ` Borislav Petkov
2026-10-09 15:23 ` Kumar Kartikeya Dwivedi
2026-11-22 20:08 ` Borislav Petkov
2026-11-22 21:59 ` Kumar Kartikeya Dwivedi
2026-11-23 0:30 ` Borislav Petkov
2026-11-23 0:59 ` Kumar Kartikeya Dwivedi
2026-11-23 2:55 ` Borislav Petkov
2026-11-23 3:56 ` Kumar Kartikeya Dwivedi
2026-11-23 4:34 ` Borislav Petkov
2026-11-23 6:58 ` Alexei Starovoitov [this message]
2026-11-23 17:27 ` Kumar Kartikeya Dwivedi
2026-11-23 18:51 ` Borislav Petkov
2026-11-24 6:25 ` Alexei Starovoitov
2026-11-25 2:17 ` Borislav Petkov
2026-11-25 3:27 ` Alexei Starovoitov
2026-11-23 15:36 ` Dave Hansen
2026-11-23 17:23 ` Kumar Kartikeya Dwivedi
2026-11-24 15:25 ` Dave Hansen
2026-11-24 20:17 ` Alexei Starovoitov
2026-11-25 4:22 ` Andy Lutomirski
2026-11-25 6:45 ` Alexei Starovoitov
2026-11-26 5:38 ` Andy Lutomirski
2026-11-26 6:18 ` Alexei Starovoitov
2026-11-26 17:30 ` Andy Lutomirski
2026-11-27 0:18 ` Alexei Starovoitov
2026-11-27 17:51 ` Andy Lutomirski
2026-11-28 1:48 ` Kumar Kartikeya Dwivedi
2026-11-28 1:55 ` Alexei Starovoitov
2026-12-01 1:49 ` Andy Lutomirski
2026-12-01 2:06 ` Kumar Kartikeya Dwivedi
2026-12-01 2:38 ` Andy Lutomirski
2026-12-01 3:24 ` Kumar Kartikeya Dwivedi
2026-12-01 19:16 ` Andy Lutomirski
2026-12-01 20:16 ` Kumar Kartikeya Dwivedi
2026-10-09 2:49 ` [PATCH bpf-next v1 2/3] bpf, x86: Skip the PROBE_MEM address range check " Kumar Kartikeya Dwivedi
2026-10-09 3:42 ` bot+bpf-ci
2026-10-09 2:49 ` [PATCH bpf-next v1 3/3] selftests/bpf: Test PROBE_MEM loads from invalid addresses Kumar Kartikeya Dwivedi
2026-10-09 2:56 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DN2E8Q9V38IF.3O738M7NGLSAL@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bp@alien8.de \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dave.hansen@linux.intel.com \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=kernel-team@meta.com \
--cc=kkd@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=memxor@gmail.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=puranjay@kernel.org \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.