Original commit message:
allow windows to detect tty types
uv_fs_fstat() fails on TTYs on Windows. This commit updates
uvwasi__get_filetype_by_fd() to detect this case and map
the fd to the WASI character device type.
Refs: https://github.com/nodejs/node/issues/31461
Fixes: https://github.com/nodejs/node/issues/31461
PR-URL: https://github.com/nodejs/node/pull/31495
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Original commit message:
prevent race conditions with uvwasi_fd_close()
uvwasi_fd_close() performed the following operations:
- lock the file descriptor mutex
- close the file
- release the file descriptor mutex
- call the file table's remove() function
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
PR-URL: https://github.com/nodejs/node/pull/31432
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Original commit message:
prevent locking fd table while holding a mutex
uvwasi_path_rename(), uvwasi_path_link(),
uvwasi_path_open(), and uvwasi_fd_renumber() operate
on multiple file descriptors. uvwasi_fd_renumber() has
been updated prior to this commit, and is not relevant
here. The other three functions would perform the
following locking operations:
- lock the file table
- acquire a file descriptor mutex
- unlock the file table
- unlock the file table again
- acquire another file descriptor mutex
- unlock the file table
- unlock the two mutexes
Attempting to acquire the second mutex introduced
the possibility of deadlock because another thread
could attempt to acquire the first mutex while
holding the file table lock.
This commit ensures that multiple mutexes are either:
- acquired in a single lock of the file table
- or, only acquired after releasing previously held mutexes
Fixes: https://github.com/cjihrig/uvwasi/issues/89
PR-URL: https://github.com/nodejs/node/pull/31432
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Original commit message:
unlock all fd mutexes in reverse order
Some functions acquire mutexes for multiple file descriptors.
This commit ensures that the mutexes are released in the
reverse order that they are aquired.
PR-URL: https://github.com/nodejs/node/pull/31432
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
This version improves file descriptor renumbering, and as a result
fixes uvwasi_fd_renumber().
PR-URL: https://github.com/nodejs/node/pull/31432
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
This commit updates the uvwasi dependency to version 0.0.4. The
most notable change is a refactor of the way paths are resolved.
All paths, including symlinks, are now resolved in terms of
sandboxed paths instead of leaking host system paths.
PR-URL: https://github.com/nodejs/node/pull/31363
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Original commit message:
This commit changes the memory management in
uvwasi_fd_table_init() such that ENOMEM errors can be
handled better in uvwasi_fd_table_free().
PR-URL: https://github.com/nodejs/node/pull/31076
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Original commit message:
This commit ensures that multiple calls to uvwasi_destroy()
are possible. Prior to this commit, subsequent calls to
destroy() would abort because the file table's rwlock was
incorrectly being destroyed multiple times.
PR-URL: https://github.com/nodejs/node/pull/31076
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit updates to uvwasi 0.0.3, which implements a newer
version of the WASI spec, snapshot_1. Since the WASI API has
changed, this also requires updating the WebAssembly memory
interfacing logic and recompiling the WASI tests with a
version of wasi-libc that supports snapshot_1.
PR-URL: https://github.com/nodejs/node/pull/30980
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>