# Re: \[PATCH net v2 2/3\] net: prevent rewrite of msg\_name in sock\_sendmsg()

- From: Jordan Rife \<hidden\>
- Date: 2023-09-18 20:49:07 
- List: netdev
- Page: https://ratatoskr.run/netdev/2023/09/11272296
- Thread: https://ratatoskr.run/netdev/2023/09/11272121/t.md

```text
Just a heads up, there are also kernel_recvmsg/sock_recvmsg functions
that mirror the kernel_sendmsg/sock_sendmsg. If we are are doing this

> 1) Rename the current kernel_sendmsg() function to
> kernel_sendmsg_kvec() and name  our new function kernel_sendmsg(). To
> me this makes some sense, considering the new function is the more
> generic of the two, and the existing kernel_sendmsg() specifically
> accepts "struct kvec".

it creates an asymmetry between *sendmsg and *recvmsg function names.
If we wanted these to be similar then it means a rename to these
functions (e.g. kern_recvmsg becomes kern_recvmsg_kvec, rename
sock_recvmsg to kern_recvmsg).

-Jordan

On Mon, Sep 18, 2023 at 11:02 AM Jordan Rife [ref] wrote:
>
> Sounds like a plan.
>
> On Mon, Sep 18, 2023 at 10:55 AM Willem de Bruijn
> [ref] wrote:
> >
> > On Mon, Sep 18, 2023 at 1:52 PM Jordan Rife [ref] wrote:
> > >
> > > > You used this short-hand to avoid having to update all callers to sock_sendmsg to __kernel_sendmsg?
> > >
> > > Sorry about that, I misunderstood the intent. I'm fine with
> > > introducing a new function, doing the address copy there, and
> > > replacing all calls to sock_sendmsg with this wrapper. One thought on
> > > the naming though,
> > >
> > > To me the "__" prefix seems out of place for a function meant as a
> > > public interface. Some possible alternatives:
> > >
> > > 1) Rename the current kernel_sendmsg() function to
> > > kernel_sendmsg_kvec() and name  our new function kernel_sendmsg(). To
> > > me this makes some sense, considering the new function is the more
> > > generic of the two, and the existing kernel_sendmsg() specifically
> > > accepts "struct kvec".
> > > 2) Same as #1, but drop the old kernel_sendmsg() function instead of
> > > renaming it. Adapt all calls to the old kernel_sendmsg() to fit the
> > > new kernel_sendmsg() (this amounts to adding a
> > > iov_iter_kvec(&msg->msg_iter, ITER_SOURCE, vec, num, size); call in
> > > each spot before kernel_sendmsg() is called.
> >
> > Thanks. Fair points.
> >
> > Of the two proposals, I think the first is preferable, as it avoids
> > some non-trivial open coding in multiple callers.
```
