Skip to content

Commit 0127725

Browse files
Hou TaoAlexei Starovoitov
authored andcommitted
bpf: Add missed maybe_wait_bpf_programs() for htab of maps
When doing batched lookup and deletion operations on htab of maps, maybe_wait_bpf_programs() is needed to ensure all programs don't use the inner map after the bpf syscall returns. Instead of adding the wait in __htab_map_lookup_and_delete_batch(), adding the wait in bpf_map_do_batch() and also removing the calling of maybe_wait_bpf_programs() from generic_map_{delete,update}_batch(). Signed-off-by: Hou Tao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 37ba5b5 commit 0127725

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/bpf/syscall.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,6 @@ int generic_map_delete_batch(struct bpf_map *map,
17581758

17591759
kvfree(key);
17601760

1761-
maybe_wait_bpf_programs(map);
17621761
return err;
17631762
}
17641763

@@ -1817,7 +1816,6 @@ int generic_map_update_batch(struct bpf_map *map, struct file *map_file,
18171816
kvfree(value);
18181817
kvfree(key);
18191818

1820-
maybe_wait_bpf_programs(map);
18211819
return err;
18221820
}
18231821

@@ -5031,8 +5029,10 @@ static int bpf_map_do_batch(const union bpf_attr *attr,
50315029
else
50325030
BPF_DO_BATCH(map->ops->map_delete_batch, map, attr, uattr);
50335031
err_put:
5034-
if (has_write)
5032+
if (has_write) {
5033+
maybe_wait_bpf_programs(map);
50355034
bpf_map_write_active_dec(map);
5035+
}
50365036
fdput(f);
50375037
return err;
50385038
}

0 commit comments

Comments
 (0)