HomeFreeBSD

busdma: avoid buflen underflow

Description

busdma: avoid buflen underflow

The loop condition in the dmamap_load_buffer() method is 'buflen > 0',
and buflen is an unsigned type (bus_size_t).

A recent change made it possible for sgsize to exceed the remaining
buflen, when the tag has a large alignment requirement. The result is
that we would not break out of the loop at the correct time. Fix this by
avoiding underflow in the subtraction at the end of the loop.

PR: 279383
Reported by: Robert Morris <rtm@lcs.mit.edu>
Reviewed by: jhibbits
Fixes: a77e1f0f81df ("busdma: better handling of small segment bouncing")
Differential Revision: https://reviews.freebsd.org/D45732

Details

Provenance
mhorneAuthored on Jul 8 2024, 2:51 PM
Reviewer
rGa77e1f0f81df: busdma: better handling of small segment bouncing
Differential Revision
D45732: busdma: avoid buflen underflow
Parents
rG4e148a7baa1c: riscv: include PV chunks in kernel dump
Branches
Unknown
Tags
Unknown