Subject: Re: [PATCH net-next v6 03/11] ipv4/route: Allow NULL flowinfo in rt_fill_info()

From: Stefano Brivio <[email-masked]>
Date: Thu, 20 Jun 2019 21:00:22 +0200

On Thu, 20 Jun 2019 07:15:55 -0600
David Ahern <[email-masked]> wrote:

> On 6/19/19 5:59 PM, Stefano Brivio wrote:
> > In the next patch, we're going to use rt_fill_info() to dump exception
> > routes upon RTM_GETROUTE with NLM_F_ROOT, meaning userspace is requesting
> > a dump and not a specific route selection, which in turn implies the input
> > interface is not relevant. Update rt_fill_info() to handle a NULL
> > flowinfo.
> > 
> > Suggested-by: David Ahern <[email-masked]>
> > Signed-off-by: Stefano Brivio <[email-masked]>
> > ---
> > v6: New patch
> > 
> >  net/ipv4/route.c | 57 ++++++++++++++++++++++++++----------------------
> >  1 file changed, 31 insertions(+), 26 deletions(-)
> > 
> > diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> > index 66cbe8a7a168..052a80373b1d 100644
> > --- a/net/ipv4/route.c
> > +++ b/net/ipv4/route.c
> > @@ -2699,7 +2699,8 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src,
> >  	r->rtm_family	 = AF_INET;
> >  	r->rtm_dst_len	= 32;
> >  	r->rtm_src_len	= 0;
> > -	r->rtm_tos	= fl4->flowi4_tos;
> > +	if (fl4)
> > +		r->rtm_tos	= fl4->flowi4_tos;  
> 
> tracing back to the alloc_skb it does not appear to be initialized to 0,
> so this should be:
> 	r->rtm_tos	= fl4 ? fl4->flowi4_tos : 0;

I guess you're right, but I'm still wondering why I'm not seeing it
with KMSAN. Thanks for catching this, I'll fix it.

-- 
Stefano