From: Anton Protopopov <a.s.protopopov@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf@vger.kernel.org, daniel@iogearbox.net, andrii@kernel.org,
eddyz87@gmail.com, memxor@gmail.com
Subject: Re: [PATCH v2 bpf-next 00/13] bpf: fmod_ret for each function that returns errors
Date: Fri, 13 Nov 2026 13:00:16 +0000 [thread overview]
Message-ID: <avcJ4OWW99bwMlCP@mail.gmail.com> (raw)
In-Reply-To: <20261113050901.1399091-1-alexei.starovoitov@gmail.com>
On 26/11/13 05:08AM, Alexei Starovoitov wrote:
> From: Alexei Starovoitov <ast@kernel.org>
> In short: with CONFIG_BPF_FMODRET_SCAN=y the build tags the functions that
> return errors, 12633 of them. A program with CAP_BPF and CAP_PERFMON can
> attach to one, skip a call and return one of its errors. It reads the
> arguments as untrusted pointers. No file of net, fs or mm changes. Test:
> one skipped call per function, 4401 functions of net, fs, mm. With this set
> 1 function in 180 then damages the kernel. A deny list by name can take
> those out.
>
> 1. What for?
> BPF can keep user space away from a security bug in the rest of the kernel
> until the fixed kernel runs. An fmod_ret program attaches to a function on
> the way to the bug and fails the bad call:
> SEC("fmod_ret/vfs_fallocate") return len > MAX_LEN ? -EFBIG : 0;
> err = vfs_fallocate(..) --> program
> returns 0 --> call it, err = its result
> returns -EFBIG --> skip it, err = -EFBIG
> Such a program needs targets in net, fs and mm. Today it has 1000 syscall
> entries, the security hooks and about 20 other functions. Of 417 fixes of
> one year that add a failing check to a function, the fixed function is a
> target: today 1 %, Anton's v3 (4) 17 %, this set 50 %.
The main reason for the difference is that my plugin was way more conservative
in "what is a clean path to error". However, given numbers, and how this is
supposed to be operated, more relaxed filter seems better. Authors of fmodret
programs are supposed to weight the consequences: forbid running a vulnerable
code vs. "leak resource", "lock one core", etc. Also, in many cases this should
be possible to fmodret upper the call stack, thus avoiding a problematic
attachment.
We can have a bit more targets via functions returning ERR_PTR(-errno), plus
maybe stuff like "if (err == -EINVAL) goto out", but maybe it was simpler
at IR (see 'bpf: Follow PHIs in bpf_scan_ir' in v3). All this is follow-ups.
For this series I don't see blockers, a few comments I had in individual patches.
One nit I've just remebered: why to tag functions which aren't attachable?
My old code stripped them out, they only take space and will be rejected
in any case.
I've also tested v2 on my x86.
> 2. What is a target?
> [...]
next prev parent reply other threads:[~2026-11-13 12:48 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 5:08 [PATCH v2 bpf-next 00/13] bpf: fmod_ret for each function that returns errors Alexei Starovoitov
2026-11-13 5:08 ` [PATCH v2 bpf-next 01/13] selftests/bpf: Don't depend on the width of a BTF id in verifier_live_stack Alexei Starovoitov
2026-11-13 11:13 ` Anton Protopopov
2026-11-13 5:08 ` [PATCH v2 bpf-next 02/13] resolve_btfids: Read the code of an ELF file by address Alexei Starovoitov
2026-11-13 5:08 ` [PATCH v2 bpf-next 03/13] resolve_btfids: Describe machine instructions with LLVM's MC layer Alexei Starovoitov
2026-11-13 11:45 ` Anton Protopopov
2026-11-13 5:08 ` [PATCH v2 bpf-next 04/13] resolve_btfids: Find the definitions that reach the return value Alexei Starovoitov
2026-11-13 5:08 ` [PATCH v2 bpf-next 05/13] resolve_btfids: Tag the functions that return errors Alexei Starovoitov
2026-11-13 5:08 ` [PATCH v2 bpf-next 06/13] resolve_btfids: Fold the constants of a select without a branch Alexei Starovoitov
2026-11-13 11:59 ` Anton Protopopov
2026-11-13 5:08 ` [PATCH v2 bpf-next 07/13] resolve_btfids: Say which registers an instruction reads Alexei Starovoitov
2026-11-13 12:03 ` Anton Protopopov
2026-11-13 5:08 ` [PATCH v2 bpf-next 08/13] resolve_btfids: Don't list an error that follows work on an argument Alexei Starovoitov
2026-11-13 5:52 ` bot+bpf-ci
2026-11-13 16:15 ` Alexei Starovoitov
2026-11-13 12:14 ` Anton Protopopov
2026-11-13 5:08 ` [PATCH v2 bpf-next 09/13] bpf: Allow fmod_ret on tagged functions and check the return value Alexei Starovoitov
2026-11-13 5:52 ` bot+bpf-ci
2026-11-13 16:17 ` Alexei Starovoitov
2026-11-13 12:20 ` Anton Protopopov
2026-11-13 16:17 ` Alexei Starovoitov
2026-11-13 5:08 ` [PATCH v2 bpf-next 10/13] selftests/bpf: Test fmod_ret on tagged functions Alexei Starovoitov
2026-11-13 5:08 ` [PATCH v2 bpf-next 11/13] bpf: Mark the arguments of fmod_ret progs as PTR_UNTRUSTED Alexei Starovoitov
2026-11-13 11:09 ` Anton Protopopov
2026-11-13 16:30 ` Alexei Starovoitov
2026-11-13 5:09 ` [PATCH v2 bpf-next 12/13] bpf: Treat the type of an untrusted pointer as a hint Alexei Starovoitov
2026-11-13 5:52 ` bot+bpf-ci
2026-11-13 16:33 ` Alexei Starovoitov
2026-11-13 5:09 ` [PATCH v2 bpf-next 13/13] selftests/bpf: Test untrusted pointers in fmod_ret progs Alexei Starovoitov
2026-11-13 13:00 ` Anton Protopopov [this message]
2026-11-13 16:37 ` [PATCH v2 bpf-next 00/13] bpf: fmod_ret for each function that returns errors Alexei Starovoitov
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=avcJ4OWW99bwMlCP@mail.gmail.com \
--to=a.s.protopopov@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=memxor@gmail.com \
/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.