Skip to content

bpf, arena: keep range tree consistent on kmalloc_nolock failure - #8636

Open
kernel-patches-daemon-bpf-rc[bot] wants to merge 3 commits into
bpf-next_basefrom
series/1141108=>bpf-next
Open

bpf, arena: keep range tree consistent on kmalloc_nolock failure#8636
kernel-patches-daemon-bpf-rc[bot] wants to merge 3 commits into
bpf-next_basefrom
series/1141108=>bpf-next

Conversation

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown

Pull request for series with
subject: bpf, arena: keep range tree consistent on kmalloc_nolock failure
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1141108

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: 11c1e83
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1141108
version: 1

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

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

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: 8c7f55d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1141108
version: 1

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: 41c129f
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1141108
version: 1

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: 2b1f9f6
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1141108
version: 1

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: e1d9b82
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1141108
version: 1

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: 51476f6
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1141108
version: 1

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: 8b365b3
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1141108
version: 1

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: d114bb9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1141108
version: 1

range_tree_clear() modifies the range tree before allocating the node
needed to split a range.  If the allocation fails, the function returns
-ENOMEM with part of the range already removed from the tree, leaving
those arena slots permanently unavailable.

Pre-allocate the node before modifying the tree so a failure leaves it
unmodified.

Fixes: b795379 ("bpf: Introduce range_tree data structure and use it in bpf arena")
Signed-off-by: Yuan Chen <chenyuan@kylinos.cn>
range_tree_set() clears overlapping ranges before allocating the node
for the new range.  If the allocation fails, the function returns
-ENOMEM with the cleared range already removed from the tree, leaving
those arena slots permanently unavailable.

Allocate only when the range has no adjacent free range on either side;
this is known before the clear, since any range covering start - 1 or
last + 1 survives it as an adjacent piece.  A failure therefore still
leaves the tree unmodified.

Fixes: b795379 ("bpf: Introduce range_tree data structure and use it in bpf arena")
Signed-off-by: Yuan Chen <chenyuan@kylinos.cn>
…_free_worker

arena_free_pages() and arena_free_worker() ignore range_tree_set()
errors and proceed to clear PTEs and free pages, even though the range
tree still considers the range allocated.  The range then becomes
permanently unavailable.

Check the return value: in arena_free_pages() abort the free on error;
in arena_free_worker() move range_tree_set() before PTE clearing and
skip the span on error.

Fixes: b795379 ("bpf: Introduce range_tree data structure and use it in bpf arena")
Signed-off-by: Yuan Chen <chenyuan@kylinos.cn>
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