]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: fix bpf_prog_get_info_by_fd to dump correct xlated_prog_len
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 28 Jul 2017 15:05:25 +0000 (17:05 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 30 Jul 2017 06:29:41 +0000 (23:29 -0700)
commit71611cee311481ea780d7bd0223d8fe0f12d3799
tree86d2c8f44b7a5aec50febea181056a7784156428
parent135ad1c2535ee130458e6b00601e33031bbbae77
bpf: fix bpf_prog_get_info_by_fd to dump correct xlated_prog_len

bpf_prog_size(prog->len) is not the correct length we want to dump
back to user space. The code in bpf_prog_get_info_by_fd() uses this
to copy prog->insnsi to user space, but bpf_prog_size(prog->len) also
includes the size of struct bpf_prog itself plus program instructions
and is usually used either in context of accounting or for bpf_prog_alloc()
et al, thus we copy out of bounds in bpf_prog_get_info_by_fd()
potentially. Use the correct bpf_prog_insn_size() instead.

Fixes: c505b02fc23d ("bpf: Add BPF_OBJ_GET_INFO_BY_FD")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/bpf/syscall.c