riscv-software-src / riscv-software-src/opensbi

integer overflows in __sbi_fifo_enqueue() and sbi_fifo_dequeue()?

Open
#202 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.5k
Forks
712
PR merge metrics
No merged PRs in 30d

Description

https://github.com/riscv/opensbi/blob/bfc85c70e7517dc633b74e33768247b4df6a661c/lib/sbi/sbi_fifo.c#L66

Hello, is there a chance for these additions and multiplications to overflow? I didn't see any constraints imposed elsewhere that would prevent this from overflowing given large enough values of queue, head, and entry_size.

There's similar code in sbi_fifo_dequeue().

Thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/sbi/sbi_fifo.c at the linked line and inspect __sbi_fifo_enqueue() alongside the similar arithmetic in sbi_fifo_dequeue(). Trace how queue, head, and entry_size are constrained elsewhere, then determine whether large values can overflow. Done means the overflow risk is resolved or formally ruled out, with validation for the relevant cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.