deepin: ARM:Fix segmentation fault when running fuse-bpf on ARM#1083
deepin: ARM:Fix segmentation fault when running fuse-bpf on ARM#1083myslqyr wants to merge 1 commit intodeepin-community:linux-6.6.yfrom
Conversation
The Struct_op operation allocates a single memory page to store target platform binary code.On x86, where instruction lengths are shorter, one page is sufficient. However, on ARM architectures, longer instructions require more memory space, causing the single page allocation to overflow. To resolve this, the memory allocation has been increased to two pages, ensuring stable operation of the fuse_daemon. Signed-off-by: myslqyr <1748189201@qq.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis patch defines a new ST_IMAGE_SIZE macro (2× PAGE_SIZE) and replaces hard-coded PAGE_SIZE values in buffer allocation, boundary checks, and memory protection calls to double the executable buffer for BPF struct operations, preventing overflows on architectures with larger instruction encodings. Class diagram for updated bpf_struct_ops_map structure and related functionsclassDiagram
class bpf_struct_ops_map {
+void *image
+void *uvalue
+struct bpf_links **links
}
class bpf_struct_ops_map_alloc {
+bpf_struct_ops_map_alloc(union bpf_attr *attr)
}
class bpf_struct_ops_map_update_elem {
+bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key, void *value, u64 flags)
}
bpf_struct_ops_map_alloc --> bpf_struct_ops_map : allocates
bpf_struct_ops_map_update_elem --> bpf_struct_ops_map : updates
bpf_struct_ops_map : image field now allocated with ST_IMAGE_SIZE (2 * PAGE_SIZE)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Hi @myslqyr. Thanks for your PR. 😃 |
|
Hi @myslqyr. Thanks for your PR. I'm waiting for a deepin-community member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
ok-to-test |
There was a problem hiding this comment.
Pull request overview
Fixes a segmentation fault on ARM when running fuse-bpf by increasing the executable “image” buffer used for struct_ops trampolines from one page to two pages (to accommodate larger generated instruction sequences on ARM).
Changes:
- Introduce
ST_IMAGE_SIZEasPAGE_SIZE * 2for a consistent trampoline image size. - Allocate
ST_IMAGE_SIZEforst_map->imageand updateimage_endaccordingly during trampoline generation. - Update
set_memory_{rox,nx,rw}()calls to apply to two pages instead of one.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #define ST_IMAGE_SIZE (PAGE_SIZE * 2) | ||
|
|
There was a problem hiding this comment.
The struct comment for st_map->image still describes it as a single page and says PAGE_SIZE is sufficient, which is no longer true now that ST_IMAGE_SIZE is used. Please update that comment to match the new two-page allocation to avoid misleading future readers.
| bpf_map_area_alloc(btf_type_vlen(t) * sizeof(struct bpf_links *), | ||
| NUMA_NO_NODE); | ||
| st_map->image = bpf_jit_alloc_exec(PAGE_SIZE); | ||
| st_map->image = bpf_jit_alloc_exec(ST_IMAGE_SIZE); | ||
| if (!st_map->uvalue || !st_map->links || !st_map->image) { |
There was a problem hiding this comment.
After increasing the JIT image allocation to ST_IMAGE_SIZE, bpf_struct_ops_map_mem_usage() still accounts only PAGE_SIZE (line ~714), so map memory accounting will be under-reported by one page. Please update the mem_usage calculation to include ST_IMAGE_SIZE instead of PAGE_SIZE to keep BPF memlock/accounting accurate.
The Struct_op operation allocates a single memory page to store target platform binary code.On x86, where instruction lengths are shorter, one page is sufficient. However, on ARM architectures, longer instructions require more memory space, causing the single page allocation to overflow.
To resolve this, the memory allocation has been
increased to two pages, ensuring stable operation
of the fuse_daemon.
Summary by Sourcery
Increase the executable image buffer for BPF struct operations from one page to two pages to prevent overflows on architectures with longer instructions (e.g., ARM).
Bug Fixes:
Enhancements: