Skip to content

Commit

Permalink
bpf: test_run: Fix overflow in bpf_test_finish frags parsing
Browse files Browse the repository at this point in the history
This place also uses signed min_t and passes this singed int to
copy_to_user (which accepts unsigned argument). I don't think
there is an issue, but let's be consistent.

Fixes: 7855e0d ("bpf: test_run: add xdp_shared_info pointer in bpf_test_finish signature")
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20220204235849.14658-2-sdf@google.com
  • Loading branch information
fomichev authored and Alexei Starovoitov committed Feb 8, 2022
1 parent 9d63b59 commit 5d1e9f4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/bpf/test_run.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ static int bpf_test_finish(const union bpf_attr *kattr,
goto out;

if (sinfo) {
int i, offset = len, data_len;
int i, offset = len;
u32 data_len;

for (i = 0; i < sinfo->nr_frags; i++) {
skb_frag_t *frag = &sinfo->frags[i];
Expand All @@ -164,7 +165,7 @@ static int bpf_test_finish(const union bpf_attr *kattr,
break;
}

data_len = min_t(int, copy_size - offset,
data_len = min_t(u32, copy_size - offset,
skb_frag_size(frag));

if (copy_to_user(data_out + offset,
Expand Down

0 comments on commit 5d1e9f4

Please sign in to comment.