JSPI shadow stack management

Đang mở
#27,364 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

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

Hướng nghiên cứu

Bắt đầu với entry point emscripten_stack_get_current() và hành vi shadow stack của WebAssembly.promising được mô tả trong issue. So sánh hai cách tiếp cận được đề xuất —xử lý ở compiler/toolchain hoặc một primitive mới emscripten_stack_get_promising_top()— cùng với công việc liên quan của Pyodide và wasm-bindgen. Được xem là hoàn tất khi thiết lập được một quy ước có khả năng tương tác và vững chắc cho việc tạm dừng và tiếp tục shadow stack của Rust JSPI.

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

Mô tả

Pyodide implemented JSPI shadow stack suspend/resume semantics quite comprehensively in https://blog.pyodide.org/posts/jspi-with-c-runtime/.

I'm now seeing similar issues for Rust and JSPI, and have been prototyping some (unfinished) ideas in https://github.com/guybedford/jspi - where as far as I can tell Emscripten is not automatically handling the shadow stack save and restore operations, so that JSPI will lead to stack corruption in Rust per Hood's blog post scenario.

In addition, wasm-bindgen is about to land support for JSPI with it's own shadow stack handling in https://github.com/wasm-bindgen/wasm-bindgen/pull/5193 and to get these approaches to interoperate well requires falling on strong conventions.

All conventions come down to needing a stack top though for the shadow stack suspension range. And the stack top is not easy to get since by the time you call emscripten_stack_get_current() you're always deep into the entry point Rust wrapper code.

We can't use the stack base, because WebAssembly.promising functions can be called with arbitrary non-JSPI stack depth, so this core feature missing to integrate this well into Rust seems to me to be a emsripten_stack_get_promising_top() for the current WebAssembly.promising which Emscripten in theory would know about.

Unless I'm missing something, as far as I can tell this leaves us with two options for Rust JSPI soundness:

  1. Either fully implement the shadow stack save/restore work at the compiler / toolchain level (instead of as a library)
  2. Expose a new JSPI-specific emscripten_stack_get_promising_top() primitive

I'd be interested to hear what others think about how to handle the problems here.

Ngôn ngữ chính
C++
Star
27.8k
Fork
3.6k
Merge trung bình
1 ngày 10 giờ
Pull request đã merge (30 ngày)
177

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của emscripten-core/emscripten

Tất cả issue của emscripten-core/emscripten

Issue tương tự

Thêm issue về C++

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.