Skip to content

Commit 4a11678

Browse files
fmaurer-rhborkmann
authored andcommitted
bpf: Do not try bpf_msg_push_data with len 0
If bpf_msg_push_data() is called with len 0 (as it happens during selftests/bpf/test_sockmap), we do not need to do anything and can return early. Calling bpf_msg_push_data() with len 0 previously lead to a wrong ENOMEM error: we later called get_order(copy + len); if len was 0, copy + len was also often 0 and get_order() returned some undefined value (at the moment 52). alloc_pages() caught that and failed, but then bpf_msg_push_data() returned ENOMEM. This was wrong because we are most probably not out of memory and actually do not need any additional memory. Fixes: 6fff607 ("bpf: sk_msg program helper bpf_msg_push_data") Signed-off-by: Felix Maurer <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Yonghong Song <[email protected]> Acked-by: John Fastabend <[email protected]> Link: https://lore.kernel.org/bpf/df69012695c7094ccb1943ca02b4920db3537466.1644421921.git.fmaurer@redhat.com
1 parent 525de9a commit 4a11678

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/core/filter.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,6 +2710,9 @@ BPF_CALL_4(bpf_msg_push_data, struct sk_msg *, msg, u32, start,
27102710
if (unlikely(flags))
27112711
return -EINVAL;
27122712

2713+
if (unlikely(len == 0))
2714+
return 0;
2715+
27132716
/* First find the starting scatterlist element */
27142717
i = msg->sg.start;
27152718
do {

0 commit comments

Comments
 (0)