Re: [PATCH net-next] net: devmem: remove min_t(iter_iov_len) in sendmsg

From: Stanislav Fomichev
Date: Fri May 16 2025 - 23:53:25 EST


On 05/17, Al Viro wrote:
> On Fri, May 16, 2025 at 07:17:23PM -0700, Stanislav Fomichev wrote:
> > > Wait, in the same commit there's
> > > + if (iov_iter_type(from) != ITER_IOVEC)
> > > + return -EFAULT;
> > >
> > > shortly prior to the loop iter_iov_{addr,len}() are used. What am I missing now?
> >
> > Yeah, I want to remove that part as well:
> >
> > https://lore.kernel.org/netdev/20250516225441.527020-1-stfomichev@xxxxxxxxx/T/#u
> >
> > Otherwise, sendmsg() with a single IOV is not accepted, which makes not
> > sense.
>
> Wait a minute. What's there to prevent a call with two ranges far from each other?

It is perfectly possible to have a call with two disjoint ranges,
net_devmem_get_niov_at should correctly resolve it to the IOVA in the
dmabuf. Not sure I understand why it's an issue, can you pls clarify?

What we want to have here is:

1. sendmsg(msg.msg_iov = [{ .iov_base = .., .iov_len = x }])
2. sendmsg(msg.msg_iov = [{ .iov_base = .., .iov_len = x },
{ .iov_base = .., .iov_len = y])

Both should be accepted. Currently only (2) works because of that ITER_IOVEC
check. Once I remove it, I hit the issue where iter_iov_len starts to
return too early.

(Documentation/networking/devmem.rst has a bit more info on the sendmsg UAPI
with dmabufs if that's still confusing)