Commit 31674900 authored by Jakub Kicinski's avatar Jakub Kicinski

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

Daniel Borkmann says:

====================
pull-request: bpf 2021-08-19

We've added 3 non-merge commits during the last 3 day(s) which contain
a total of 3 files changed, 29 insertions(+), 6 deletions(-).

The main changes are:

1) Fix to clear zext_dst for dead instructions which was causing invalid program
   rejections on JITs with bpf_jit_needs_zext such as s390x, from Ilya Leoshkevich.

2) Fix RCU splat in bpf_get_current_{ancestor_,}cgroup_id() helpers when they are
   invoked from sleepable programs, from Yonghong Song.

* https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf:
  selftests, bpf: Test that dead ldx_w insns are accepted
  bpf: Clear zext_dst of dead insns
  bpf: Add rcu_read_lock in bpf_get_current_[ancestor_]cgroup_id() helpers
====================

Link: https://lore.kernel.org/r/20210819144904.20069-1-daniel@iogearbox.netSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents c15128c9 3776f351
...@@ -353,9 +353,15 @@ const struct bpf_func_proto bpf_jiffies64_proto = { ...@@ -353,9 +353,15 @@ const struct bpf_func_proto bpf_jiffies64_proto = {
#ifdef CONFIG_CGROUPS #ifdef CONFIG_CGROUPS
BPF_CALL_0(bpf_get_current_cgroup_id) BPF_CALL_0(bpf_get_current_cgroup_id)
{ {
struct cgroup *cgrp = task_dfl_cgroup(current); struct cgroup *cgrp;
u64 cgrp_id;
return cgroup_id(cgrp); rcu_read_lock();
cgrp = task_dfl_cgroup(current);
cgrp_id = cgroup_id(cgrp);
rcu_read_unlock();
return cgrp_id;
} }
const struct bpf_func_proto bpf_get_current_cgroup_id_proto = { const struct bpf_func_proto bpf_get_current_cgroup_id_proto = {
...@@ -366,13 +372,17 @@ const struct bpf_func_proto bpf_get_current_cgroup_id_proto = { ...@@ -366,13 +372,17 @@ const struct bpf_func_proto bpf_get_current_cgroup_id_proto = {
BPF_CALL_1(bpf_get_current_ancestor_cgroup_id, int, ancestor_level) BPF_CALL_1(bpf_get_current_ancestor_cgroup_id, int, ancestor_level)
{ {
struct cgroup *cgrp = task_dfl_cgroup(current); struct cgroup *cgrp;
struct cgroup *ancestor; struct cgroup *ancestor;
u64 cgrp_id;
rcu_read_lock();
cgrp = task_dfl_cgroup(current);
ancestor = cgroup_ancestor(cgrp, ancestor_level); ancestor = cgroup_ancestor(cgrp, ancestor_level);
if (!ancestor) cgrp_id = ancestor ? cgroup_id(ancestor) : 0;
return 0; rcu_read_unlock();
return cgroup_id(ancestor);
return cgrp_id;
} }
const struct bpf_func_proto bpf_get_current_ancestor_cgroup_id_proto = { const struct bpf_func_proto bpf_get_current_ancestor_cgroup_id_proto = {
......
...@@ -11663,6 +11663,7 @@ static void sanitize_dead_code(struct bpf_verifier_env *env) ...@@ -11663,6 +11663,7 @@ static void sanitize_dead_code(struct bpf_verifier_env *env)
if (aux_data[i].seen) if (aux_data[i].seen)
continue; continue;
memcpy(insn + i, &trap, sizeof(trap)); memcpy(insn + i, &trap, sizeof(trap));
aux_data[i].zext_dst = false;
} }
} }
......
...@@ -159,3 +159,15 @@ ...@@ -159,3 +159,15 @@
.result = ACCEPT, .result = ACCEPT,
.retval = 2, .retval = 2,
}, },
{
"dead code: zero extension",
.insns = {
BPF_MOV64_IMM(BPF_REG_0, 0),
BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4),
BPF_JMP_IMM(BPF_JGE, BPF_REG_0, 0, 1),
BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_10, -4),
BPF_EXIT_INSN(),
},
.result = ACCEPT,
.retval = 0,
},
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment