netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	netdev <netdev@vger.kernel.org>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	David Ahern <dsahern@gmail.com>,
	syzbot <syzkaller@googlegroups.com>
Subject: Re: [PATCH net] ipv4: fix suspicious RCU usage in fib_dump_info_fnhe()
Date: Wed, 26 Jun 2019 12:28:36 +0200	[thread overview]
Message-ID: <20190626122836.508db0ad@redhat.com> (raw)
In-Reply-To: <20190626100450.217106-1-edumazet@google.com>

On Wed, 26 Jun 2019 03:04:50 -0700
Eric Dumazet <edumazet@google.com> wrote:

> sysbot reported that we lack appropriate rcu_read_lock()
> protection in fib_dump_info_fnhe()

Thanks for fixing this.

> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index 6aee412a68bdd3c24a6a0eb9883e04b7a83998e0..59670fafcd2612b94c237cbe30109adb196cf3f0 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -2872,12 +2872,13 @@ int fib_dump_info_fnhe(struct sk_buff *skb, struct netlink_callback *cb,
>  		if (nhc->nhc_flags & RTNH_F_DEAD)
>  			continue;
>  
> +		rcu_read_lock();
>  		bucket = rcu_dereference(nhc->nhc_exceptions);
> -		if (!bucket)
> -			continue;
> -
> -		err = fnhe_dump_bucket(net, skb, cb, table_id, bucket, genid,
> -				       fa_index, fa_start);
> +		err = 0;

Could you perhaps move declaration and initialisation of 'err' outside
the block while at it? It looks a bit more readable at this point.

> +		if (bucket)
> +			err = fnhe_dump_bucket(net, skb, cb, table_id, bucket,
> +					       genid, fa_index, fa_start);
> +		rcu_read_unlock();
>  		if (err)
>  			return err;
>  	}

Either way,

Reviewed-by: Stefano Brivio <sbrivio@redhat.com>

-- 
Stefano

  parent reply	other threads:[~2019-06-26 10:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-26 10:04 [PATCH net] ipv4: fix suspicious RCU usage in fib_dump_info_fnhe() Eric Dumazet
2019-06-26 10:09 ` Eric Dumazet
2019-06-26 10:28 ` Stefano Brivio [this message]
2019-06-26 16:08 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190626122836.508db0ad@redhat.com \
    --to=sbrivio@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=syzkaller@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).