Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf

Pull bpf fixes from Alexei Starovoitov:

- Add namespace to BPF internal symbols (Alexei Starovoitov)

- Fix possible endless loop in BPF map iteration (Brandon Kammerdiener)

- Fix compilation failure for samples/bpf on LoongArch (Haoran Jiang)

- Disable a part of sockmap_ktls test (Ihor Solodrai)

- Correct typo in __clang_major__ macro (Peilin Ye)

* tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf:
selftests/bpf: Correct typo in __clang_major__ macro
samples/bpf: Fix compilation failure for samples/bpf on LoongArch Fedora
bpf: Add namespace to BPF internal symbols
selftests/bpf: add test for softlock when modifying hashmap while iterating
bpf: fix possible endless loop in BPF map iteration
selftests/bpf: Mitigate sockmap_ktls disconnect_after_delete failure

+82 -7
+8
Documentation/bpf/bpf_devel_QA.rst
··· 382 382 into the Linux kernel, please implement support into LLVM's BPF back 383 383 end. See LLVM_ section below for further information. 384 384 385 + Q: What "BPF_INTERNAL" symbol namespace is for? 386 + ----------------------------------------------- 387 + A: Symbols exported as BPF_INTERNAL can only be used by BPF infrastructure 388 + like preload kernel modules with light skeleton. Most symbols outside 389 + of BPF_INTERNAL are not expected to be used by code outside of BPF either. 390 + Symbols may lack the designation because they predate the namespaces, 391 + or due to an oversight. 392 + 385 393 Stable submission 386 394 ================= 387 395
+1 -1
kernel/bpf/hashtab.c
··· 2189 2189 b = &htab->buckets[i]; 2190 2190 rcu_read_lock(); 2191 2191 head = &b->head; 2192 - hlist_nulls_for_each_entry_rcu(elem, n, head, hash_node) { 2192 + hlist_nulls_for_each_entry_safe(elem, n, head, hash_node) { 2193 2193 key = elem->key; 2194 2194 if (is_percpu) { 2195 2195 /* current cpu value for percpu map */
+1
kernel/bpf/preload/bpf_preload_kern.c
··· 89 89 } 90 90 late_initcall(load); 91 91 module_exit(fini); 92 + MODULE_IMPORT_NS("BPF_INTERNAL"); 92 93 MODULE_LICENSE("GPL"); 93 94 MODULE_DESCRIPTION("Embedded BPF programs for introspection in bpffs");
+3 -3
kernel/bpf/syscall.c
··· 1583 1583 1584 1584 return map; 1585 1585 } 1586 - EXPORT_SYMBOL(bpf_map_get); 1586 + EXPORT_SYMBOL_NS(bpf_map_get, "BPF_INTERNAL"); 1587 1587 1588 1588 struct bpf_map *bpf_map_get_with_uref(u32 ufd) 1589 1589 { ··· 3364 3364 bpf_link_inc(link); 3365 3365 return link; 3366 3366 } 3367 - EXPORT_SYMBOL(bpf_link_get_from_fd); 3367 + EXPORT_SYMBOL_NS(bpf_link_get_from_fd, "BPF_INTERNAL"); 3368 3368 3369 3369 static void bpf_tracing_link_release(struct bpf_link *link) 3370 3370 { ··· 6020 6020 return ____bpf_sys_bpf(cmd, attr, size); 6021 6021 } 6022 6022 } 6023 - EXPORT_SYMBOL(kern_sys_bpf); 6023 + EXPORT_SYMBOL_NS(kern_sys_bpf, "BPF_INTERNAL"); 6024 6024 6025 6025 static const struct bpf_func_proto bpf_sys_bpf_proto = { 6026 6026 .func = bpf_sys_bpf,
+1 -1
samples/bpf/Makefile
··· 376 376 @echo " CLANG-bpf " $@ 377 377 $(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(BPF_EXTRA_CFLAGS) \ 378 378 -I$(obj) -I$(srctree)/tools/testing/selftests/bpf/ \ 379 - -I$(LIBBPF_INCLUDE) \ 379 + -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES) \ 380 380 -D__KERNEL__ -D__BPF_TRACING__ -Wno-unused-value -Wno-pointer-sign \ 381 381 -D__TARGET_ARCH_$(SRCARCH) -Wno-compare-distinct-pointer-types \ 382 382 -Wno-gnu-variable-sized-type-not-at-end \
+37
tools/testing/selftests/bpf/prog_tests/for_each.c
··· 6 6 #include "for_each_array_map_elem.skel.h" 7 7 #include "for_each_map_elem_write_key.skel.h" 8 8 #include "for_each_multi_maps.skel.h" 9 + #include "for_each_hash_modify.skel.h" 9 10 10 11 static unsigned int duration; 11 12 ··· 204 203 for_each_multi_maps__destroy(skel); 205 204 } 206 205 206 + static void test_hash_modify(void) 207 + { 208 + struct for_each_hash_modify *skel; 209 + int max_entries, i, err; 210 + __u64 key, val; 211 + 212 + LIBBPF_OPTS(bpf_test_run_opts, topts, 213 + .data_in = &pkt_v4, 214 + .data_size_in = sizeof(pkt_v4), 215 + .repeat = 1 216 + ); 217 + 218 + skel = for_each_hash_modify__open_and_load(); 219 + if (!ASSERT_OK_PTR(skel, "for_each_hash_modify__open_and_load")) 220 + return; 221 + 222 + max_entries = bpf_map__max_entries(skel->maps.hashmap); 223 + for (i = 0; i < max_entries; i++) { 224 + key = i; 225 + val = i; 226 + err = bpf_map__update_elem(skel->maps.hashmap, &key, sizeof(key), 227 + &val, sizeof(val), BPF_ANY); 228 + if (!ASSERT_OK(err, "map_update")) 229 + goto out; 230 + } 231 + 232 + err = bpf_prog_test_run_opts(bpf_program__fd(skel->progs.test_pkt_access), &topts); 233 + ASSERT_OK(err, "bpf_prog_test_run_opts"); 234 + ASSERT_OK(topts.retval, "retval"); 235 + 236 + out: 237 + for_each_hash_modify__destroy(skel); 238 + } 239 + 207 240 void test_for_each(void) 208 241 { 209 242 if (test__start_subtest("hash_map")) ··· 248 213 test_write_map_key(); 249 214 if (test__start_subtest("multi_maps")) 250 215 test_multi_maps(); 216 + if (test__start_subtest("hash_modify")) 217 + test_hash_modify(); 251 218 }
-1
tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c
··· 68 68 goto close_cli; 69 69 70 70 err = disconnect(cli); 71 - ASSERT_OK(err, "disconnect"); 72 71 73 72 close_cli: 74 73 close(cli);
+1 -1
tools/testing/selftests/bpf/progs/bpf_misc.h
··· 221 221 #define CAN_USE_GOTOL 222 222 #endif 223 223 224 - #if _clang_major__ >= 18 224 + #if __clang_major__ >= 18 225 225 #define CAN_USE_BPF_ST 226 226 #endif 227 227
+30
tools/testing/selftests/bpf/progs/for_each_hash_modify.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* Copyright (c) 2025 Intel Corporation */ 3 + #include "vmlinux.h" 4 + #include <bpf/bpf_helpers.h> 5 + 6 + char _license[] SEC("license") = "GPL"; 7 + 8 + struct { 9 + __uint(type, BPF_MAP_TYPE_HASH); 10 + __uint(max_entries, 128); 11 + __type(key, __u64); 12 + __type(value, __u64); 13 + } hashmap SEC(".maps"); 14 + 15 + static int cb(struct bpf_map *map, __u64 *key, __u64 *val, void *arg) 16 + { 17 + bpf_map_delete_elem(map, key); 18 + bpf_map_update_elem(map, key, val, 0); 19 + return 0; 20 + } 21 + 22 + SEC("tc") 23 + int test_pkt_access(struct __sk_buff *skb) 24 + { 25 + (void)skb; 26 + 27 + bpf_for_each_map_elem(&hashmap, cb, NULL, 0); 28 + 29 + return 0; 30 + }