[Bug] rpmi_shmem_mailbox_controller_init() copies FDT queue names into 16-byte qctx->name without checking length
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- c
- Domain
- operating-systems
Research direction
Start at rpmi_shmem_mailbox_controller_init() and inspect how reg-names lengths are returned and copied into qctx->name. Check the surrounding RPMI mailbox code for the expected handling of oversized names, then ensure an overlong FDT queue name cannot overflow the fixed field. Verify the behavior with an oversized queue-name input if the repository provides relevant parser tests.
Written by the indexing model from the issue text.
Description
Hello,
I reviewed current upstream head and found a real missing length check in the RPMI shared-memory mailbox FDT parser.
The queue context stores the name in a fixed field:
```c
#define RPMI_NAME_CHARS_MAX (16)
struct rpmi_mbox_queue_context {
...
char name[RPMI_NAME_CHARS_MAX];
};
```
The initialization code later does:
```c
count = fdt_stringlist_count(fdt, nodeoff, "reg-names");
if (count < 0 || count > (RPMI_QUEUE_IDX_MAX_COUNT + RPMI_REG_IDX_MAX_COUNT))
return SBI_EINVAL;
...
name = fdt_stringlist_get(fdt, nodeoff, "reg-names", qid, &len);
if (!name || (name && len < 0))
return len;
sbi_memcpy(qctx->name, name, len);
```
The important point is that the existing check only validates the number of strings, not the length of each string. `fdt_stringlist_get(..., &len)` returns the actual string length, and current head copies that length directly into `qctx->name[16]` with no `len <= RPMI_NAME_CHARS_MAX` check.
So the current-head claim is narrow and concrete:
- queue names are stored in a fixed 16-byte field,
- the FDT parser obtains an arbitrary string length for each entry,
- and the copy uses that length directly.
A straightforward fix would be to reject any queue name with `len >= RPMI_NAME_CHARS_MAX`, or clamp and explicitly terminate if truncation is acceptable.
Best regards
Pengpeng Hou
- Dominant language
- C
- Stars
- 1.6k
- Forks
- 734
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from riscv-software-src/opensbi
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
riscv-software-src/opensbi#425 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
riscv-software-src/opensbi#424 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
riscv-software-src/opensbi#439 ·
-
sbi_trap_redirect() does not clear SPELP when the interrupted context had no landing pad expectedOpen
Difficulty 3/5 1-2 days Newbie friendliness 67/100
riscv-software-src/opensbi#438 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
riscv-software-src/opensbi#436 · 3 comments ·
All issues in riscv-software-src/opensbi
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
libreswan/libreswan#3185 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
category:port-update
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
llvm:instcombine
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
llvm/llvm-project#246503 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day