Solve some lock ordering
This commit is contained in:
+2
-4
@@ -441,7 +441,7 @@ impl KernelScheme for ProcScheme {
|
||||
arg1,
|
||||
},
|
||||
} => {
|
||||
let old_ctx = try_stop_context(context, token, |context, _| {
|
||||
let old_ctx = try_stop_context(context, token, |context, token| {
|
||||
let regs = context.regs_mut().ok_or(Error::new(EBADFD))?;
|
||||
regs.set_instr_pointer(new_ip);
|
||||
regs.set_stack_pointer(new_sp);
|
||||
@@ -452,9 +452,7 @@ impl KernelScheme for ProcScheme {
|
||||
))]
|
||||
regs.set_arg1(arg1);
|
||||
|
||||
// TODO: Lock ordering violation
|
||||
let mut token = unsafe { CleanLockToken::new() };
|
||||
Ok(context.set_addr_space(Some(new), token.downgrade()))
|
||||
Ok(context.set_addr_space(Some(new), token))
|
||||
})?;
|
||||
if let Some(old_ctx) = old_ctx
|
||||
&& let Some(addrspace) = Arc::into_inner(old_ctx)
|
||||
|
||||
+9
-11
@@ -1340,12 +1340,15 @@ impl<const READ: bool, const WRITE: bool> CaptureGuard<READ, WRITE> {
|
||||
dst.copy_from_slice(&src.buf()[..dst.len()])?;
|
||||
}
|
||||
let unpin = true;
|
||||
if let Some(ref addrsp) = self.addrsp
|
||||
&& !self.span.is_empty()
|
||||
{
|
||||
let res = addrsp.munmap(self.span, unpin, token)?;
|
||||
for r in res {
|
||||
let _ = r.unmap(token);
|
||||
if let Some(addrsp) = self.addrsp.take() {
|
||||
if !self.span.is_empty() {
|
||||
let res = addrsp.munmap(self.span, unpin, token)?;
|
||||
for r in res {
|
||||
let _ = r.unmap(token);
|
||||
}
|
||||
}
|
||||
if let Some(addrsp) = Arc::into_inner(addrsp) {
|
||||
addrsp.into_drop(token);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1353,11 +1356,6 @@ impl<const READ: bool, const WRITE: bool> CaptureGuard<READ, WRITE> {
|
||||
}
|
||||
pub fn release(mut self, token: &mut CleanLockToken) -> Result<()> {
|
||||
self.release_inner(token)?;
|
||||
if let Some(addrsp) = self.addrsp.take()
|
||||
&& let Some(addrsp) = Arc::into_inner(addrsp)
|
||||
{
|
||||
addrsp.into_drop(token);
|
||||
}
|
||||
if let Some(src) = self.head.src.take() {
|
||||
src.into_drop(token);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user