-
Notifications
You must be signed in to change notification settings - Fork 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
TDBStore: Must use work buffer with size of programming unit. #13731
Conversation
@SeppoTakalo, thank you for your changes. |
CI started |
Jenkins CI Test : ❌ FAILEDBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Unittests failed ( |
Please update the unittests or if not, someone else shall pick this up ? |
In TDBStore::copy_record() we must prepare our content in size of full programming unit. If we don't have big enough buffer we end up writing garbage from our stack. In most cases, this is prevent by usage of output buffer, but when writing the record header, due the padding, we must write one full programming unit.
67f3b34
to
c8426e8
Compare
Pull request has been modified.
PR updated. Found a bug in the PR, fixed it. |
CI started |
Jenkins CI Test : ❌ FAILEDBuild Number: 2 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
I restarted tests. @ARMmbed/mbed-os-core would you be able to take over? |
Jenkins CI Test : ❌ FAILEDBuild Number: 3 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
@LDong-Arm is taking over |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments are for our own record, I'll raise a separate PR
@@ -824,17 +823,19 @@ int TDBStore::copy_record(uint8_t from_area, uint32_t from_offset, uint32_t to_o | |||
uint32_t &to_next_offset) | |||
{ | |||
int ret; | |||
record_header_t header; | |||
record_header_t *header = (record_header_t *) _work_buf; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no guarantee _work_buf
is large enough
@@ -1041,7 +1042,7 @@ int TDBStore::init() | |||
} | |||
|
|||
_prog_size = _bd->get_program_size(); | |||
_work_buf = new uint8_t[work_buf_size]; | |||
_work_buf = new uint8_t[_prog_size]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, we read record_header_t
(a 32-bit aligned struct of size 24 bytes) into _work_buff
, but
- here it's only 8-bit aligned
- the program size can be less than that - some flashes can be programmed to 1-byte, in which case the buffer is insufficient
This could be why the Greentea test failed and hard faulted.
OK, I'll close this one now. |
@@ -847,7 +848,7 @@ int TDBStore::copy_record(uint8_t from_area, uint32_t from_offset, uint32_t to_o | |||
} | |||
|
|||
chunk_size = align_up(sizeof(record_header_t), _prog_size); | |||
ret = write_area(1 - from_area, to_offset, chunk_size, &header); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I get that this is what the PR intended to fix
Co-authored-by: Seppo Takalo <seppo.takalo@arm.com>
Summary of changes
In TDBStore::copy_record() we must prepare our content in
size of full programming unit. If we don't have big enough buffer
we end up writing garbage from our stack.
In most cases, this is prevent by usage of output buffer, but when
writing the record header, due the padding, we must write one full
programming unit.
Impact of changes
Migration actions required
Documentation
Pull request type
Test results
Reviewers