Subject: Re: [PATCH v2 net 1/1] tipc: fix kernel warning when sending SYN message

From: Jakub Kicinski <[email-masked]>
Date: Fri, 10 Feb 2023 19:16:06 -0800

On Thu, 9 Feb 2023 11:10:16 +0000 Tung Quang Nguyen wrote:
> >>  	msg_set_size(mhdr, msz);
> >>
> >> +	if (!dsz)
> >> +		iov_iter_init(&m->msg_iter, ITER_SOURCE, NULL, 0, 0);  
> >
> >It looks like the root cause of the problem is that not all (indirect)
> >callers of tipc_msg_build() properly initialize the iter.
> >
> >tipc_connect() is one of such caller, but AFAICS even tipc_accept() can
> >reach tipc_msg_build() without proper iter initialization - via
> >__tipc_sendstream -> __tipc_sendmsg.
> >
> >I think it's better if you address the issue in relevant callers,
> >avoiding unneeded and confusing code in tipc_msg_build().  
>
> I am fully aware of callers (without initializing iovec) of this
> function. My intention was to make as less change as possible.

General kernel guidance is to fix things "right" (i.e. so that the fix
doesn't have to be refactored later). 

> Do you think using  iov_iter_kvec() instead in the callers make sense
> if I go for what you suggested ?

I think so. These are the potential culprits?

$ git grep 'struct msghdr [^*]*;' -- net/tipc/
net/tipc/socket.c:      struct msghdr m = {NULL,};
net/tipc/socket.c:      struct msghdr m = {NULL,};
net/tipc/topsrv.c:      struct msghdr msg;
net/tipc/topsrv.c:      struct msghdr msg = {};