diff options
author | Damien Zammit <damien@zamaudio.com> | 2022-09-08 09:32:52 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-09-11 21:20:53 +0200 |
commit | 22676a3a6e4d99e13ee75c1ad2f4976ae6b0ce52 (patch) | |
tree | 166b5a14fa24eb45382c8c03e83279de8007de7f /libmachdev | |
parent | fab864748c2daf57b3fdad7382cba5f9b9d5c9d8 (diff) | |
download | hurd-22676a3a6e4d99e13ee75c1ad2f4976ae6b0ce52.tar.gz hurd-22676a3a6e4d99e13ee75c1ad2f4976ae6b0ce52.tar.bz2 hurd-22676a3a6e4d99e13ee75c1ad2f4976ae6b0ce52.zip |
machdev, pci-arbiter, rumpdisk: Fix race condition in bootstrap
This fixes a known race condition in bootstrapping by
separating the fsys_startup call from the server demuxer loop
into two separate functions that the caller can decide
when to call.
Message-Id: <20220908093229.499494-1-damien@zamaudio.com>
Diffstat (limited to 'libmachdev')
-rw-r--r-- | libmachdev/machdev.h | 3 | ||||
-rw-r--r-- | libmachdev/trivfs_server.c | 18 |
2 files changed, 14 insertions, 7 deletions
diff --git a/libmachdev/machdev.h b/libmachdev/machdev.h index e1833cff..50bfd41b 100644 --- a/libmachdev/machdev.h +++ b/libmachdev/machdev.h @@ -37,7 +37,8 @@ void * machdev_server(void *); error_t machdev_create_device_port (size_t size, void *result); int machdev_trivfs_init(int argc, char **argv, mach_port_t bootstrap_resume_task, const char *name, const char *path, mach_port_t *bootstrap); int machdev_demuxer(mach_msg_header_t *inp, mach_msg_header_t *outp); -void machdev_trivfs_server(mach_port_t bootstrap); +void machdev_trivfs_server_startup(mach_port_t bootstrap); +void * machdev_trivfs_server_loop(void *); boolean_t machdev_is_master_device (mach_port_t port); #endif diff --git a/libmachdev/trivfs_server.c b/libmachdev/trivfs_server.c index 21684dab..979741d1 100644 --- a/libmachdev/trivfs_server.c +++ b/libmachdev/trivfs_server.c @@ -84,6 +84,9 @@ static task_t parent_task; /* Our argument vector */ static char **machdev_argv; +/* Our trivfs control port to use in server loop */ +static struct trivfs_control *global_fsys; + static void install_as_translator (mach_port_t bootport) { @@ -513,9 +516,8 @@ trivfs_modify_stat (struct trivfs_protid *cred, io_statbuf_t *stat) } void -machdev_trivfs_server(mach_port_t bootstrap) +machdev_trivfs_server_startup(mach_port_t bootstrap) { - struct trivfs_control *fsys = NULL; int err; if (bootstrapping == FALSE) @@ -523,7 +525,7 @@ machdev_trivfs_server(mach_port_t bootstrap) /* This path is executed when a parent exists */ err = trivfs_startup (bootstrap, 0, trivfs_cntl_class, port_bucket, - trivfs_protid_class, port_bucket, &fsys); + trivfs_protid_class, port_bucket, &global_fsys); mach_port_deallocate (mach_task_self (), bootstrap); if (err) error (1, err, "Contacting parent"); @@ -532,14 +534,18 @@ machdev_trivfs_server(mach_port_t bootstrap) } else { - fsys = control; + global_fsys = control; } +} +void * +machdev_trivfs_server_loop(void *arg) +{ /* Launch. */ do { ports_manage_port_operations_one_thread (port_bucket, demuxer, 0); - } while (trivfs_goaway (fsys, 0)); + } while (trivfs_goaway (global_fsys, 0)); - /* Never reached */ + return NULL; } |