History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf

Daniel borkmann says: ==================== The following pull-request contains BPF updates for your *net* tree. We've added 11 non-merge commits during the last 14 day(s) which contain a total of 13 files changed, 61 insertions(+), 24 deletions(-). The main changes are: 1) Fix BPF verifier's precision tracking around BPF ring buffer, from Kumar Kartikeya Dwivedi. 2) Fix regression in tunnel key infra when passing FLOWI_FLAG_ANYSRC, from Eyal Birger. 3) Fix insufficient permissions for bpf_sys_bpf() helper, from YiFei Zhu. 4) Fix splat from hitting BUG when purging effective cgroup programs, from Pu Lehui. 5) Fix range tracking for array poke descriptors, from Daniel Borkmann. 6) Fix corrupted packets for XDP_SHARED_UMEM in aligned mode, from Magnus Karlsson. 7) Fix NULL pointer splat in BPF sockmap sk_msg_recvmsg(), from Liu Jian. 8) Add READ_ONCE() to bpf_jit_limit when reading from sysctl, from Kuniyuki Iwashima. 9) Add BPF selftest lru_bug check to s390x deny list, from Daniel Müller. ====================

David S. Miller committed 4 years ago

Commit 2e085ec2 parents 4ba9d38 a65718213 files · +61 −24Browse files

Showing the changes to kernel (4 of 13 files). Show all

Unified · Split

4 files
  1. kernel/bpf/cgroup.c +3 −1
  2. kernel/bpf/core.c +1 −1
  3. kernel/bpf/syscall.c +1 −1
  4. kernel/bpf/verifier.c +7 −6
kernel/bpf/cgroup.c+3−1
@@ -921,8 +921,10 @@ static void purge_effective_progs(struct cgroup *cgrp, struct bpf_prog *prog, · 920 unmodified lines
921921 pos++;
922922 }
923923 }
924+
925+ /* no link or prog match, skip the cgroup of this layer */
926+ continue;
924927 found:
925− BUG_ON(!cg);
926928 progs = rcu_dereference_protected(
927929 desc->bpf.effective[atype],
928930 lockdep_is_held(&cgroup_mutex));
kernel/bpf/core.c+1−1
@@ -971,7 +971,7 @@ pure_initcall(bpf_jit_charge_init); · 970 unmodified lines
971971
972972 int bpf_jit_charge_modmem(u32 size)
973973 {
974− if (atomic_long_add_return(size, &bpf_jit_current) > bpf_jit_limit) {
974+ if (atomic_long_add_return(size, &bpf_jit_current) > READ_ONCE(bpf_jit_limit)) {
975975 if (!bpf_capable()) {
976976 atomic_long_sub(size, &bpf_jit_current);
977977 return -EPERM;
kernel/bpf/syscall.c+1−1
@@ -5197,7 +5197,7 @@ syscall_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) · 5196 unmodified lines
51975197 {
51985198 switch (func_id) {
51995199 case BPF_FUNC_sys_bpf:
5200− return &bpf_sys_bpf_proto;
5200+ return !perfmon_capable() ? NULL : &bpf_sys_bpf_proto;
52015201 case BPF_FUNC_btf_find_by_name_kind:
52025202 return &bpf_btf_find_by_name_kind_proto;
52035203 case BPF_FUNC_sys_close:
kernel/bpf/verifier.c+7−6
@@ -6066,6 +6066,9 @@ skip_type_check: · 6065 unmodified lines
60666066 return -EACCES;
60676067 }
60686068 meta->mem_size = reg->var_off.value;
6069+ err = mark_chain_precision(env, regno);
6070+ if (err)
6071+ return err;
60696072 break;
60706073 case ARG_PTR_TO_INT:
60716074 case ARG_PTR_TO_LONG:
@@ -7030,8 +7033,7 @@ record_func_key(struct bpf_verifier_env *env, struct bpf_call_arg_meta *meta, · 958 unmodified lines
70307033 struct bpf_insn_aux_data *aux = &env->insn_aux_data[insn_idx];
70317034 struct bpf_reg_state *regs = cur_regs(env), *reg;
70327035 struct bpf_map *map = meta->map_ptr;
7033− struct tnum range;
7034− u64 val;
7036+ u64 val, max;
70357037 int err;
70367038
70377039 if (func_id != BPF_FUNC_tail_call)
@@ -7041,10 +7043,11 @@ record_func_key(struct bpf_verifier_env *env, struct bpf_call_arg_meta *meta, · 3 unmodified lines
70417043 return -EINVAL;
70427044 }
70437045
7044− range = tnum_range(0, map->max_entries - 1);
70457046 reg = &regs[BPF_REG_3];
7047+ val = reg->var_off.value;
7048+ max = map->max_entries;
70467049
7047− if (!register_is_const(reg) || !tnum_in(range, reg->var_off)) {
7050+ if (!(register_is_const(reg) && val < max)) {
70487051 bpf_map_key_store(aux, BPF_MAP_KEY_POISON);
70497052 return 0;
70507053 }
@@ -7052,8 +7055,6 @@ record_func_key(struct bpf_verifier_env *env, struct bpf_call_arg_meta *meta, · 1 unmodified line
70527055 err = mark_chain_precision(env, BPF_REG_3);
70537056 if (err)
70547057 return err;
7055−
7056− val = reg->var_off.value;
70577058 if (bpf_map_key_unseen(aux))
70587059 bpf_map_key_store(aux, val);
70597060 else if (!bpf_map_key_poisoned(aux) &&