]> 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>
Sat, 14 Dec 2024 18:50:58 +0000 (19:50 +0100)
commit0f8db9b3693004c8cfe9ddb5e80b64a0db338a87
tree464b41e904a291d2f132ebe5fbfca8bcbfbee735
parent7073d9004fffa2d4bf354d4157843638bdd5d982
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