Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60b58afc authored by Alexei Starovoitov's avatar Alexei Starovoitov Committed by Daniel Borkmann
Browse files

bpf: fix net.core.bpf_jit_enable race



global bpf_jit_enable variable is tested multiple times in JITs,
blinding and verifier core. The malicious root can try to toggle
it while loading the programs. This race condition was accounted
for and there should be no issues, but it's safer to avoid
this race condition.

Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 1ea47e01
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1824,7 +1824,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
	/* If BPF JIT was not enabled then we must fall back to
	 * the interpreter.
	 */
	if (!bpf_jit_enable)
	if (!prog->jit_requested)
		return orig_prog;

	/* If constant blinding was enabled and we failed during blinding
+1 −1
Original line number Diff line number Diff line
@@ -844,7 +844,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
	int image_size;
	u8 *image_ptr;

	if (!bpf_jit_enable)
	if (!prog->jit_requested)
		return orig_prog;

	tmp = bpf_jit_blind_constants(prog);
+1 −1
Original line number Diff line number Diff line
@@ -1869,7 +1869,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
	unsigned int image_size;
	u8 *image_ptr;

	if (!bpf_jit_enable || !cpu_has_mips64r2)
	if (!prog->jit_requested || !cpu_has_mips64r2)
		return prog;

	tmp = bpf_jit_blind_constants(prog);
+1 −1
Original line number Diff line number Diff line
@@ -993,7 +993,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
	struct bpf_prog *tmp_fp;
	bool bpf_blinded = false;

	if (!bpf_jit_enable)
	if (!fp->jit_requested)
		return org_fp;

	tmp_fp = bpf_jit_blind_constants(org_fp);
+1 −1
Original line number Diff line number Diff line
@@ -1300,7 +1300,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
	struct bpf_jit jit;
	int pass;

	if (!bpf_jit_enable)
	if (!fp->jit_requested)
		return orig_fp;

	tmp = bpf_jit_blind_constants(fp);
Loading