History

Merge tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf

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 ====================

Jakub Kicinski committed 2 years ago

Commit c64da102 parents 1afe4a6 7bdcedd9 files · +92 −11Browse files

Showing the changes to include/linux (3 of 9 files). Show all

Unified · Split

3 files
  1. include/linux/bpf_verifier.h +2 −0
  2. include/linux/btf.h +1 −1
  3. include/linux/compiler_types.h +23 −0
include/linux/bpf_verifier.h+2−0
@@ -746,6 +746,8 @@ struct bpf_verifier_env { · 745 unmodified lines
746746 /* Same as scratched_regs but for stack slots */
747747 u64 scratched_stack_slots;
748748 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];
749751 /* buffer used to generate temporary string representations,
750752 * e.g., in reg_type_str() to generate reg_type string
751753 */
include/linux/btf.h+1−1
@@ -82,7 +82,7 @@ · 81 unmodified lines
8282 * as to avoid issues such as the compiler inlining or eliding either a static
8383 * kfunc, or a global kfunc in an LTO build.
8484 */
85−#define __bpf_kfunc __used noinline
85+#define __bpf_kfunc __used __retain noinline
8686
8787 #define __bpf_kfunc_start_defs() \
8888 __diag_push(); \
include/linux/compiler_types.h+23−0
@@ -143,6 +143,29 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { } · 142 unmodified lines
143143 # define __preserve_most
144144 #endif
145145
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+
146169 /* Compiler specific macros. */
147170 #ifdef __clang__
148171 #include <linux/compiler-clang.h>

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t