Similarly to #1171, the raw_descriptor_store lock is grabbed three times in succession for two inserts. If the second operation fails (because the table is full, for example) the first fd is removed. If a concurrent thread interleaves between these two lock acquisitions and closes the same slot, the second insert's failure mode will either try to close a non-existent fd or an unrelated fd.
|
let raw_fd1 = files.insert_raw_fd(typed1).map_err(|typed| { |
|
let _ = self.global.litebox.descriptor_table_mut().remove(&typed); |
|
Errno::EMFILE |
|
})?; |
|
let raw_fd2 = files.insert_raw_fd(typed2).map_err(|typed| { |
|
self.do_close(raw_fd1).unwrap(); |
|
let _ = self.global.litebox.descriptor_table_mut().remove(&typed); |
|
Errno::EMFILE |
|
})?; |
Similarly to #1171, the
raw_descriptor_storelock is grabbed three times in succession for two inserts. If the second operation fails (because the table is full, for example) the first fd is removed. If a concurrent thread interleaves between these two lock acquisitions and closes the same slot, the second insert's failure mode will either try to close a non-existent fd or an unrelated fd.litebox/litebox_shim_linux/src/syscalls/net.rs
Lines 1075 to 1083 in 9732adf