riscv-software-src / riscv-software-src/opensbi
Too small fw_heap_size makes OpenSBI corrupt memory
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 1.5k
- Forks
- 712
- PR merge metrics
- No merged PRs in 30d
Description
Heap minimum appears to be 16k. This is quite a chunk. This is not documented anywhere nor checked anywhere.
Otherwise sbi_heap.c fails:
hpctrl.hksize = hpctrl.size / HEAP_HOUSEKEEPING_FACTOR;
hpctrl.hksize &= ~((unsigned long)HEAP_BASE_ALIGN - 1);
8k: (0x2000 / 16) & ~(1024 - 1) = 0 (Fail!)
16k: (0x4000 / 16) & ~(1024 - 1) = 0x400 (Ok)
For example, with fw_heap_size = 8k, hpctrl.hksize gets to be zero making the OpenSBI corrupt memory wildly. Everything goes bust and boom in that case.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in sbi_heap.c at the hpctrl.hksize calculation and trace how fw_heap_size is configured and consumed. Verify the minimum size or validation needed to prevent a zero housekeeping size, then document the requirement and check the affected heap behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100