提交 9cda2178 编写于 作者: J Jiong Wang 提交者: Yu Changchun

tools: bpftool: teach cfg code about JMP32

mainline inclusion
from mainline-v5.1-rc1
commit df791dc167603efb676447a2d7b769a19e8fd722
category: bugfix
bugzilla: NA
CVE: CVE-2021-3444

--------------------------------

The cfg code need to be aware of the new JMP32 instruction class so it
could partition functions correctly.
Reviewed-by: NJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: NJiong Wang <jiong.wang@netronome.com>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
Signed-off-by: He Fengqing<hefengqing@huawei.com>
Reviewed-by: NKuohai Xu <xukuohai@huawei.com>
Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NYu Changchun <yuchangchun1@huawei.com>
上级 2ab810cf
...@@ -191,6 +191,11 @@ static bool cfg_partition_funcs(struct cfg *cfg, struct bpf_insn *cur, ...@@ -191,6 +191,11 @@ static bool cfg_partition_funcs(struct cfg *cfg, struct bpf_insn *cur,
return false; return false;
} }
static bool is_jmp_insn(u8 code)
{
return BPF_CLASS(code) == BPF_JMP || BPF_CLASS(code) == BPF_JMP32;
}
static bool func_partition_bb_head(struct func_node *func) static bool func_partition_bb_head(struct func_node *func)
{ {
struct bpf_insn *cur, *end; struct bpf_insn *cur, *end;
...@@ -204,7 +209,7 @@ static bool func_partition_bb_head(struct func_node *func) ...@@ -204,7 +209,7 @@ static bool func_partition_bb_head(struct func_node *func)
return true; return true;
for (; cur <= end; cur++) { for (; cur <= end; cur++) {
if (BPF_CLASS(cur->code) == BPF_JMP) { if (is_jmp_insn(cur->code)) {
u8 opcode = BPF_OP(cur->code); u8 opcode = BPF_OP(cur->code);
if (opcode == BPF_EXIT || opcode == BPF_CALL) if (opcode == BPF_EXIT || opcode == BPF_CALL)
...@@ -330,7 +335,7 @@ static bool func_add_bb_edges(struct func_node *func) ...@@ -330,7 +335,7 @@ static bool func_add_bb_edges(struct func_node *func)
e->src = bb; e->src = bb;
insn = bb->tail; insn = bb->tail;
if (BPF_CLASS(insn->code) != BPF_JMP || if (!is_jmp_insn(insn->code) ||
BPF_OP(insn->code) == BPF_EXIT) { BPF_OP(insn->code) == BPF_EXIT) {
e->dst = bb_next(bb); e->dst = bb_next(bb);
e->flags |= EDGE_FLAG_FALLTHROUGH; e->flags |= EDGE_FLAG_FALLTHROUGH;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册