mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Dave Hansen" <dave.hansen@intel.com>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: "Borislav Petkov" <bp@alien8.de>, <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: Tue, 24 Nov 2026 20:17:01 +0000	[thread overview]
Message-ID: <DN3PUVNYI5U3.EG46DZP94II5@gmail.com> (raw)
In-Reply-To: <077779c3-aac7-49c5-8887-0d4266caa2d6@intel.com>

On Tue, Nov 24, 2026 at 07:25 AM Dave Hansen <dave.hansen@intel.com> wrote:
> On 11/23/26 09:23, Kumar Kartikeya Dwivedi wrote:
>> It would be equivalent of doing copy_from_kernel_nofault() in the
>> normal kernel.
>
> ... and running afoul a userspace address. So, no, it's not equivalent.
> These accesses are more wild than anything else we have in the kernel.

copy_from_kernel_nofault() runs into user addresses too.
sysrq-t does it for every idle kworker in print_worker_info():

  copy_from_kernel_nofault(&pwq, &worker->current_pwq, sizeof(pwq));
  copy_from_kernel_nofault(&wq, &pwq->wq, sizeof(wq));

An idle worker has current_pwq == NULL, so the second call gets address 8.
That's the same walk as sk->sk_socket->file: no locks, no NULL check.

The set of addresses is the same. The difference is who refuses a bad one.
"CPU" is a fault and a fixup via extable:

                              user, guard,                  unmapped
                              vsyscall page  non-canonical  kernel
  --------------------------  -------------  -------------  --------
  copy_from_kernel_nofault()  compare        compare        CPU
  PROBE_MEM today             compare        CPU            CPU
  PROBE_MEM, patch 2, SMAP    CPU            CPU            CPU

Every cell ends the same way: no data and no oops.
The series changes one cell.

> Do we at least require that these super specialized programs have the
> bpf_prog_info->gpl_compatible bit set?

Yes. check_ptr_to_btf_access() rejects a load from a kernel struct in a
non-GPL prog:
"Cannot access kernel 'struct sock' from non-GPL compatible program"
The check right above it wants CAP_PERFMON.
It's the same as bpf_probe_read_kernel(), which is gpl_only.

  reply	other threads:[~2026-11-24 20:17 UTC|newest]

Thread overview: 22+ 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 " 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  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
2026-11-23 17:27                     ` Kumar Kartikeya Dwivedi
2026-11-23 18:51                     ` Borislav Petkov
2026-11-24  6:25                       ` 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 [this message]
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

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=DN3PUVNYI5U3.EG46DZP94II5@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@intel.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®