netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] ipv6: Fix may be used uninitialized warning in rt6_check
@ 2017-08-25  7:05 Steffen Klassert
  2017-08-25  7:52 ` Steffen Klassert
  2017-08-26  0:08 ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Steffen Klassert @ 2017-08-25  7:05 UTC (permalink / raw)
  To: David S. Miller; +Cc: Wei Wang, Eric Dumazet, Martin KaFai Lau, netdev

rt_cookie might be used uninitialized, fix this by
initializing it.

Fixes: c5cff8561d2d ("ipv6: add rcu grace period before freeing fib6_node")
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/ipv6/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index a9d3564..48c8c92 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1289,7 +1289,7 @@ static void rt6_dst_from_metrics_check(struct rt6_info *rt)
 
 static struct dst_entry *rt6_check(struct rt6_info *rt, u32 cookie)
 {
-	u32 rt_cookie;
+	u32 rt_cookie = 0;
 
 	if (!rt6_get_cookie_safe(rt, &rt_cookie) || rt_cookie != cookie)
 		return NULL;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net] ipv6: Fix may be used uninitialized warning in rt6_check
  2017-08-25  7:05 [PATCH net] ipv6: Fix may be used uninitialized warning in rt6_check Steffen Klassert
@ 2017-08-25  7:52 ` Steffen Klassert
  2017-08-25  9:02   ` Stefano Brivio
  2017-08-26  0:08 ` David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: Steffen Klassert @ 2017-08-25  7:52 UTC (permalink / raw)
  To: David S. Miller; +Cc: Wei Wang, Eric Dumazet, Martin KaFai Lau, netdev

On Fri, Aug 25, 2017 at 09:05:42AM +0200, Steffen Klassert wrote:
> rt_cookie might be used uninitialized, fix this by
> initializing it.
> 
> Fixes: c5cff8561d2d ("ipv6: add rcu grace period before freeing fib6_node")
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
> ---
>  net/ipv6/route.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index a9d3564..48c8c92 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1289,7 +1289,7 @@ static void rt6_dst_from_metrics_check(struct rt6_info *rt)
>  
>  static struct dst_entry *rt6_check(struct rt6_info *rt, u32 cookie)
>  {
> -	u32 rt_cookie;
> +	u32 rt_cookie = 0;
>  
>  	if (!rt6_get_cookie_safe(rt, &rt_cookie) || rt_cookie != cookie)
>  		return NULL;

The compiler warning seems to be a false positive, as
rt_cookie != cookie is only checked if rt6_get_cookie_safe
returns true in which case rt_cookie is initialized.

Please disregard this patch.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] ipv6: Fix may be used uninitialized warning in rt6_check
  2017-08-25  7:52 ` Steffen Klassert
@ 2017-08-25  9:02   ` Stefano Brivio
  2017-08-26  0:04     ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Stefano Brivio @ 2017-08-25  9:02 UTC (permalink / raw)
  To: Steffen Klassert
  Cc: David S. Miller, Wei Wang, Eric Dumazet, Martin KaFai Lau, netdev

On Fri, 25 Aug 2017 09:52:17 +0200
Steffen Klassert <steffen.klassert@secunet.com> wrote:

> On Fri, Aug 25, 2017 at 09:05:42AM +0200, Steffen Klassert wrote:
> > rt_cookie might be used uninitialized, fix this by
> > initializing it.
> > 
> > Fixes: c5cff8561d2d ("ipv6: add rcu grace period before freeing fib6_node")
> > Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
> > ---
> >  net/ipv6/route.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> > index a9d3564..48c8c92 100644
> > --- a/net/ipv6/route.c
> > +++ b/net/ipv6/route.c
> > @@ -1289,7 +1289,7 @@ static void rt6_dst_from_metrics_check(struct rt6_info *rt)
> >  
> >  static struct dst_entry *rt6_check(struct rt6_info *rt, u32 cookie)
> >  {
> > -	u32 rt_cookie;
> > +	u32 rt_cookie = 0;
> >  
> >  	if (!rt6_get_cookie_safe(rt, &rt_cookie) || rt_cookie != cookie)
> >  		return NULL;  
> 
> The compiler warning seems to be a false positive, as
> rt_cookie != cookie is only checked if rt6_get_cookie_safe
> returns true in which case rt_cookie is initialized.
> 
> Please disregard this patch.

...or not? I was thinking of sending a similar patch with
uninitialized_var(rt_cookie), but it seems we have similar cases
where we just initialize to zero instead.

I wonder which approach is considered the most acceptable nowadays. I
would be in favour of uninitialized_var() as it doesn't change the
binary output, but https://lwn.net/Articles/529954/ also contains some
valid criticism. Ideas?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] ipv6: Fix may be used uninitialized warning in rt6_check
  2017-08-25  9:02   ` Stefano Brivio
@ 2017-08-26  0:04     ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-08-26  0:04 UTC (permalink / raw)
  To: sbrivio; +Cc: steffen.klassert, weiwan, edumazet, kafai, netdev

From: Stefano Brivio <sbrivio@redhat.com>
Date: Fri, 25 Aug 2017 11:02:06 +0200

> On Fri, 25 Aug 2017 09:52:17 +0200
> Steffen Klassert <steffen.klassert@secunet.com> wrote:
> 
>> On Fri, Aug 25, 2017 at 09:05:42AM +0200, Steffen Klassert wrote:
>> > rt_cookie might be used uninitialized, fix this by
>> > initializing it.
>> > 
>> > Fixes: c5cff8561d2d ("ipv6: add rcu grace period before freeing fib6_node")
>> > Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
>> > ---
>> >  net/ipv6/route.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> > 
>> > diff --git a/net/ipv6/route.c b/net/ipv6/route.c
>> > index a9d3564..48c8c92 100644
>> > --- a/net/ipv6/route.c
>> > +++ b/net/ipv6/route.c
>> > @@ -1289,7 +1289,7 @@ static void rt6_dst_from_metrics_check(struct rt6_info *rt)
>> >  
>> >  static struct dst_entry *rt6_check(struct rt6_info *rt, u32 cookie)
>> >  {
>> > -	u32 rt_cookie;
>> > +	u32 rt_cookie = 0;
>> >  
>> >  	if (!rt6_get_cookie_safe(rt, &rt_cookie) || rt_cookie != cookie)
>> >  		return NULL;  
>> 
>> The compiler warning seems to be a false positive, as
>> rt_cookie != cookie is only checked if rt6_get_cookie_safe
>> returns true in which case rt_cookie is initialized.
>> 
>> Please disregard this patch.
> 
> ...or not? I was thinking of sending a similar patch with
> uninitialized_var(rt_cookie), but it seems we have similar cases
> where we just initialize to zero instead.
> 
> I wonder which approach is considered the most acceptable nowadays. I
> would be in favour of uninitialized_var() as it doesn't change the
> binary output, but https://lwn.net/Articles/529954/ also contains some
> valid criticism. Ideas?

Generally speaking I guess initializing to zero is Ok to do.

As far as which approach is better, I don't have any strong opinion.

So I will probably just apply Steffen's patch.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] ipv6: Fix may be used uninitialized warning in rt6_check
  2017-08-25  7:05 [PATCH net] ipv6: Fix may be used uninitialized warning in rt6_check Steffen Klassert
  2017-08-25  7:52 ` Steffen Klassert
@ 2017-08-26  0:08 ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2017-08-26  0:08 UTC (permalink / raw)
  To: steffen.klassert; +Cc: weiwan, edumazet, kafai, netdev

From: Steffen Klassert <steffen.klassert@secunet.com>
Date: Fri, 25 Aug 2017 09:05:42 +0200

> rt_cookie might be used uninitialized, fix this by
> initializing it.
> 
> Fixes: c5cff8561d2d ("ipv6: add rcu grace period before freeing fib6_node")
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-08-26  0:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-25  7:05 [PATCH net] ipv6: Fix may be used uninitialized warning in rt6_check Steffen Klassert
2017-08-25  7:52 ` Steffen Klassert
2017-08-25  9:02   ` Stefano Brivio
2017-08-26  0:04     ` David Miller
2017-08-26  0:08 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).