bpf, offload: Replace bitwise AND by logical AND in bpf_prog_offload_info_fill
authorJohannes Krude <johannes@krude.de>
Wed, 12 Feb 2020 19:32:27 +0000 (20:32 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 28 Feb 2020 15:38:59 +0000 (16:38 +0100)
commitbf3043d27755a8cb53cb99e4f04139a5279761e0
treeeb7d8f6d4ecc6907f64bbff203ce5d807f5958f7
parent3132696dd748f44b60f940e78c8d10203e33117a
bpf, offload: Replace bitwise AND by logical AND in bpf_prog_offload_info_fill

commit e20d3a055a457a10a4c748ce5b7c2ed3173a1324 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: fcfb126defda ("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>
kernel/bpf/offload.c