]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf, sockmap: Several fixes to bpf_msg_push_data
authorZijian Zhang <zijianzhang@bytedance.com>
Wed, 6 Nov 2024 22:25:18 +0000 (22:25 +0000)
committerMartin KaFai Lau <martin.lau@kernel.org>
Thu, 7 Nov 2024 00:01:53 +0000 (16:01 -0800)
commit15ab0548e3107665c34579ae523b2b6e7c22082a
treedda98c950a8b6ed99f7b50041072e65790e20f40
parent47eae080410b1de1d7f6c79b511aaa6be865c61e
bpf, sockmap: Several fixes to bpf_msg_push_data

Several fixes to bpf_msg_push_data,
1. test_sockmap has tests where bpf_msg_push_data is invoked to push some
data at the end of a message, but -EINVAL is returned. In this case, in
bpf_msg_push_data, after the first loop, i will be set to msg->sg.end, add
the logic to handle it.
2. In the code block of "if (start - offset)", it's possible that "i"
points to the last of sk_msg_elem. In this case, "sk_msg_iter_next(msg,
end)" might still be called twice, another invoking is in "if (!copy)"
code block, but actually only one is needed. Add the logic to handle it,
and reconstruct the code to make the logic more clear.

Fixes: 6fff607e2f14 ("bpf: sk_msg program helper bpf_msg_push_data")
Signed-off-by: Zijian Zhang <zijianzhang@bytedance.com>
Link: https://lore.kernel.org/r/20241106222520.527076-7-zijianzhang@bytedance.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
net/core/filter.c