mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 22:02:02 +00:00
bpf, offload: Replace bitwise AND by logical AND in bpf_prog_offload_info_fill
commite20d3a055a
upstream. This if guards whether user-space wants a copy of the offload-jited bytecode and whether this bytecode exists. By erroneously doing a bitwise AND instead of a logical AND on user- and kernel-space buffer-size can lead to no data being copied to user-space especially when user-space size is a power of two and bigger then the kernel-space buffer. Fixes:fcfb126def
("bpf: add new jited info fields in bpf_dev_offload and bpf_prog_info") Signed-off-by: Johannes Krude <johannes@krude.de> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Jakub Kicinski <kuba@kernel.org> Link: https://lore.kernel.org/bpf/20200212193227.GA3769@phlox.h.transitiv.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
2463a30f66
commit
8132323eb3
1 changed files with 1 additions and 1 deletions
|
@ -321,7 +321,7 @@ int bpf_prog_offload_info_fill(struct bpf_prog_info *info,
|
||||||
|
|
||||||
ulen = info->jited_prog_len;
|
ulen = info->jited_prog_len;
|
||||||
info->jited_prog_len = aux->offload->jited_len;
|
info->jited_prog_len = aux->offload->jited_len;
|
||||||
if (info->jited_prog_len & ulen) {
|
if (info->jited_prog_len && ulen) {
|
||||||
uinsns = u64_to_user_ptr(info->jited_prog_insns);
|
uinsns = u64_to_user_ptr(info->jited_prog_insns);
|
||||||
ulen = min_t(u32, info->jited_prog_len, ulen);
|
ulen = min_t(u32, info->jited_prog_len, ulen);
|
||||||
if (copy_to_user(uinsns, aux->offload->jited_image, ulen)) {
|
if (copy_to_user(uinsns, aux->offload->jited_image, ulen)) {
|
||||||
|
|
Loading…
Reference in a new issue