Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] iov_iter: silent fallback to iterate_discard() for dmabuf maps - [Medium] iov_iter: bounds check bypass in iov_iter_revert() for dmabuf maps --
commit 8e47b333dea94c1451175bac8e284adfbbf175cc Author: Pavel Begunkov <[email protected]> Subject: iov_iter: add iterator type for dmabuf maps Introduce a new ITER_DMABUF_MAP iterator type for dmabuf maps. The patch adds the new iterator type, updates struct iov_iter to hold dmabuf maps, and wires up basic iterator operations like advance, revert, and alignment. > diff --git a/include/linux/uio.h b/include/linux/uio.h > index fe2e985d74d24..638c1116e912e 100644 > --- a/include/linux/uio.h > +++ b/include/linux/uio.h [ ... ] > @@ -29,6 +30,7 @@ enum iter_type { > ITER_FOLIOQ, > ITER_XARRAY, > ITER_DISCARD, > + ITER_DMABUF_MAP, > }; [Severity: Medium] With the addition of ITER_DMABUF_MAP here, do iterate_and_advance2() and iterate_and_advance_kernel() in include/linux/iov_iter.h also need to be updated? It appears they currently lack a type check for ITER_DMABUF_MAP, which might cause operations like copy_to_iter() or copy_from_iter() to silently fall through to iterate_discard(). If any middle layer attempts to read or write using this iterator type, the operation would drop data and return success without reporting an error. [ ... ] > diff --git a/lib/iov_iter.c b/lib/iov_iter.c > index 2072c04e99d05..6831a5d9396e1 100644 > --- a/lib/iov_iter.c > +++ b/lib/iov_iter.c [ ... ] > @@ -775,6 +777,20 @@ void iov_iter_xarray(struct iov_iter *i, unsigned int > direction, > } > EXPORT_SYMBOL(iov_iter_xarray); > > +void iov_iter_dmabuf_map(struct iov_iter *i, unsigned int direction, > + struct dma_buf_io_map *map, > + loff_t off, size_t count) > +{ > + WARN_ON(direction & ~(READ | WRITE)); > + *i = (struct iov_iter){ > + .iter_type = ITER_DMABUF_MAP, > + .data_source = direction, > + .dmabuf_map = map, > + .count = count, > + .iov_offset = off, > + }; > +} [Severity: Medium] Since iov_offset is initialized here to the absolute starting offset (off) rather than a relative zero, does this cause an issue with the tracking logic in iov_iter_revert()? In iov_iter_revert(), the unroll size is checked against i->iov_offset like this: if (unroll <= i->iov_offset) { i->iov_offset -= unroll; return; } Because iov_offset starts at the absolute offset rather than 0, couldn't a caller successfully revert an ITER_DMABUF_MAP iterator beyond its initial starting offset? This would bypass the BUG() safety net intended to catch invalid unrolls, potentially leading to an out-of-bounds DMA access if the reverted iterator is used again. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=2
