IPlib: spi: possible invalid SPI FIFO read
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 1.2k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
In the following SPI RX FIFO consumption while-loop:
As this function does not mandate the parameter ByteCount to be divisible by {1, 2, 4}-byte. It is possible that the caller can pass something like 5-byte to transmit/receive. If this is the case, then, when ByteCount (remaining bytes to receive) is nearing zero, and the DataWidth is not of XSP_DATAWIDTH_BYTE, a read can potentially consumes invalid byte(s).
Instead, would it be more robust to do something like "always test the remaining bytes to receive, and switch to XSP_DATAWIDTH_BYTE when ByteCount is less than the preset DataWidth" ? Or, we should simply add a "divisible by {1, 2, 4}-byte" check at function prologue?
Contributor guide
No contributing guide indexed for this repository
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 XilinxProcessorIPLib/drivers/spi/src/xspi.c at the SPI RX FIFO consumption loop around lines 746-783, and trace how ByteCount and DataWidth behave for non-divisible sizes such as 5 bytes. Determine the intended handling for the remaining bytes, then verify that the FIFO is not read beyond the requested count.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100