]> 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)
commit774ff90983dd319c25f36c92efc2a783a964e24f
treee7dbca49e7a5c1b6a8c5bd42acec8624903914df
parent867468c820a7df3226614186ecd93b80ff296001
bpf: Fix too large copy from user in bpf_test_init

Commit bdff7bcb80da ("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: bdff7bcb80da ("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