]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Fix too large copy from user in bpf_test_init
authorJesper Dangaard Brouer <brouer@redhat.com>
Mon, 18 May 2020 13:05:27 +0000 (15:05 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 19 May 2020 15:56:34 +0000 (17:56 +0200)
commit3595e9f6dff0e42b2444b1a80f063ca31cd3558d
treee7dbca49e7a5c1b6a8c5bd42acec8624903914df
parentfaebb1a480986eefa942f3b2541c8336807cf8ba
bpf: Fix too large copy from user in bpf_test_init

Commit 17856ff83d9a ("bpf: Add xdp.frame_sz in bpf_prog_test_run_xdp().")
recently changed bpf_prog_test_run_xdp() to use larger frames for XDP in
order to test tail growing frames (via bpf_xdp_adjust_tail) and to have
memory backing frame better resemble drivers.

The commit contains a bug, as it tries to copy the max data size from
userspace, instead of the size provided by userspace.  This cause XDP
unit tests to fail sporadically with EFAULT, an unfortunate behavior.
The fix is to only copy the size specified by userspace.

Fixes: 17856ff83d9a ("bpf: Add xdp.frame_sz in bpf_prog_test_run_xdp().")
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/158980712729.256597.6115007718472928659.stgit@firesoul
net/bpf/test_run.c