You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Incomplete arithmetic is_in_flash_area_bounds allowed combination of offset and length, to any Flash Map function that has been using it, to read/write outside of designated flash area, in case when combination of len and offset would overflow.
To Reproduce
Reproduction is not required; if you take a look at the code above you will notice that off is only checked to be non-negative and if sum of off and len is below or equal to fa_size; the size_t type of len causes the sum operands to be cast to size_t, which is unsigned int (assuming that off_t is smaller or equal type to size_t). This means that it is enough if (off + len) mod(max(size_t)) <= fa_size for the off and len to be accepted as valid.
Expected behavior
Proper checking of off and len not allowing to overflow integer arithmetic.
Impact
Probable reads/writes out of designated flash area.
Environment (please complete the following information):
Prevent possible overflow in is_in_flash_area_bounds while
validating offset and length of an operation.
Fixeszephyrproject-rtos#89349
Signed-off-by: Dominik Ermel <[email protected]>
Describe the bug
Incomplete arithmetic
is_in_flash_area_bounds
allowed combination of offset and length, to any Flash Map function that has been using it, to read/write outside of designated flash area, in case when combination oflen
andoffset
would overflow.zephyr/subsys/storage/flash_map/flash_map_priv.h
Lines 33 to 37 in 5615e46
To Reproduce
Reproduction is not required; if you take a look at the code above you will notice that
off
is only checked to be non-negative and if sum ofoff
andlen
is below or equal tofa_size
; thesize_t
type oflen
causes the sum operands to be cast tosize_t
, which is unsigned int (assuming thatoff_t
is smaller or equal type tosize_t
). This means that it is enough if(off + len) mod(max(size_t)) <= fa_size
for theoff
andlen
to be accepted as valid.Expected behavior
Proper checking of
off
andlen
not allowing to overflow integer arithmetic.Impact
Probable reads/writes out of designated flash area.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: