-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
esp_himem_map() calculates wrong pointer if range_offset is nonzero (IDFGH-3713) #5639
Comments
Thanks for reporting, we will look into. |
I think this bug report is valid. |
Any progress? |
@Alvin1Zhang |
Just hit this. Any chance it will ever be fixed? |
Does the change mentioned in #5639 (comment) work for you? |
@AxelLin It does. FWIW, current release/v4.4, release/v5.0, release/v5.1 and master are also affected. |
It's not a matter of API vs. implementation: the actual mapping works fine and just in the way described in the documentation. The problem is a bug in the computation of On the positive side, the bug cannot go unnoticed because the incorrect pointer is always beyond the end of the valid ESP32 memory address range, so attempting to dereference it immediately causes an abort. |
@alyf80 , I see. I have reconsidered this and think your proposal make sense. No one can call the function with The fix is on the way. |
@ginkgm v5.0 branch still needs this fix. |
Environment
Problem Description
The
esp_himem_map()
function accepts arange_offset
parameter that selects the virtual memory range within an existing range handle to use. For any value ofrange_offset
other than zero, the resulting pointer returned via*out_ptr
is calculated incorrectly.By simple inspection of line 338 in esp_himem.c:
range_offset
is in bytes, but it's being added torange->block_start
which is counting cache blocks and then being multiplied byCACHE_BLOCKSIZE
.Instead, it should be calculated one of two possible more-or-less equivalent ways:
or:
The text was updated successfully, but these errors were encountered: