diff options
| author | David S. Miller <davem@davemloft.net> | 2017-11-14 16:20:04 +0900 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2017-11-14 16:20:04 +0900 |
| commit | 0a87bc2e58a687fe14817b9c7f73e68570ba33c6 (patch) | |
| tree | 9fb5554961eecb8be5a8de7b84675fc6708afb32 /kernel/trace/bpf_trace.c | |
| parent | 3a9b76fd0db9f0d426533f96a68a62a58753a51e (diff) | |
| parent | b6ff63911232c2823e2763371ec4462ac64cc331 (diff) | |
Merge branch 'bpf-improve-verifier-ARG_CONST_SIZE_OR_ZERO-semantics'
Yonghong Song says:
====================
bpf: improve verifier ARG_CONST_SIZE_OR_ZERO semantics
This patch set intends to change verifier ARG_CONST_SIZE_OR_ZERO
semantics so that simpler bpf programs can be written with verifier
acceptance. Patch #1 comment provided the detailed examples and
the patch itself implements the new semantics. Patch #2
changes bpf_probe_read helper arg2 type from
ARG_CONST_SIZE to ARG_CONST_SIZE_OR_ZERO. Patch #3 fixed a few
test cases and added some for better coverage.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel/trace/bpf_trace.c')
| -rw-r--r-- | kernel/trace/bpf_trace.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 506efe6e8ed9..a5580c670866 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -78,12 +78,16 @@ EXPORT_SYMBOL_GPL(trace_call_bpf); BPF_CALL_3(bpf_probe_read, void *, dst, u32, size, const void *, unsafe_ptr) { - int ret; + int ret = 0; + + if (unlikely(size == 0)) + goto out; ret = probe_kernel_read(dst, unsafe_ptr, size); if (unlikely(ret < 0)) memset(dst, 0, size); + out: return ret; } @@ -92,7 +96,7 @@ static const struct bpf_func_proto bpf_probe_read_proto = { .gpl_only = true, .ret_type = RET_INTEGER, .arg1_type = ARG_PTR_TO_UNINIT_MEM, - .arg2_type = ARG_CONST_SIZE, + .arg2_type = ARG_CONST_SIZE_OR_ZERO, .arg3_type = ARG_ANYTHING, }; |
