Skip to content

bpf, sockmap: keep sk_msg copy bitmap in sync#12138

Open
kernel-patches-daemon-bpf[bot] wants to merge 1 commit into
bpf_basefrom
series/1097961=>bpf
Open

bpf, sockmap: keep sk_msg copy bitmap in sync#12138
kernel-patches-daemon-bpf[bot] wants to merge 1 commit into
bpf_basefrom
series/1097961=>bpf

Conversation

@kernel-patches-daemon-bpf
Copy link
Copy Markdown

Pull request for series with
subject: bpf, sockmap: keep sk_msg copy bitmap in sync
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1097961

@kernel-patches-daemon-bpf
Copy link
Copy Markdown
Author

Upstream branch: 49b1831
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1097961
version: 1

@kernel-patches-daemon-bpf
Copy link
Copy Markdown
Author

Upstream branch: 7dd6256
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1097961
version: 1

The sk_msg scatterlist ring stores the actual page descriptors in
sg.data[] and stores the copy-required state for each slot in the
parallel sg.copy bitmap.  bpf_msg_pull_data() trusts this bitmap to
know whether the current slot can be exposed for direct packet access or
whether it has to be copied into a private page first.

Several SK_MSG helpers move or split sg.data[] entries without moving
the matching sg.copy bit.  In particular, bpf_msg_push_data() can split
a copy-marked entry and place the tail in a new slot with a stale clear
copy bit.  A later bpf_msg_pull_data() can then skip the private copy
and expose a direct writable pointer to the shared page.

Keep sg.copy synchronized whenever these helpers move, split, replace or
remove scatterlist entries.  Clear the bit for newly allocated private
pages and preserve it for descriptors that still refer to the original
shared backing page.

Fixes: 015632b ("bpf: sk_msg program helper bpf_sk_msg_pull_data")
Fixes: 6fff607 ("bpf: sk_msg program helper bpf_msg_push_data")
Fixes: 7246d8e ("bpf: helper to pop data from messages")
Reported-by: Junxi Qian <qjx1298677004@gmail.com>
Reported-by: Qi Tang <tpluszz77@gmail.com>
Signed-off-by: Junxi Qian <qjx1298677004@gmail.com>
Cc: stable@vger.kernel.org
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant