Skip to contentSkip to conversation

serial: sh-sci: Is there a potential buffer underflow in sci_dma_rx_complete()?

DISCUSSION Tuo Li 1 participant 1 message Aug 12, 2021 TTY layer and serial drivers

lore
Share & tools
lore

Tuo Li

author
#0 lore raw

Hello,

Our static analysis tool reports a possible buffer underflow in sh-sci.c in Linux 5.14.0-rc3:

The variable active is checked in:
1304:    if (active >= 0)

This indicates that it can be negative.
If so, a possible buffer underflow will occur:
1312:    desc = dmaengine_prep_slave_sg(s->chan_rx, &s->sg_rx[active], 1, ....);

However, I am not sure whether &s->sg_rx[active] will be used in dmaengine_prep_slave_sg() if the function sci_dma_rx_find_active() called at Line 1303 returns a negative value (-1).

Any feedback would be appreciated, thanks!

Best wishes,
Tuo Li