[PATCH v2 3/4] bpf: Add warning when program uses deprecated bpf_probe_read

From: Joel Fernandes (Google)
Date: Mon May 06 2019 - 14:32:19 EST


bpf_probe_read is deprecated and ambiguous. Add a warning if programs
still use it, so that they may be moved to not use it. After sufficient
time, the warning can be removed.

Signed-off-by: Joel Fernandes (Google) <joel@xxxxxxxxxxxxxxxxx>
---
kernel/bpf/verifier.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 09d5d972c9ff..f8cc77e85b48 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -7656,6 +7656,10 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env)
if (insn->src_reg == BPF_PSEUDO_CALL)
continue;

+ if (insn->imm == BPF_FUNC_probe_read)
+ pr_warn_once("bpf_probe_read is deprecated, please use "
+ "bpf_probe_read_{kernel,user} in eBPF programs.\n");
+
if (insn->imm == BPF_FUNC_get_route_realm)
prog->dst_needed = 1;
if (insn->imm == BPF_FUNC_get_prandom_u32)
--
2.21.0.1020.gf2820cf01a-goog