Daniel Borkmann says: ==================== pull-request: bpf 2024-06-14 We've added 8 non-merge commits during the last 2 day(s) which contain a total of 9 files changed, 92 insertions(+), 11 deletions(-). The main changes are: 1) Silence a syzkaller splat under CONFIG_DEBUG_NET=y in pskb_pull_reason() triggered via __bpf_try_make_writable(), from Florian Westphal. 2) Fix removal of kfuncs during linking phase which then throws a kernel build warning via resolve_btfids about unresolved symbols, from Tony Ambardar. 3) Fix a UML x86_64 compilation failure from BPF as pcpu_hot symbol is not available on User Mode Linux, from Maciej Żenczykowski. 4) Fix a register corruption in reg_set_min_max triggering an invariant violation in BPF verifier, from Daniel Borkmann. * tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf: bpf: Harden __bpf_kfunc tag against linker kfunc removal compiler_types.h: Define __retain for __attribute__((__retain__)) bpf: Avoid splat in pskb_pull_reason bpf: fix UML x86_64 compile failure selftests/bpf: Add test coverage for reg_set_min_max handling bpf: Reduce stack consumption in check_stack_write_fixed_off bpf: Fix reg_set_min_max corruption of fake_reg MAINTAINERS: mailmap: Update Stanislav's email address ====================
Showing the changes to include/linux (3 of 9 files). Show all
Unified · Split
| @@ -746,6 +746,8 @@ struct bpf_verifier_env { · 745 unmodified lines | |||
| 746 | /* Same as scratched_regs but for stack slots */ | 746 | /* Same as scratched_regs but for stack slots */ |
| 747 | u64 scratched_stack_slots; | 747 | u64 scratched_stack_slots; |
| 748 | u64 prev_log_pos, prev_insn_print_pos; | 748 | u64 prev_log_pos, prev_insn_print_pos; |
| 749 | /* buffer used to temporary hold constants as scalar registers */ | ||
| 750 | struct bpf_reg_state fake_reg[2]; | ||
| 749 | /* buffer used to generate temporary string representations, | 751 | /* buffer used to generate temporary string representations, |
| 750 | * e.g., in reg_type_str() to generate reg_type string | 752 | * e.g., in reg_type_str() to generate reg_type string |
| 751 | */ | 753 | */ |
| @@ -82,7 +82,7 @@ · 81 unmodified lines | |||
| 82 | * as to avoid issues such as the compiler inlining or eliding either a static | 82 | * as to avoid issues such as the compiler inlining or eliding either a static |
| 83 | * kfunc, or a global kfunc in an LTO build. | 83 | * kfunc, or a global kfunc in an LTO build. |
| 84 | */ | 84 | */ |
| 85 | #define __bpf_kfunc __used noinline | 85 | #define __bpf_kfunc __used __retain noinline |
| 86 | 86 | ||
| 87 | #define __bpf_kfunc_start_defs() \ | 87 | #define __bpf_kfunc_start_defs() \ |
| 88 | __diag_push(); \ | 88 | __diag_push(); \ |
| @@ -143,6 +143,29 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { } · 142 unmodified lines | |||
| 143 | # define __preserve_most | 143 | # define __preserve_most |
| 144 | #endif | 144 | #endif |
| 145 | 145 | ||
| 146 | /* | ||
| 147 | * Annotating a function/variable with __retain tells the compiler to place | ||
| 148 | * the object in its own section and set the flag SHF_GNU_RETAIN. This flag | ||
| 149 | * instructs the linker to retain the object during garbage-cleanup or LTO | ||
| 150 | * phases. | ||
| 151 | * | ||
| 152 | * Note that the __used macro is also used to prevent functions or data | ||
| 153 | * being optimized out, but operates at the compiler/IR-level and may still | ||
| 154 | * allow unintended removal of objects during linking. | ||
| 155 | * | ||
| 156 | * Optional: only supported since gcc >= 11, clang >= 13 | ||
| 157 | * | ||
| 158 | * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-retain-function-attribute | ||
| 159 | * clang: https://clang.llvm.org/docs/AttributeReference.html#retain | ||
| 160 | */ | ||
| 161 | #if __has_attribute(__retain__) && \ | ||
| 162 | (defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || \ | ||
| 163 | defined(CONFIG_LTO_CLANG)) | ||
| 164 | # define __retain __attribute__((__retain__)) | ||
| 165 | #else | ||
| 166 | # define __retain | ||
| 167 | #endif | ||
| 168 | |||
| 146 | /* Compiler specific macros. */ | 169 | /* Compiler specific macros. */ |
| 147 | #ifdef __clang__ | 170 | #ifdef __clang__ |
| 148 | #include <linux/compiler-clang.h> | 171 | #include <linux/compiler-clang.h> |