Skip to content

Out-by-one error in vmpu_mpu_push() #369

@nchong

Description

@nchong

This function pushes a slot/region into the v7M MPU. There is an out-by-one error in the check to see if the slot is in range or not. Consider the case when:

ARMv7M_MPU_REGIONS_MAX = 8
g_mpu_slot = 7

Then the check for overflow (++g_mpu_slot > ARMv7M_MPU_REGIONS_MAX) will fail (since 8 > 8 is false).

I think the fix is to change the strict inequality to (++g_mpu_slot >= ARMv7M_MPU_REGIONS_MAX).

Found using ArchEx.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions