Skip to content

Commit

Permalink
arch: arc: fix the bug where buffer validate should be atomic
Browse files Browse the repository at this point in the history
reported by #22290 and similar to #22275, the access to mpu regs
in buffer validate should be atomic.

Signed-off-by: Wayne Ren <[email protected]>
  • Loading branch information
Wayne Ren authored and andrewboie committed Feb 5, 2020
1 parent 8450d26 commit d1fa27c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions arch/arc/core/mpu/arc_mpu_v3_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ int arc_core_mpu_get_max_domain_partition_regions(void)
int arc_core_mpu_buffer_validate(void *addr, size_t size, int write)
{
int r_index;

int key = arch_irq_lock();

/*
* For ARC MPU v3, overlapping is not supported.
Expand All @@ -667,13 +667,17 @@ int arc_core_mpu_buffer_validate(void *addr, size_t size, int write)
/* match and the area is in one region */
if (r_index >= 0 && r_index == _mpu_probe((u32_t)addr + (size - 1))) {
if (_is_user_accessible_region(r_index, write)) {
return 0;
r_index = 0;
} else {
return -EPERM;
r_index = -EPERM;
}
} else {
r_index = -EPERM;
}

return -EPERM;
arch_irq_unlock(key);

return r_index;
}
#endif /* CONFIG_USERSPACE */

Expand Down

0 comments on commit d1fa27c

Please sign in to comment.