eBPF-based security platform
kernel: drop the x86 ftrace patch now that bpf-next carries it
Daniel Borkmannbe3029288a64
diff --git a/AGENTS.md b/AGENTS.mdindex ea7ee884..8544244a 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -313,7 +313,7 @@ one usually still compiles and passes tests.authority. The seal marks what it labels at creation, what shirudoopens and what anyone opens for writing or as a directory, andrefreshes a directory's mark in every entry hook from the label it- reads there (carried kernel patches 0004 and 0005 make those hooks+ reads there (carried kernel patches 0003 and 0004 make those hookssleepable and `dentry->d_parent` trusted), so that`inode_init_security`, which has no dentry, labels the new inode fromit: the marks are a cache, never the decision. A sealed inode cannotdiff --git a/Documentation/concepts/background/tpm.rst b/Documentation/concepts/background/tpm.rstindex 7e696c9f..c628face 100644--- a/Documentation/concepts/background/tpm.rst+++ b/Documentation/concepts/background/tpm.rst@@ -359,7 +359,7 @@ The signature alone does not keep other processes out. The bytes thewriter key derives from are not a secret, so any process that recreatesthe key could ask the TPM to sign. An LSM hook in the kernel keepsthem out. The companion kernel patch-:src:`kernel/0002-tpm-Let-LSMs-inspect-userspace-commands.patch` adds an+:src:`kernel/0001-tpm-Let-LSMs-inspect-userspace-commands.patch` adds anLSM hook, ``tpm_command``, that sees every command written to``/dev/tpm0`` or ``/dev/tpmrm0`` before the driver sends or queues it.shirudo's ``lsm/tpm_command``diff --git a/Documentation/contribute/arch-support.rst b/Documentation/contribute/arch-support.rstindex 1f204f89..c52d3a58 100644--- a/Documentation/contribute/arch-support.rst+++ b/Documentation/contribute/arch-support.rst@@ -49,9 +49,9 @@ Comparison``-mbranch-protection=standard``- None* - Carried kernel patches- - ``kernel/0001`` to ``kernel/0005``- - ``kernel/0002`` to ``kernel/0005``- - ``kernel/0002`` to ``kernel/0005``+ - ``kernel/0001`` to ``kernel/0004``+ - ``kernel/0001`` to ``kernel/0004``+ - ``kernel/0001`` to ``kernel/0004``* - BPF trampolines (``lsm``, ``fentry``, ``fexit``, ``fmod_ret``)- 36 programs per function- 37 programs per function@@ -83,10 +83,12 @@ Comparisonx86-64-------- Targets need ``kernel/0001``. Without it, a kernel whose functions can- start at an odd address, such as one built with gcc 13 and+- Targets need upstream commit ``31ac959c915c``, which shirudo carried+ until bpf-next took it. Without it, a kernel whose functions can start+ at an odd address, such as one built with gcc 13 and``CONFIG_CC_OPTIMIZE_FOR_SIZE=y``, can crash when a BPF trampoline is- installed. :doc:`/internals/kernel-patches` explains the bug.+ updated. :doc:`/operate/plan/system-requirements` says which+ kernels need it.- ``kernel-cve`` defines ``__TARGET_ARCH_x86`` for its ``kprobe``programs and loads on x86-64 only.@@ -150,7 +152,7 @@ shirudoLinux kernel~~~~~~~~~~~~-- Get ``kernel/0001`` to ``kernel/0005`` upstream. None of them is in+- Get ``kernel/0001`` to ``kernel/0004`` upstream. None of them is inbpf-next; :doc:`/internals/kernel-patches` describes each.- riscv64: BPF trampolines on a kernel built with ``CONFIG_CFI``.- riscv64: arenas on CPUs without Zacas.diff --git a/Documentation/internals/enforcement.rst b/Documentation/internals/enforcement.rstindex ebd75ddc..ae4fd841 100644--- a/Documentation/internals/enforcement.rst+++ b/Documentation/internals/enforcement.rst@@ -555,7 +555,7 @@ when the record it needs is missing.- No label removes the mark; a failed read leaves it.The label verdict of the ``seal`` hooks reads ``security.bpf.shirudo``-with the xattr kfuncs, which with the carried patch 0003 return it+with the xattr kfuncs, which with the carried patch 0002 return itwithout the calling task's permission and upstream check thatpermission first. No label (``ENODATA``) and no securityextended attributes on the file system (``EOPNOTSUPP``) count asdiff --git a/Documentation/internals/kernel-interfaces.rst b/Documentation/internals/kernel-interfaces.rstindex 711615d9..9b3a72d0 100644--- a/Documentation/internals/kernel-interfaces.rst+++ b/Documentation/internals/kernel-interfaces.rst@@ -272,12 +272,12 @@ LSM hooks* - ``inode_create``, ``inode_symlink``, ``inode_mknod``,``inode_rename`` (all sleepable)- ``seal``- - Carried patch 0005, for the read of ``dentry->d_parent``+ - Carried patch 0004, for the read of ``dentry->d_parent``* - ``inode_mkdir``, ``inode_link``, ``inode_set_acl``,``inode_remove_acl``, ``inode_file_setattr``, ``inode_copy_up``(all sleepable)- ``seal``- - Carried patch 0004, and 0005 for ``inode_mkdir`` and+ - Carried patch 0003, and 0004 for ``inode_mkdir`` and``inode_link``A missing hook makes the object fail to load. :doc:`enforcement` gives@@ -295,7 +295,7 @@ Kfuncs and helpers* - ``bpf_get_file_xattr()``, ``bpf_get_dentry_xattr()``- Read ``security.bpf.shirudo`` and ``security.bpf.shirudo.policy``.Sleepable; upstream they check ``MAY_READ`` for the calling task- first, which the carried patch 0003 skips for ``security.bpf.``+ first, which the carried patch 0002 skips for ``security.bpf.``names.* - ``bpf_inode_init_xattr()``- Add the label in ``inode_init_security``.diff --git a/Documentation/internals/kernel-patches.rst b/Documentation/internals/kernel-patches.rstindex c0105467..f895fd6f 100644--- a/Documentation/internals/kernel-patches.rst+++ b/Documentation/internals/kernel-patches.rst@@ -22,37 +22,38 @@ Summary- Author- In bpf-next- Architectures- * - ``0001-x86-ftrace-Mark-jmp-mode-by-clearing-bit-63-of-the-trampoline-address.patch``- - Daniel Borkmann- - No- - x86-64- * - ``0002-tpm-Let-LSMs-inspect-userspace-commands.patch``+ * - ``0001-tpm-Let-LSMs-inspect-userspace-commands.patch``- KP Singh- No- All- * - ``0003-bpf-Read-security.bpf-xattrs-for-LSM-programs-without-the-caller-s-permission.patch``+ * - ``0002-bpf-Read-security.bpf-xattrs-for-LSM-programs-without-the-caller-s-permission.patch``- Daniel Borkmann- No- All- * - ``0004-bpf-Let-sleepable-LSM-programs-attach-to-the-remaining-inode-hooks.patch``+ * - ``0003-bpf-Let-sleepable-LSM-programs-attach-to-the-remaining-inode-hooks.patch``- Daniel Borkmann- No- All- * - ``0005-bpf-Treat-dentry-d_parent-as-a-trusted-pointer.patch``+ * - ``0004-bpf-Treat-dentry-d_parent-as-a-trusted-pointer.patch``- Daniel Borkmann- No- All"In bpf-next" was checked against the bpf-next tree at commit-``cd5bc55288d4``: ``include/linux/ftrace.h`` there still marks jmp mode-with bit 0, ``include/linux/lsm_hook_defs.h`` has no ``tpm_command``-hook, ``fs/bpf_fs_kfuncs.c`` checks the calling task's read permission-before it returns a ``security.bpf.`` xattr to an LSM program, the-sleepable hook set of ``kernel/bpf/bpf_lsm.c`` lacks ``inode_mkdir``,-``inode_link``, ``inode_set_acl``, ``inode_remove_acl``,+``57fae4059380``: ``include/linux/lsm_hook_defs.h`` there has no+``tpm_command`` hook, ``fs/bpf_fs_kfuncs.c`` checks the calling task's+read permission before it returns a ``security.bpf.`` xattr to an LSM+program, the sleepable hook set of ``kernel/bpf/bpf_lsm.c`` lacks+``inode_mkdir``, ``inode_link``, ``inode_set_acl``, ``inode_remove_acl``,``inode_file_setattr`` and ``inode_copy_up``, and the verifier trusts``d_inode`` of a dentry but not ``d_parent``.+The x86 ftrace fix the tree used to carry is upstream as+``31ac959c915c`` ("x86/ftrace: Mark jmp mode by clearing bit 63 of+trampoline address"), in bpf-next and in the bpf fixes tree for 7.4.+:doc:`/operate/plan/system-requirements` says which kernels still need+it.+How the test kernel applies them--------------------------------@@ -62,55 +63,6 @@ How the test kernel applies them``git apply --index`` and commits it, and skips a patch whose reversealready applies. A patch that applies neither way fails the build.-x86 ftrace jmp mode----------------------Subject- x86/ftrace: Mark jmp mode by clearing bit 63 of the trampoline- address--Fixes- ``0c3772a8db1f`` ("x86/ftrace: Implement DYNAMIC_FTRACE_WITH_JMP"),- first released in v6.19.--Files- ``arch/x86/kernel/ftrace_64.S``, ``include/linux/ftrace.h``,- ``kernel/trace/Kconfig``.--What it changes- With ``CONFIG_DYNAMIC_FTRACE_WITH_JMP``, which only x86-64 selects,- ``ftrace_call_replace()`` emits a ``jmp`` instead of a ``call`` when- bit 0 of the target is set, the mark of a direct trampoline entered- by a jump. The same code patches the call of the ftrace callback in- ``ftrace_caller``, ``ftrace_regs_caller`` and the ftrace trampolines,- but a callback is a C function and can start at an odd address. It- does with gcc 13 and ``CONFIG_CC_OPTIMIZE_FOR_SIZE=y``: gcc 13 has no- ``-fmin-function-alignment``, and ``-falign-functions=16`` does not- apply to functions optimized for size. The call then becomes a jump- to the byte before the callback, which decodes as another instruction- and swallows part of the callback's prologue; the callback runs- without a return address and returns through the saved registers.- The patch marks jmp mode by- clearing bit 63 instead, which is set in every x86-64 kernel text- address, so no callback can carry the mark, and a marked address- that is used without being unmarked is not canonical and faults.--Why shirudo needs it- The list callback ``ftrace_ops_list_func()`` is installed whenever two- ``ftrace_ops`` are registered, and every- ``update_ftrace_direct_mod()`` registers a stub ops for the sites it- modifies. Detaching one of several BPF LSM programs from a busy hook- is such an update. shirudo puts several programs on the same hooks,- ``bpf2`` and ``seal`` share ten, and an upatch unload detaches- programs from hooks that other tasks are running. The test kernel's- slim configuration sets ``CONFIG_CC_OPTIMIZE_FOR_SIZE=y``.--Without it- On an affected x86-64 build, a task that runs the hook during the- trampoline update can take a kernel page fault on an instruction- fetch, and the kernel oopses. Builds whose callbacks start at even- addresses, and other architectures, are not affected.-TPM command LSM hook--------------------diff --git a/Documentation/internals/seal.rst b/Documentation/internals/seal.rstindex b669ecab..5e256387 100644--- a/Documentation/internals/seal.rst+++ b/Documentation/internals/seal.rst@@ -261,7 +261,7 @@ Marks are a cacheentry's parent dentry and refresh its mark on the way, which``inode_init_security``, the one hook without a dentry, labels thenew inode from in the same operation. On a kernel without the- carried patches 0004 and 0005, the seal's entry hooks do not load+ carried patches 0003 and 0004, the seal's entry hooks do not loadand ``init`` fails.Label reads on an upstream kerneldiff --git a/Documentation/operate/plan/hardening.rst b/Documentation/operate/plan/hardening.rstindex 43a4c2a4..5ac76653 100644--- a/Documentation/operate/plan/hardening.rst+++ b/Documentation/operate/plan/hardening.rst@@ -90,7 +90,7 @@ Kernel configurationcount, including the module signing key of the kernel build, sokeep that key in the same custody as the config key.- no- * - The ``tpm_command`` LSM hook from ``kernel/0002`` in the shirudo+ * - The ``tpm_command`` LSM hook from ``kernel/0001`` in the shirudotree- The hook lets shirudo refuse extensions of its register byother processes.diff --git a/Documentation/operate/plan/system-requirements.rst b/Documentation/operate/plan/system-requirements.rstindex 05e2914b..3576b05f 100644--- a/Documentation/operate/plan/system-requirements.rst+++ b/Documentation/operate/plan/system-requirements.rst@@ -24,7 +24,7 @@ Architectures- Notes* - x86-64- Target and operator. The test VM runs on x86-64 hosts. Targets- need ``kernel/0001`` (see below).+ need upstream commit ``31ac959c915c`` (see below).* - arm64- Target and operator. The test VM runs on arm64 hosts.* - riscv64@@ -41,7 +41,7 @@ Target kernelThe target runs a bpf-next kernel with the signed-loader ABI. A releasenumber does not identify such a kernel: development trees report the-release they follow (the test kernel reports ``7.3.0-bpf-next+``), and+release they follow (the test kernel reports ``7.4.0-rc1-bpf-next+``), andthe ABI and the patches below decide whether shirudo works on it.Kernel source@@ -60,36 +60,38 @@ Kernel source``KEY_SPEC_BPF_KEYRING`` with the ``bpf.keyring_unsealed``parameter, and the kfuncs ``bpf_inode_init_xattr`` and``bpf_real_data_inode``. The test suite runs bpf-next commit- ``cd5bc55288d4``.+ ``57fae4059380``.* - Upstream commit ``1041fca2ee8a``- ``keys: add KEY_SPEC_DM_VERITY_KEYRING``. ``shirudo init``enrolls and seals the config certificate in the ``.dm-verity``keyring through ``KEY_SPEC_DM_VERITY_KEYRING``. Apply it to abpf-next tree that predates it.- * - :src:`kernel/0001-x86-ftrace-Mark-jmp-mode-by-clearing-bit-63-of-the-trampoline-address.patch`- - x86-64 only. Without it, detaching one BPF program from a hook- that others share can crash tasks that run the hook during the- update, on kernels where an ftrace callback starts at an odd- address (seen with gcc 13 and ``CONFIG_CC_OPTIMIZE_FOR_SIZE=y``).- Unloading an upatch detaches its programs from hooks that other- programs share.- * - :src:`kernel/0002-tpm-Let-LSMs-inspect-userspace-commands.patch`+ * - Upstream commit ``31ac959c915c``+ - ``x86/ftrace: Mark jmp mode by clearing bit 63 of trampoline+ address``, x86-64 only, in bpf-next and in the bpf fixes tree for+ 7.4. Without it, detaching one BPF program from a hook that others+ share can crash tasks that run the hook during the update, on+ kernels where an ftrace callback starts at an odd address (seen+ with gcc 13 and ``CONFIG_CC_OPTIMIZE_FOR_SIZE=y``). Unloading an+ upatch detaches its programs from hooks that other programs+ share. Apply it to an x86-64 tree that predates it.+ * - :src:`kernel/0001-tpm-Let-LSMs-inspect-userspace-commands.patch`- Adds the ``tpm_command`` LSM hook. ``shirudo init`` attaches``lsm/tpm_command`` to refuse an untrusted ``TPM2_NV_Extend`` ofits register and fails without the hook.- * - :src:`kernel/0003-bpf-Read-security.bpf-xattrs-for-LSM-programs-without-the-caller-s-permission.patch`+ * - :src:`kernel/0002-bpf-Read-security.bpf-xattrs-for-LSM-programs-without-the-caller-s-permission.patch`- Lets an LSM program read a ``security.bpf.`` xattr without thecalling task's read permission on the inode, as the in-kernelLSMs read their labels. Without it the seal takes a label itscaller may not read for a missing one unless the inode carries amark, which root can arrange with an idmapped mount or an ACL.- * - :src:`kernel/0004-bpf-Let-sleepable-LSM-programs-attach-to-the-remaining-inode-hooks.patch`+ * - :src:`kernel/0003-bpf-Let-sleepable-LSM-programs-attach-to-the-remaining-inode-hooks.patch`- Lets a sleepable LSM program attach to ``inode_mkdir``,``inode_link``, ``inode_set_acl``, ``inode_remove_acl``,``inode_file_setattr`` and ``inode_copy_up``. The seal readslabels in those hooks and ``shirudo init`` fails to attach themwithout it.- * - :src:`kernel/0005-bpf-Treat-dentry-d_parent-as-a-trusted-pointer.patch`+ * - :src:`kernel/0004-bpf-Treat-dentry-d_parent-as-a-trusted-pointer.patch`- Lets an LSM program pass ``dentry->d_parent`` to the xattr kfunc.The seal reads the label of the directory a new entry goes intofrom it; without the patch the verifier refuses the seal's entry@@ -111,7 +113,7 @@ Identify the kernelwithout it fails with ``kernel_abi_unsupported``.- The test harness builds bpf-next by default. It also builds releasetags and refuses any tag older than v7.4. It applies the patches in- :src:`kernel/` to either. A release kernel still needs ``kernel/0002``.+ :src:`kernel/` to either. A release kernel still needs ``kernel/0001``.Kernel configuration~~~~~~~~~~~~~~~~~~~~diff --git a/Documentation/security/threat-model.rst b/Documentation/security/threat-model.rstindex 695a98eb..2178dd4f 100644--- a/Documentation/security/threat-model.rst+++ b/Documentation/security/threat-model.rst@@ -154,11 +154,11 @@ without the protection.``inode_remove_acl``, ``inode_file_setattr`` and``inode_copy_up``, and a ``dentry->d_parent`` the verifiertrusts. Upstream has none of these, and shirudo carries them as- :src:`kernel/0002-tpm-Let-LSMs-inspect-userspace-commands.patch`,- :src:`kernel/0003-bpf-Read-security.bpf-xattrs-for-LSM-programs-without-the-caller-s-permission.patch`,- :src:`kernel/0004-bpf-Let-sleepable-LSM-programs-attach-to-the-remaining-inode-hooks.patch`+ :src:`kernel/0001-tpm-Let-LSMs-inspect-userspace-commands.patch`,+ :src:`kernel/0002-bpf-Read-security.bpf-xattrs-for-LSM-programs-without-the-caller-s-permission.patch`,+ :src:`kernel/0003-bpf-Let-sleepable-LSM-programs-attach-to-the-remaining-inode-hooks.patch`and- :src:`kernel/0005-bpf-Treat-dentry-d_parent-as-a-trusted-pointer.patch`.+ :src:`kernel/0004-bpf-Treat-dentry-d_parent-as-a-trusted-pointer.patch`.- T1 needs the ABI, T5 the hook, T3 the label read, the sleepablehooks and the trusted parent.- Partly. The pre-flight check ``signed_loader_kernel_abi`` tests@@ -722,7 +722,7 @@ receive no binding to these maps.A labeled directory takes new entries, by create, mkdir, symlink,mknod, hard link or rename, only from authorized tasks (``SealEntry``):each entry hook reads the directory's label from the new entry's parent-dentry, which the carried patches 0004 and 0005 (A3) make possible by+dentry, which the carried patches 0003 and 0004 (A3) make possible byletting a sleepable program attach to ``inode_mkdir`` and ``inode_link``and by trusting ``dentry->d_parent``, and refreshes the directory'smark on the way, from which ``lsm/inode_init_security`` gives the newdiff --git a/kernel/0002-tpm-Let-LSMs-inspect-userspace-commands.patch b/kernel/0001-tpm-Let-LSMs-inspect-userspace-commands.patchsimilarity index 100%rename from kernel/0002-tpm-Let-LSMs-inspect-userspace-commands.patchrename to kernel/0001-tpm-Let-LSMs-inspect-userspace-commands.patchdiff --git a/kernel/0001-x86-ftrace-Mark-jmp-mode-by-clearing-bit-63-of-the-trampoline-address.patch b/kernel/0001-x86-ftrace-Mark-jmp-mode-by-clearing-bit-63-of-the-trampoline-address.patchdeleted file mode 100644index 73d1aa94..00000000--- a/kernel/0001-x86-ftrace-Mark-jmp-mode-by-clearing-bit-63-of-the-trampoline-address.patch+++ /dev/null@@ -1,126 +0,0 @@-From b1ee33b5478d0ac4553b65f442f89a3d0feb4e8e Mon Sep 17 00:00:00 2001-From: Daniel Borkmann <[email protected]>-Date: Tue, 27 Oct 2026 21:29:53 +0000-Subject: [PATCH] x86/ftrace: Mark jmp mode by clearing bit 63 of the- trampoline address--Since commit 0c3772a8db1f ("x86/ftrace: Implement DYNAMIC_FTRACE_WITH_JMP")-ftrace_call_replace() emits a jmp instead of a call when bit 0 of the-target is set, the mark of a direct trampoline that is entered by a jmp.-ftrace_update_ftrace_func() and arch_ftrace_update_trampoline() use it-too, for the call of the ftrace callback in ftrace_caller, ftrace_regs_caller-and the ftrace trampolines, but a callback is a C function and can start-at an odd address. It does with gcc13 and CONFIG_CC_OPTIMIZE_FOR_SIZE=y:-gcc13 has no -fmin-function-alignment, so CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT-is not set, and the -falign-functions=16 used in its place does not apply-to functions optimized for size. Here ftrace_ops_list_func() starts at:-- ffffffff810e0147 T ftrace_ops_list_func--ftrace_regs_call then becomes a jmp to the byte before it:-- ftrace_regs_call ffffffff810374f3: e9 4e 8c 0a 00--That byte is the last one of the preceding function's tail jump, and with-the first two of ftrace_ops_list_func() it decodes as an inc DWORD PTR-[rcx+0x57], which swallows the push %r15 of the prologue. Entered without-a return address and one push short, the list function returns through-the pt_regs that ftrace_regs_caller saved, here to the saved R14:-- BUG: unable to handle page fault for address: ffff888116c29f40- #PF: supervisor instruction fetch in kernel mode- RIP: 0010:0xffff888116c29f40- R13: 0000000000000000 R14: ffff888116c29f40 R15: 0000000000000000- Call Trace:- ? bpf_trampoline_6442499918+0x1/0x149- ? bpf_lsm_file_open+0x5/0x8- ? bpf_lsm_file_open+0x5/0x8- ? security_file_open+0x19/0x46- ? do_dentry_open+0x16c/0x32a--The list function is installed whenever two ftrace_ops are registered,-and a function that two of them trace calls it. A kprobe next to a BPF-trampoline is one such case, and with the single ftrace_ops of the BPF-trampolines every update_ftrace_direct_mod() is another, as it registers-a stub ops for the sites it modifies. Here, detaching one of several BPF-LSM programs from a busy hook crashed the tasks that ran the hook during-the update.--Bit 0 is free only in the direct trampolines that a dyn_ftrace record can-point to, but bit 63 is set in every kernel text address on x86_64. Thus,-mark jmp mode by clearing bit 63 instead, so that ftrace_is_jmp() is false-for any callback, whatever its alignment, and ftrace_regs_caller sets the-bit again where it cleared bit 0 before. A marked address is not canonical,-so one that is used without ftrace_jmp_get() faults instead of running-from a byte before its target.--Fixes: 0c3772a8db1f ("x86/ftrace: Implement DYNAMIC_FTRACE_WITH_JMP")-Suggested-by: Steven Rostedt <[email protected]>-Signed-off-by: Daniel Borkmann <[email protected]>-Cc: Menglong Dong <[email protected]>----- arch/x86/kernel/ftrace_64.S | 6 +++---- include/linux/ftrace.h | 8 +++++---- kernel/trace/Kconfig | 3 ++-- 3 files changed, 10 insertions(+), 7 deletions(-)--diff --git a/arch/x86/kernel/ftrace_64.S b/arch/x86/kernel/ftrace_64.S-index 62c1c93aa1c6a6..d0c2c7ea6ecc91 100644---- a/arch/x86/kernel/ftrace_64.S-+++ b/arch/x86/kernel/ftrace_64.S-@@ -286,9 +286,9 @@ SYM_INNER_LABEL(ftrace_regs_caller_end, SYM_L_GLOBAL)- RET-- 1:-- testb $1, %al-- jz 2f-- andq $0xfffffffffffffffe, %rax-+ /* With bit 63 clear, see ftrace_jmp_set(), jmp to the trampoline */-+ btsq $63, %rax-+ jc 2f- movq %rax, MCOUNT_REG_SIZE+8(%rsp)- restore_mcount_regs- /* Restore flags */-diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h-index b041d9142d2b8a..1c2056a1a68b30 100644---- a/include/linux/ftrace.h-+++ b/include/linux/ftrace.h-@@ -618,19 +618,21 @@ static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs,- #endif /* CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS */-- #ifdef CONFIG_DYNAMIC_FTRACE_WITH_JMP-+#define FTRACE_JMP_BIT BIT(BITS_PER_LONG - 1)-+- static inline bool ftrace_is_jmp(unsigned long addr)- {-- return addr & 1;-+ return !(addr & FTRACE_JMP_BIT);- }-- static inline unsigned long ftrace_jmp_set(unsigned long addr)- {-- return addr | 1UL;-+ return addr & ~FTRACE_JMP_BIT;- }-- static inline unsigned long ftrace_jmp_get(unsigned long addr)- {-- return addr & ~1UL;-+ return addr | FTRACE_JMP_BIT;- }- #else- static inline bool ftrace_is_jmp(unsigned long addr)-diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig-index 0ab5916575a97a..efd477c851e957 100644---- a/kernel/trace/Kconfig-+++ b/kernel/trace/Kconfig-@@ -87,7 +87,8 @@ config HAVE_DYNAMIC_FTRACE_WITH_JMP- bool- help- If the architecture supports to replace the __fentry__ with a-- "jmp" instruction.-+ "jmp" instruction. The top bit of its kernel text addresses must-+ be set, as clearing it marks a direct trampoline to jmp to.-- config HAVE_SYSCALL_TRACEPOINTS- booldiff --git a/kernel/0003-bpf-Read-security.bpf-xattrs-for-LSM-programs-without-the-caller-s-permission.patch b/kernel/0002-bpf-Read-security.bpf-xattrs-for-LSM-programs-without-the-caller-s-permission.patchsimilarity index 100%rename from kernel/0003-bpf-Read-security.bpf-xattrs-for-LSM-programs-without-the-caller-s-permission.patchrename to kernel/0002-bpf-Read-security.bpf-xattrs-for-LSM-programs-without-the-caller-s-permission.patchdiff --git a/kernel/0004-bpf-Let-sleepable-LSM-programs-attach-to-the-remaining-inode-hooks.patch b/kernel/0003-bpf-Let-sleepable-LSM-programs-attach-to-the-remaining-inode-hooks.patchsimilarity index 100%rename from kernel/0004-bpf-Let-sleepable-LSM-programs-attach-to-the-remaining-inode-hooks.patchrename to kernel/0003-bpf-Let-sleepable-LSM-programs-attach-to-the-remaining-inode-hooks.patchdiff --git a/kernel/0005-bpf-Treat-dentry-d_parent-as-a-trusted-pointer.patch b/kernel/0004-bpf-Treat-dentry-d_parent-as-a-trusted-pointer.patchsimilarity index 100%rename from kernel/0005-bpf-Treat-dentry-d_parent-as-a-trusted-pointer.patchrename to kernel/0004-bpf-Treat-dentry-d_parent-as-a-trusted-pointer.patch