Go to file
Alexei Starovoitov 5bbb9e1f08 Merge branch 'bpf-x64-fix-tailcall-infinite-loop'
Leon Hwang says:

====================
bpf, x64: Fix tailcall infinite loop

This patch series fixes a tailcall infinite loop on x64.

From commit ebf7d1f508 ("bpf, x64: rework pro/epilogue and tailcall
handling in JIT"), the tailcall on x64 works better than before.

From commit e411901c0b ("bpf: allow for tailcalls in BPF subprograms
for x64 JIT"), tailcall is able to run in BPF subprograms on x64.

From commit 5b92a28aae ("bpf: Support attaching tracing BPF program
to other BPF programs"), BPF program is able to trace other BPF programs.

How about combining them all together?

1. FENTRY/FEXIT on a BPF subprogram.
2. A tailcall runs in the BPF subprogram.
3. The tailcall calls the subprogram's caller.

As a result, a tailcall infinite loop comes up. And the loop would halt
the machine.

As we know, in tail call context, the tail_call_cnt propagates by stack
and rax register between BPF subprograms. So do in trampolines.

How did I discover the bug?

From commit 7f6e4312e1 ("bpf: Limit caller's stack depth 256 for
subprogs with tailcalls"), the total stack size limits to around 8KiB.
Then, I write some bpf progs to validate the stack consuming, that are
tailcalls running in bpf2bpf and FENTRY/FEXIT tracing on bpf2bpf.

At that time, accidently, I made a tailcall loop. And then the loop halted
my VM. Without the loop, the bpf progs would consume over 8KiB stack size.
But the _stack-overflow_ did not halt my VM.

With bpf_printk(), I confirmed that the tailcall count limit did not work
expectedly. Next, read the code and fix it.

Thank Ilya Leoshkevich, this bug on s390x has been fixed.

Hopefully, this bug on arm64 will be fixed in near future.
====================

Link: https://lore.kernel.org/r/20230912150442.2009-1-hffilwlqm@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2023-09-12 13:06:12 -07:00
Documentation Including fixes from netfilter and bpf. 2023-09-07 18:33:07 -07:00
LICENSES LICENSES: Add the copyleft-next-0.3.1 license 2022-11-08 15:44:01 +01:00
arch bpf, x64: Fix tailcall infinite loop 2023-09-12 13:06:12 -07:00
block for-6.6/block-2023-08-28 2023-08-29 20:21:42 -07:00
certs certs: Reference revocation list for all keyrings 2023-08-17 20:12:41 +00:00
crypto This update includes the following changes: 2023-08-29 11:23:29 -07:00
drivers Including fixes from netfilter and bpf. 2023-09-07 18:33:07 -07:00
fs ntfs3: drop inode references in ntfs_put_super() 2023-09-07 10:23:37 -07:00
include bpf, x64: Fix tailcall infinite loop 2023-09-12 13:06:12 -07:00
init workqueue: Changes for v6.6 2023-09-01 16:06:32 -07:00
io_uring for-6.6/io_uring-2023-08-28 2023-08-29 20:11:33 -07:00
ipc Add x86 shadow stack support 2023-08-31 12:20:12 -07:00
kernel bpf, x64: Fix tailcall infinite loop 2023-09-12 13:06:12 -07:00
lib printk changes for 6.6 2023-09-04 13:20:19 -07:00
mm Seven hotfixes. Four are cc:stable and the remainder pertain to issues 2023-09-05 12:22:39 -07:00
net Including fixes from netfilter and bpf. 2023-09-07 18:33:07 -07:00
rust Documentation work keeps chugging along; stuff for 6.6 includes: 2023-08-30 20:05:42 -07:00
samples selftests/bpf: trace_helpers.c: Optimize kallsyms cache 2023-09-08 16:22:41 -07:00
scripts Including fixes from netfilter and bpf. 2023-09-07 18:33:07 -07:00
security Three cleanup patches, no behavior changes. 2023-09-04 10:38:35 -07:00
sound This pull request contains the following changes for UML: 2023-09-04 11:32:21 -07:00
tools selftests/bpf: Add testcases for tailcall infinite loop fixing 2023-09-12 13:06:12 -07:00
usr initramfs: Encode dependency on KBUILD_BUILD_TIMESTAMP 2023-06-06 17:54:49 +09:00
virt ARM: 2023-09-07 13:52:20 -07:00
.clang-format iommu: Add for_each_group_device() 2023-05-23 08:15:51 +02:00
.cocciconfig
.get_maintainer.ignore get_maintainer: add Alan to .get_maintainer.ignore 2022-08-20 15:17:44 -07:00
.gitattributes .gitattributes: set diff driver for Rust source code files 2023-05-31 17:48:25 +02:00
.gitignore kbuild: rpm-pkg: rename binkernel.spec to kernel.spec 2023-07-25 00:59:33 +09:00
.mailmap for-linus-2023083101 2023-09-01 12:31:44 -07:00
.rustfmt.toml rust: add `.rustfmt.toml` 2022-09-28 09:02:20 +02:00
COPYING COPYING: state that all contributions really are covered by this file 2020-02-10 13:32:20 -08:00
CREDITS USB: Remove Wireless USB and UWB documentation 2023-08-09 14:17:32 +02:00
Kbuild Kbuild updates for v6.1 2022-10-10 12:00:45 -07:00
Kconfig kbuild: ensure full rebuild when the compiler is updated 2020-05-12 13:28:33 +09:00
MAINTAINERS RTC for 6.6 2023-09-07 16:07:35 -07:00
Makefile Kbuild updates for v6.6 2023-09-05 11:01:47 -07:00
README Drop all 00-INDEX files from Documentation/ 2018-09-09 15:08:58 -06:00

README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.