1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-06 13:17:44 +03:00

bpf: fix off-by-one in class whitelisting

We would jump one insn too many, landing in the middle of the subsequent block.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-11-10 13:32:36 +01:00
parent 415fe5ec7d
commit a72a5326a4

View File

@ -108,7 +108,7 @@ static int bpf_prog_whitelist_class(BPFProgram *prog, int type, const char *acc)
return -EINVAL;
const struct bpf_insn insn[] = {
BPF_JMP_IMM(BPF_JNE, BPF_REG_2, type, 5), /* compare device type */
BPF_JMP_IMM(BPF_JNE, BPF_REG_2, type, 4), /* compare device type */
BPF_MOV32_REG(BPF_REG_1, BPF_REG_3), /* calculate access type */
BPF_ALU32_IMM(BPF_AND, BPF_REG_1, access),
BPF_JMP_REG(BPF_JNE, BPF_REG_1, BPF_REG_3, 1), /* compare access type */