Alexei Starovoitov says: ==================== pull-request: bpf 2020-03-12 The following pull-request contains BPF updates for your *net* tree. We've added 12 non-merge commits during the last 8 day(s) which contain a total of 12 files changed, 161 insertions(+), 15 deletions(-). The main changes are: 1) Andrii fixed two bugs in cgroup-bpf. 2) John fixed sockmap. 3) Luke fixed x32 jit. 4) Martin fixed two issues in struct_ops. 5) Yonghong fixed bpf_send_signal. 6) Yoshiki fixed BTF enum. ====================
Showing the changes to kernel (5 of 12 files). Show all
Unified · Split
| @@ -482,13 +482,21 @@ static int bpf_struct_ops_map_delete_elem(struct bpf_map *map, void *key) · 481 unmodified lines | |||
| 482 | prev_state = cmpxchg(&st_map->kvalue.state, | 482 | prev_state = cmpxchg(&st_map->kvalue.state, |
| 483 | BPF_STRUCT_OPS_STATE_INUSE, | 483 | BPF_STRUCT_OPS_STATE_INUSE, |
| 484 | BPF_STRUCT_OPS_STATE_TOBEFREE); | 484 | BPF_STRUCT_OPS_STATE_TOBEFREE); |
| 485 | if (prev_state == BPF_STRUCT_OPS_STATE_INUSE) { | 485 | switch (prev_state) { |
| 486 | case BPF_STRUCT_OPS_STATE_INUSE: | ||
| 486 | st_map->st_ops->unreg(&st_map->kvalue.data); | 487 | st_map->st_ops->unreg(&st_map->kvalue.data); |
| 487 | if (refcount_dec_and_test(&st_map->kvalue.refcnt)) | 488 | if (refcount_dec_and_test(&st_map->kvalue.refcnt)) |
| 488 | bpf_map_put(map); | 489 | bpf_map_put(map); |
| 490 | return 0; | ||
| 491 | case BPF_STRUCT_OPS_STATE_TOBEFREE: | ||
| 492 | return -EINPROGRESS; | ||
| 493 | case BPF_STRUCT_OPS_STATE_INIT: | ||
| 494 | return -ENOENT; | ||
| 495 | default: | ||
| 496 | WARN_ON_ONCE(1); | ||
| 497 | /* Should never happen. Treat it as not found. */ | ||
| 498 | return -ENOENT; | ||
| 489 | } | 499 | } |
| 490 | |||
| 491 | return 0; | ||
| 492 | } | 500 | } |
| 493 | 501 | ||
| 494 | static void bpf_struct_ops_map_seq_show_elem(struct bpf_map *map, void *key, | 502 | static void bpf_struct_ops_map_seq_show_elem(struct bpf_map *map, void *key, |
| @@ -2418,7 +2418,7 @@ static int btf_enum_check_member(struct btf_verifier_env *env, · 2417 unmodified lines | |||
| 2418 | 2418 | ||
| 2419 | struct_size = struct_type->size; | 2419 | struct_size = struct_type->size; |
| 2420 | bytes_offset = BITS_ROUNDDOWN_BYTES(struct_bits_off); | 2420 | bytes_offset = BITS_ROUNDDOWN_BYTES(struct_bits_off); |
| 2421 | if (struct_size - bytes_offset < sizeof(int)) { | 2421 | if (struct_size - bytes_offset < member_type->size) { |
| 2422 | btf_verifier_log_member(env, struct_type, member, | 2422 | btf_verifier_log_member(env, struct_type, member, |
| 2423 | "Member exceeds struct_size"); | 2423 | "Member exceeds struct_size"); |
| 2424 | return -EINVAL; | 2424 | return -EINVAL; |
| @@ -227,6 +227,9 @@ cleanup: · 226 unmodified lines | |||
| 227 | for (i = 0; i < NR; i++) | 227 | for (i = 0; i < NR; i++) |
| 228 | bpf_prog_array_free(arrays[i]); | 228 | bpf_prog_array_free(arrays[i]); |
| 229 | 229 | ||
| 230 | for (p = cgroup_parent(cgrp); p; p = cgroup_parent(p)) | ||
| 231 | cgroup_bpf_put(p); | ||
| 232 | |||
| 230 | percpu_ref_exit(&cgrp->bpf.refcnt); | 233 | percpu_ref_exit(&cgrp->bpf.refcnt); |
| 231 | 234 | ||
| 232 | return -ENOMEM; | 235 | return -ENOMEM; |
| @@ -302,8 +305,8 @@ int __cgroup_bpf_attach(struct cgroup *cgrp, struct bpf_prog *prog, · 69 unmodified lines | |||
| 302 | u32 saved_flags = (flags & (BPF_F_ALLOW_OVERRIDE | BPF_F_ALLOW_MULTI)); | 305 | u32 saved_flags = (flags & (BPF_F_ALLOW_OVERRIDE | BPF_F_ALLOW_MULTI)); |
| 303 | struct list_head *progs = &cgrp->bpf.progs[type]; | 306 | struct list_head *progs = &cgrp->bpf.progs[type]; |
| 304 | struct bpf_prog *old_prog = NULL; | 307 | struct bpf_prog *old_prog = NULL; |
| 305 | struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE], | 308 | struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE] = {}; |
| 306 | *old_storage[MAX_BPF_CGROUP_STORAGE_TYPE] = {NULL}; | 309 | struct bpf_cgroup_storage *old_storage[MAX_BPF_CGROUP_STORAGE_TYPE] = {}; |
| 307 | struct bpf_prog_list *pl, *replace_pl = NULL; | 310 | struct bpf_prog_list *pl, *replace_pl = NULL; |
| 308 | enum bpf_cgroup_storage_type stype; | 311 | enum bpf_cgroup_storage_type stype; |
| 309 | int err; | 312 | int err; |
| @@ -1510,6 +1510,11 @@ static int map_freeze(const union bpf_attr *attr) · 1509 unmodified lines | |||
| 1510 | if (IS_ERR(map)) | 1510 | if (IS_ERR(map)) |
| 1511 | return PTR_ERR(map); | 1511 | return PTR_ERR(map); |
| 1512 | 1512 | ||
| 1513 | if (map->map_type == BPF_MAP_TYPE_STRUCT_OPS) { | ||
| 1514 | fdput(f); | ||
| 1515 | return -ENOTSUPP; | ||
| 1516 | } | ||
| 1517 | |||
| 1513 | mutex_lock(&map->freeze_mutex); | 1518 | mutex_lock(&map->freeze_mutex); |
| 1514 | 1519 | ||
| 1515 | if (map->writecnt) { | 1520 | if (map->writecnt) { |
| @@ -732,7 +732,7 @@ static int bpf_send_signal_common(u32 sig, enum pid_type type) · 731 unmodified lines | |||
| 732 | if (unlikely(!nmi_uaccess_okay())) | 732 | if (unlikely(!nmi_uaccess_okay())) |
| 733 | return -EPERM; | 733 | return -EPERM; |
| 734 | 734 | ||
| 735 | if (in_nmi()) { | 735 | if (irqs_disabled()) { |
| 736 | /* Do an early check on signal validity. Otherwise, | 736 | /* Do an early check on signal validity. Otherwise, |
| 737 | * the error is lost in deferred irq_work. | 737 | * the error is lost in deferred irq_work. |
| 738 | */ | 738 | */ |