Skip to content

Commit 52d94c1

Browse files
committed
Daniel Borkmann says: ==================== pull-request: bpf 2024-05-17 We've added 7 non-merge commits during the last 2 day(s) which contain a total of 8 files changed, 20 insertions(+), 9 deletions(-). The main changes are: 1) Fix KASAN slab-out-of-bounds in percpu_array_map_gen_lookup and add BPF selftests to cover this case, from Andrii Nakryiko. (Report https://lore.kernel.org/bpf/[email protected]/) 2) Fix two BPF selftests to adjust for kernel changes after fast-forwarding Linus' tree to make BPF CI all green again, from Martin KaFai Lau. 3) Fix libbpf feature detectors when using token_fd by adjusting the attribute size for memset to cover the former, also from Andrii Nakryiko. 4) Fix the description of 'src' in ALU instructions for the BPF ISA standardization doc, from Puranjay Mohan. * tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf: selftests/bpf: Adjust btf_dump test to reflect recent change in file_operations selftests/bpf: Adjust test_access_variable_array after a kernel function name change selftests/bpf: add more variations of map-in-map situations bpf: save extended inner map info for percpu array maps as well MAINTAINERS: Update ARM64 BPF JIT maintainer bpf, docs: Fix the description of 'src' in ALU instructions libbpf: fix feature detectors when using token_fd ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 83e9394 + 51e2b8d commit 52d94c1

File tree

8 files changed

+20
-9
lines changed

8 files changed

+20
-9
lines changed

Documentation/bpf/standardization/instruction-set.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,9 @@ Arithmetic instructions
301301
``ALU`` uses 32-bit wide operands while ``ALU64`` uses 64-bit wide operands for
302302
otherwise identical operations. ``ALU64`` instructions belong to the
303303
base64 conformance group unless noted otherwise.
304-
The 'code' field encodes the operation as below, where 'src' and 'dst' refer
305-
to the values of the source and destination registers, respectively.
304+
The 'code' field encodes the operation as below, where 'src' refers to the
305+
the source operand and 'dst' refers to the value of the destination
306+
register.
306307

307308
===== ===== ======= ==========================================================
308309
name code offset description

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3777,7 +3777,7 @@ F: arch/arm/net/
37773777
BPF JIT for ARM64
37783778
M: Daniel Borkmann <[email protected]>
37793779
M: Alexei Starovoitov <[email protected]>
3780-
M: Zi Shen Lim <[email protected]>
3780+
M: Puranjay Mohan <[email protected]>
37813781
37823782
S: Supported
37833783
F: arch/arm64/net/

kernel/bpf/map_in_map.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct bpf_map *bpf_map_meta_alloc(int inner_map_ufd)
3232

3333
inner_map_meta_size = sizeof(*inner_map_meta);
3434
/* In some cases verifier needs to access beyond just base map. */
35-
if (inner_map->ops == &array_map_ops)
35+
if (inner_map->ops == &array_map_ops || inner_map->ops == &percpu_array_map_ops)
3636
inner_map_meta_size = sizeof(struct bpf_array);
3737

3838
inner_map_meta = kzalloc(inner_map_meta_size, GFP_USER);
@@ -68,7 +68,7 @@ struct bpf_map *bpf_map_meta_alloc(int inner_map_ufd)
6868

6969
/* Misc members not needed in bpf_map_meta_equal() check. */
7070
inner_map_meta->ops = inner_map->ops;
71-
if (inner_map->ops == &array_map_ops) {
71+
if (inner_map->ops == &array_map_ops || inner_map->ops == &percpu_array_map_ops) {
7272
struct bpf_array *inner_array_meta =
7373
container_of(inner_map_meta, struct bpf_array, map);
7474
struct bpf_array *inner_array = container_of(inner_map, struct bpf_array, map);

tools/lib/bpf/bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ int sys_bpf_prog_load(union bpf_attr *attr, unsigned int size, int attempts)
105105
*/
106106
int probe_memcg_account(int token_fd)
107107
{
108-
const size_t attr_sz = offsetofend(union bpf_attr, attach_btf_obj_fd);
108+
const size_t attr_sz = offsetofend(union bpf_attr, prog_token_fd);
109109
struct bpf_insn insns[] = {
110110
BPF_EMIT_CALL(BPF_FUNC_ktime_get_coarse_ns),
111111
BPF_EXIT_INSN(),

tools/lib/bpf/features.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int probe_fd(int fd)
2222

2323
static int probe_kern_prog_name(int token_fd)
2424
{
25-
const size_t attr_sz = offsetofend(union bpf_attr, prog_name);
25+
const size_t attr_sz = offsetofend(union bpf_attr, prog_token_fd);
2626
struct bpf_insn insns[] = {
2727
BPF_MOV64_IMM(BPF_REG_0, 0),
2828
BPF_EXIT_INSN(),

tools/testing/selftests/bpf/prog_tests/btf_dump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ static void test_btf_dump_struct_data(struct btf *btf, struct btf_dump *d,
653653
cmpstr =
654654
"(struct file_operations){\n"
655655
" .owner = (struct module *)0xffffffffffffffff,\n"
656-
" .llseek = (loff_t (*)(struct file *, loff_t, int))0xffffffffffffffff,";
656+
" .fop_flags = (fop_flags_t)4294967295,";
657657

658658
ASSERT_STRNEQ(str, cmpstr, strlen(cmpstr), "file_operations");
659659
}

tools/testing/selftests/bpf/progs/map_kptr.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,14 @@ DEFINE_MAP_OF_MAP(BPF_MAP_TYPE_ARRAY_OF_MAPS, array_map, array_of_array_maps);
110110
DEFINE_MAP_OF_MAP(BPF_MAP_TYPE_ARRAY_OF_MAPS, hash_map, array_of_hash_maps);
111111
DEFINE_MAP_OF_MAP(BPF_MAP_TYPE_ARRAY_OF_MAPS, hash_malloc_map, array_of_hash_malloc_maps);
112112
DEFINE_MAP_OF_MAP(BPF_MAP_TYPE_ARRAY_OF_MAPS, lru_hash_map, array_of_lru_hash_maps);
113+
DEFINE_MAP_OF_MAP(BPF_MAP_TYPE_ARRAY_OF_MAPS, pcpu_array_map, array_of_pcpu_array_maps);
114+
DEFINE_MAP_OF_MAP(BPF_MAP_TYPE_ARRAY_OF_MAPS, pcpu_hash_map, array_of_pcpu_hash_maps);
113115
DEFINE_MAP_OF_MAP(BPF_MAP_TYPE_HASH_OF_MAPS, array_map, hash_of_array_maps);
114116
DEFINE_MAP_OF_MAP(BPF_MAP_TYPE_HASH_OF_MAPS, hash_map, hash_of_hash_maps);
115117
DEFINE_MAP_OF_MAP(BPF_MAP_TYPE_HASH_OF_MAPS, hash_malloc_map, hash_of_hash_malloc_maps);
116118
DEFINE_MAP_OF_MAP(BPF_MAP_TYPE_HASH_OF_MAPS, lru_hash_map, hash_of_lru_hash_maps);
119+
DEFINE_MAP_OF_MAP(BPF_MAP_TYPE_HASH_OF_MAPS, pcpu_array_map, hash_of_pcpu_array_maps);
120+
DEFINE_MAP_OF_MAP(BPF_MAP_TYPE_HASH_OF_MAPS, pcpu_hash_map, hash_of_pcpu_hash_maps);
117121

118122
#define WRITE_ONCE(x, val) ((*(volatile typeof(x) *) &(x)) = (val))
119123

@@ -204,6 +208,8 @@ int test_map_kptr(struct __sk_buff *ctx)
204208
TEST(hash_map);
205209
TEST(hash_malloc_map);
206210
TEST(lru_hash_map);
211+
TEST(pcpu_array_map);
212+
TEST(pcpu_hash_map);
207213

208214
#undef TEST
209215
return 0;
@@ -281,10 +287,14 @@ int test_map_in_map_kptr(struct __sk_buff *ctx)
281287
TEST(array_of_hash_maps);
282288
TEST(array_of_hash_malloc_maps);
283289
TEST(array_of_lru_hash_maps);
290+
TEST(array_of_pcpu_array_maps);
291+
TEST(array_of_pcpu_hash_maps);
284292
TEST(hash_of_array_maps);
285293
TEST(hash_of_hash_maps);
286294
TEST(hash_of_hash_malloc_maps);
287295
TEST(hash_of_lru_hash_maps);
296+
TEST(hash_of_pcpu_array_maps);
297+
TEST(hash_of_pcpu_hash_maps);
288298

289299
#undef TEST
290300
return 0;

tools/testing/selftests/bpf/progs/test_access_variable_array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
unsigned long span = 0;
99

10-
SEC("fentry/load_balance")
10+
SEC("fentry/sched_balance_rq")
1111
int BPF_PROG(fentry_fentry, int this_cpu, struct rq *this_rq,
1212
struct sched_domain *sd)
1313
{

0 commit comments

Comments
 (0)