UPSTREAM: bpf: Explicitly memset the bpf_attr structure

For the bpf syscall, we are relying on the compiler to properly zero out
the bpf_attr union that we copy userspace data into. Unfortunately that
doesn't always work properly, padding and other oddities might not be
correctly zeroed, and in some tests odd things have been found when the
stack is pre-initialized to other values.

Fix this by explicitly memsetting the structure to 0 before using it.

Reported-by: Maciej ┼╗enczykowski <>
Reported-by: John Stultz <>
Reported-by: Alexander Potapenko <>
Reported-by: Alistair Delva <>
Signed-off-by: Greg Kroah-Hartman <>
Signed-off-by: Daniel Borkmann <>
Acked-by: Yonghong Song <>
(cherry picked from commit 8096f229421f7b22433775e928d506f0342e5907)
Signed-off-by: Greg Kroah-Hartman <>
Change-Id: I2dc28cd45024da5cc6861ff4a9b25fae389cc6d8
1 file changed