diff --git a/kernel/src/ipc.rs b/kernel/src/ipc.rs index b1ccf09b20..e285577ff2 100644 --- a/kernel/src/ipc.rs +++ b/kernel/src/ipc.rs @@ -73,6 +73,13 @@ impl IPC { ) -> Result<(), process::Error> { let schedule_on_id = schedule_on.index().ok_or(process::Error::NoSuchApp)?; let called_from_id = called_from.index().ok_or(process::Error::NoSuchApp)?; + + // Verify that IPC is not trying to share with the same app. If so, this + // will cause a double grant enter if we don't return now. + if schedule_on_id == called_from_id { + return Err(process::Error::AlreadyInUse); + } + self.data.enter(schedule_on, |_, schedule_on_data| { self.data.enter(called_from, |_, called_from_data| { // If the other app shared a buffer with us, make