mirror of https://github.com/m-labs/artiq.git
firmware: fix another TOCTTOU race in sync/async RPC code.
This commit is contained in:
parent
68aad3e482
commit
248c1cf7dc
|
@ -518,6 +518,19 @@ pub unsafe fn main() {
|
||||||
attribute_writeback(typeinfo as *const ());
|
attribute_writeback(typeinfo as *const ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure all async RPCs are processed before exiting.
|
||||||
|
// Otherwise, if the comms and kernel CPU run in the following sequence:
|
||||||
|
//
|
||||||
|
// comms kernel
|
||||||
|
// ----------------------- -----------------------
|
||||||
|
// check for async RPC
|
||||||
|
// post async RPC
|
||||||
|
// post RunFinished
|
||||||
|
// check for mailbox
|
||||||
|
//
|
||||||
|
// the async RPC would be missed.
|
||||||
|
send(&RpcFlush);
|
||||||
|
|
||||||
send(&RunFinished);
|
send(&RunFinished);
|
||||||
|
|
||||||
loop {}
|
loop {}
|
||||||
|
|
|
@ -73,6 +73,7 @@ pub enum Message<'a> {
|
||||||
},
|
},
|
||||||
RpcRecvRequest(*mut ()),
|
RpcRecvRequest(*mut ()),
|
||||||
RpcRecvReply(Result<usize, Exception<'a>>),
|
RpcRecvReply(Result<usize, Exception<'a>>),
|
||||||
|
RpcFlush,
|
||||||
|
|
||||||
CacheGetRequest { key: &'a str },
|
CacheGetRequest { key: &'a str },
|
||||||
CacheGetReply { value: &'static [i32] },
|
CacheGetReply { value: &'static [i32] },
|
||||||
|
|
|
@ -417,7 +417,13 @@ fn process_kern_message(io: &Io, mut stream: Option<&mut TcpStream>,
|
||||||
kern_acknowledge()
|
kern_acknowledge()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
&kern::RpcFlush => {
|
||||||
|
// See ksupport/lib.rs for the reason this request exists.
|
||||||
|
// We do not need to do anything here because of how the main loop is
|
||||||
|
// structured.
|
||||||
|
kern_acknowledge()
|
||||||
|
},
|
||||||
|
|
||||||
&kern::CacheGetRequest { key } => {
|
&kern::CacheGetRequest { key } => {
|
||||||
let value = session.congress.cache.get(key);
|
let value = session.congress.cache.get(key);
|
||||||
|
|
Loading…
Reference in New Issue