Skip to content

Commit

Permalink
ipc: avoid double grant entry
Browse files Browse the repository at this point in the history
Check if the app is using IPC incorrectly and trying to notify itself.
If it is we need to return early so we do not double enter a grant.
  • Loading branch information
bradjc committed Jun 28, 2024
1 parent ab884ba commit 5e36496
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions kernel/src/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ impl<const NUM_PROCS: u8> IPC<NUM_PROCS> {
) -> 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
Expand Down

0 comments on commit 5e36496

Please sign in to comment.