bpf, arena: fix range_tree consistency on allocation failure - #13435
bpf, arena: fix range_tree consistency on allocation failure#13435kernel-patches-daemon-bpf[bot] wants to merge 3 commits into
Conversation
|
Upstream branch: 5e289c5 |
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: |
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: |
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: |
|
Forwarding comment 5396667125 via email |
|
Forwarding comment 5396680724 via email |
|
Forwarding comment 5396736132 via email |
71e031f to
909ca3a
Compare
|
Upstream branch: d83fba2 |
ffd2b7b to
02a6ed3
Compare
909ca3a to
b010507
Compare
|
Upstream branch: ce36e38 |
02a6ed3 to
2c76994
Compare
b010507 to
975b11a
Compare
|
Upstream branch: 05ea1b6 |
2c76994 to
014d9e8
Compare
975b11a to
f8c8078
Compare
range_tree_clear() pre-allocates the right-half node before modifying the tree, so an allocation failure returns -ENOMEM without altering the range tree. Signed-off-by: Yuan Chen <chenyuan@kylinos.cn>
range_tree_set() pre-allocates the node needed for a brand-new range before calling range_tree_clear(), so an allocation failure returns -ENOMEM without having modified the tree (previously the overlapping nodes were already removed by range_tree_clear() before the allocation was attempted, permanently losing the cleared sub-ranges). Signed-off-by: Yuan Chen <chenyuan@kylinos.cn>
…_free_worker arena_free_pages() and arena_free_worker() now handle range_tree_set() errors. arena_free_pages() aborts the free on error, and arena_free_worker() moves range_tree_set() before PTE clearing so that a failed tree update leaves the PTEs intact instead of freeing pages that the arena free tree does not track. Also check the range_tree_set() return value in arena_alloc_pages()'s error path, which restores the unpopulated tail of a partially allocated range; log a warning instead of silently leaking the virtual range when the tree update fails. range_tree_set() is failure-atomic (it pre-allocates the node before touching the tree), so on -ENOMEM the range stays tracked as allocated and the pages remain mapped and accessible. A failed free is therefore retryable, and arena_map_free() reclaims any retained pages at map destruction; aborting the free avoids clearing PTEs for pages the arena free tree does not track. In arena_free_worker() a failed tree update used to leave the span in the drained list, where the second loop would still flush TLB entries, zap user VMAs, and free the span itself: the free request was dropped, user mappings were destroyed for a free that never happened, and the pages stayed mapped until map destruction. Keep failed spans on arena->free_spans instead and retry them on a later worker run; only spans whose PTE clearing actually ran are flushed, zapped, and released. Suggested-by: Emil Tsalapatis <emil@etsalapatis.com> Signed-off-by: Yuan Chen <chenyuan@kylinos.cn>
|
Upstream branch: 1555de3 |
014d9e8 to
77efca4
Compare
Pull request for series with
subject: bpf, arena: fix range_tree consistency on allocation failure
version: 4
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1150936