From 9b8228d76f36833d2150a1f073a316982f503d9a Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Fri, 8 Sep 2017 13:08:58 +0200 Subject: [PATCH] Noux: fix race condition on Vfs_io_channel destruction Fixes #2518 --- repos/ports/src/noux/child.h | 1 + repos/ports/src/noux/main.cc | 12 ++++++++---- repos/ports/src/noux/syscall.cc | 2 +- repos/ports/src/noux/vfs_io_channel.h | 8 +++++--- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/repos/ports/src/noux/child.h b/repos/ports/src/noux/child.h index 4ada464fc..5c024056f 100644 --- a/repos/ports/src/noux/child.h +++ b/repos/ports/src/noux/child.h @@ -127,6 +127,7 @@ class Noux::Child : public Rpc_object, Vfs::Dir_file_system &_root_dir; Vfs_io_waiter_registry &_vfs_io_waiter_registry; + Vfs_handle_context _vfs_handle_context; Destruct_queue &_destruct_queue; diff --git a/repos/ports/src/noux/main.cc b/repos/ports/src/noux/main.cc index 82da53a43..81bb48bc1 100644 --- a/repos/ports/src/noux/main.cc +++ b/repos/ports/src/noux/main.cc @@ -97,6 +97,7 @@ connect_stdio(Genode::Env &env, Genode::Constructible &terminal, Genode::Xml_node config, Vfs::Dir_file_system &root, + Noux::Vfs_handle_context &vfs_handle_context, Noux::Vfs_io_waiter_registry &vfs_io_waiter_registry, Noux::Terminal_io_channel::Type type, Genode::Allocator &alloc) @@ -143,7 +144,8 @@ connect_stdio(Genode::Env &env, return *new (alloc) Vfs_io_channel(path.string(), root.leaf_path(path.string()), &root, - vfs_handle, vfs_io_waiter_registry, env.ep()); + vfs_handle, vfs_handle_context, + vfs_io_waiter_registry, env.ep()); } @@ -237,6 +239,8 @@ struct Noux::Main _io_response_handler, _global_file_system_factory }; + Vfs_handle_context _vfs_handle_context; + Pid_allocator _pid_allocator; Timeout_scheduler _timeout_scheduler { _env }; @@ -301,13 +305,13 @@ struct Noux::Main Shared_pointer _channel_0 { &connect_stdio(_env, _terminal, _config.xml(), _root_dir, - _io_response_handler.io_waiter_registry, + _vfs_handle_context, _io_response_handler.io_waiter_registry, Tio::STDIN, _heap), _heap }, _channel_1 { &connect_stdio(_env, _terminal, _config.xml(), _root_dir, - _io_response_handler.io_waiter_registry, + _vfs_handle_context, _io_response_handler.io_waiter_registry, Tio::STDOUT, _heap), _heap }, _channel_2 { &connect_stdio(_env, _terminal, _config.xml(), _root_dir, - _io_response_handler.io_waiter_registry, + _vfs_handle_context, _io_response_handler.io_waiter_registry, Tio::STDERR, _heap), _heap }; Main(Env &env) : _env(env) diff --git a/repos/ports/src/noux/syscall.cc b/repos/ports/src/noux/syscall.cc index 822fd4016..1d508c769 100644 --- a/repos/ports/src/noux/syscall.cc +++ b/repos/ports/src/noux/syscall.cc @@ -240,7 +240,7 @@ bool Noux::Child::syscall(Noux::Session::Syscall sc) Shared_pointer channel(new (_heap) Vfs_io_channel(_sysio.open_in.path, leaf_path, &_root_dir, - vfs_handle, + vfs_handle, _vfs_handle_context, _vfs_io_waiter_registry, _env.ep()), _heap); diff --git a/repos/ports/src/noux/vfs_io_channel.h b/repos/ports/src/noux/vfs_io_channel.h index ff33d2615..876af82f9 100644 --- a/repos/ports/src/noux/vfs_io_channel.h +++ b/repos/ports/src/noux/vfs_io_channel.h @@ -62,20 +62,22 @@ struct Noux::Vfs_io_channel : Io_channel Vfs::Vfs_handle *_fh; + Vfs_handle_context &_context; + Vfs_io_waiter_registry &_vfs_io_waiter_registry; Absolute_path _path; Absolute_path _leaf_path; - Vfs_handle_context _context; - Vfs_io_channel(char const *path, char const *leaf_path, Vfs::Dir_file_system *root_dir, Vfs::Vfs_handle *vfs_handle, + Vfs_handle_context &vfs_handle_context, Vfs_io_waiter_registry &vfs_io_waiter_registry, Entrypoint &ep) : _read_avail_handler(ep, *this, &Vfs_io_channel::_handle_read_avail), - _fh(vfs_handle), _vfs_io_waiter_registry(vfs_io_waiter_registry), + _fh(vfs_handle), _context(vfs_handle_context), + _vfs_io_waiter_registry(vfs_io_waiter_registry), _path(path), _leaf_path(leaf_path) { _fh->context = &_context;