bytecodealliance / bytecodealliance/ComponentizeJS

Import return buffers are never freed

Đang mở
#330 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
391
Fork
53
Merge trung bình
3 ngày 5 giờ
Pull request đã merge (30 ngày)
1

Mô tả

**Issue details assume #319 is merged.**

Import return buffers allocated via `cabi_realloc` in the splicer are never freed. The old `free_list` bulk free in `post_call` was the only mechanism reclaiming them, but it also caused use-after-free (#224, fixed by #319).

The retptr is returned to JS as a pointer, and JS reads from it after the WASM glue returns, so there's no obvious place to insert a free in the current architecture. This is an unbounded leak for components that make repeated import calls returning strings or lists.

Separately, I noticed the bindgen sets `post_return: None` so ComponentizeJS never generates post-return functions for exports. The canonical ABI expects the host to call post-return so the guest can free export return buffers. I haven't investigated whether `post_call` covers this already.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu bằng việc xem xét cách splicer xử lý `cabi_realloc` và logic free-list của `post_call`, trong đó issue #319 là điều kiện tiên quyết còn #224 đề cập đến use-after-free trước đây. Sau đó, kiểm tra thiết lập `post_return: None` của bindgen và cách ComponentizeJS xử lý các lệnh gọi post-return của export. Công việc được coi là hoàn tất khi đã quyết định được một thiết kế về ownership và reclamation, ngăn chặn cả memory leak lẫn use-after-free.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
rust, wasm
Lĩnh vực
backend
Loại issue
Lỗi
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.