linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [LSF/MM/BPF TOPIC] eBPF isolation with pkeys
@ 2026-02-12 16:22 Yeoreum Yun
  2026-02-12 16:36 ` Dave Hansen
  2026-02-12 17:44 ` Alexei Starovoitov
  0 siblings, 2 replies; 12+ messages in thread
From: Yeoreum Yun @ 2026-02-12 16:22 UTC (permalink / raw)
  To: lsf-pc, linux-mm, bpf
  Cc: catalin.marinas, david, ryan.roberts, kevin.brodsky,
	sebastian.osterlund, dave.hansen, rick.p.edgecombe, yeoreum.yun

Hi all,

I would like to propose the topic of eBPF isolation with pkeys at the
upcoming LSF/MM/BPF summit.


Background
==========

Today, eBPF programs provide powerful capabilities to extend kernel
functionality without requiring modifications to the kernel itself.
These capabilities are largely enabled by the eBPF verifier, which
enforces memory safety and other constraints to protect the kernel.

However, vulnerabilities in the verifier have repeatedly demonstrated that
eBPF programs can also become a serious attack surface.  In several cases,
flaws in verifier logic have allowed malicious eBPF programs to bypass
safety guarantees and compromise kernel security.

Representative CVEs include:

     - CVE-2020-8835   [1]
     - CVE-2021-3490   [2]
     - CVE-2022-23222  [3]
     - CVE-2023-2163   [4]

To mitigate security risks arising from verifier vulnerabilities, this
proposal introduces an approach to isolate eBPF programs using pkeys
implemented on top of the ARMv8.9 Permission Overlay Extension (POE) in
arm64 [5].


eBPF isolation with pkeys
=========================

The goals of eBPF isolation are as follows:

  1. Prohibit eBPF programs from writing to memory that they
     are not permitted to access.

  2. Prohibit eBPF programs from executing memory that they are
     not permitted to access.

  3. Allow kernel memory writes and code execution only through controlled
     interfaces such as KFUNCS and BPF helpers.

Conceptually, the model can be illustrated as follows:
┌──────────────────────────────────────────────────────────────────┐
│                                     executable memory (RO)       │
│            ┌──────────┐          ┌────────┬─────────┬────────┐   │
│            │          │          │        │         │        │   │
│            │  KFUNCS  │  allowed │  BPF   │         │  BPF   │   │
│            │          │◄─────────┤  PROG  ◄─────────►  PROG  │   │
│            └──────────┘          │        │         │        │   │
│                                  ├────────┘         └────────┤   │
│                                  │                           │   │
│                                  │              ┌────────┐   │   │
│               ┌───────────┐      │              │        │   │   │
│               │ arbitrary │◄─────┼────X-────────┤  BPF   │   │   │
│               │    w/x    │      │              │  PROG  │   │   │
│               └───────────┘      │              │        │   │   │
│                                  │              └────────┘   │   │
│                                  │                           │   │
│   ┌─────────┐◄───┐               │    ┌────────┐             │   │
│   └─────────┘    ├───────────┐   │    │        │             │   │
│                  │    BPF    │◄──┼────┤  BPF   │             │   │
│   ┌─────────┐◄───┤  HELPERS  │   │    │  PROG  │             │   │
│   └─────────┘    └───────────┘   │    │        │             │   │
│                                  └────┴────────┴─────────────┘   │
│                                                                  │
└──────────────────────────────────────────────────────────────────┘

eBPF isolation is implemented by operating with some pkeys for example:

  - PKEY_DEFAULT: used for general kernel memory
  - PKEY_EBPF   : used for memory owned by eBPF programs

Additionally, an extra pkey can be used for specific data or code that is
shared between the core kernel and eBPF programs.

During execution, if an eBPF program attempts to access memory marked with
PKEY_DEFAULT without going through KFUNCS or BPF helpers, a permission
overlay fault is raised by the hardware.

As a result, even if a malicious eBPF program is loaded due to a verifier
vulnerability, any attempt to arbitrarily modify or execute kernel memory
will cause the program to fault and terminate.

This prevents further exploitation and significantly reduces the impact of
verifier bugs.


Goals of the discussion
=======================

The goal of this session is to share concrete ideas on how eBPF isolation
can be implemented using pkeys.

To achieve effective isolation, all memory directly accessible by eBPF
programs must be marked with non-default pkey.  This requires kernel memory
allocators to become pkeys aware.

To that end, this discussion introduces a set of new allocator APIs and
explores more extensible API designs:

  - kmalloc_pkey series
  - vmalloc_pkey series
  - alloc_percpu_pkey series

We also aim to discuss how existing kernel allocators can be internally
extended to propagate and enforce pkey information.


Current status
==============

An RFC series is planned for around Q2 2026, and the experimental
implementations for eBPF isolation with pkey and pkey-aware memory
allocators have already been completed internally.  Using these
implementations, we verified that eBPF programs running under isolation
successfully execute several sched_ext applications provided by
tools/sched_ext, as well as some bpf kselftest cases.


Reference
=========

[1] https://www.zerodayinitiative.com/blog/2020/4/8/cve-2020-8835-linux-kernel-privilege-escalation-via-improper-ebpf-program-verification
[2] https://github.com/chompie1337/Linux_LPE_eBPF_CVE-2021-3490
[3] https://github.com/tr3ee/CVE-2022-23222
[4] https://bughunters.google.com/blog/a-deep-dive-into-cve-2023-2163-how-we-found-and-fixed-an-ebpf-linux-kernel-vulnerability
[5] https://developer.arm.com/community/arm-community-blogs/b/architectures-and-processors-blog/posts/arm-a-profile-architecture-2022


--
Sincerely,
Yeoreum Yun
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-02-20  2:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-12 16:22 [LSF/MM/BPF TOPIC] eBPF isolation with pkeys Yeoreum Yun
2026-02-12 16:36 ` Dave Hansen
2026-02-12 17:14   ` Yeoreum Yun
2026-02-12 18:14     ` Dave Hansen
2026-02-16  9:57       ` Yeoreum Yun
2026-02-12 17:44 ` Alexei Starovoitov
2026-02-12 18:01   ` Yeoreum Yun
2026-02-12 18:37     ` Alexei Starovoitov
2026-02-13 10:08       ` Yeoreum Yun
2026-02-13 21:37         ` Alexei Starovoitov
2026-02-16 14:27           ` James Bottomley
2026-02-20  2:50             ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox