Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bpf: bpf_probe_read_kernel_str() has to return amount of data read on success

During recent refactorings, bpf_probe_read_kernel_str() started returning 0 on
success, instead of amount of data successfully read. This majorly breaks
applications relying on bpf_probe_read_kernel_str() and bpf_probe_read_str()
and their results. Fix this by returning actual number of bytes read.

Fixes: 8d92db5c04d1 ("bpf: rework the compat kernel probe handling")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20200616050432.1902042-1-andriin@fb.com

authored by

Andrii Nakryiko and committed by
Daniel Borkmann
02553b91 6903cdae

+1 -1
+1 -1
kernel/trace/bpf_trace.c
··· 241 241 if (unlikely(ret < 0)) 242 242 goto fail; 243 243 244 - return 0; 244 + return ret; 245 245 fail: 246 246 memset(dst, 0, size); 247 247 return ret;