]> 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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Dec 2024 12:53:23 +0000 (13:53 +0100)
commit1a0d5c17d5ce1019aa2a48b4e6a7b4ce877382c9
tree0485258afde25b5487ab01e895dbfba2e3aff1e4
parent1b2129208a2f1999ee131df74ecb14bfac19da6d
bpf, sockmap: Several fixes to bpf_msg_push_data

[ Upstream commit 15ab0548e3107665c34579ae523b2b6e7c22082a ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/core/filter.c