nodejs / uvwasi

WASI syscall API built atop libuv
MIT License
226 stars 50 forks source link

prevent race conditions with uvwasi_fd_close() #91

Closed cjihrig closed 4 years ago

cjihrig commented 4 years ago

This depends on https://github.com/cjihrig/uvwasi/pull/90 (the first commit in this PR).

uvwasi_fd_close() performed the following operations:

Once the fd's mutex is released, another thread could acquire it before the fd is removed from the file table. If this happens, remove() could destroy a held mutex.

This commit updates uvwasi_fd_close() to perform the entire sequence while holding the file table's lock, preventing new acquisitions of the fd's mutex.

Fixes: https://github.com/cjihrig/uvwasi/issues/88