Subject: Re: [PATCH net] ipvlan: fix addr hash list corruption

From: Jiri Benc <[email-masked]>
Date: Tue, 24 Mar 2015 09:58:09 +0100

On Mon, 23 Mar 2015 18:10:01 -0700, Mahesh Bandewar wrote:
> On Mon, Mar 23, 2015 at 2:10 PM, Jiri Benc <[email-masked]> wrote:
> > When ipvlan interface with IP addresses attached is brought down and then
> > deleted, the assigned addresses are deleted twice from the address hash
> > list, first on the interface down and second on the link deletion.
> > Similarly, when an address is added while the interface is down, it is added
> > second time once the interface is brought up.
> >
> Presumably this is creating problems for you and I'm not sure why? Do
> you have a script  / (sequence of commands) to produce this condition?

You cannot call hlist_del_rcu on the same pointer twice. Nor
hlist_add_head_rcu, for that matter.

Try e.g.:

ip link add link eth0 name ipvl0 type ipvlan mode l2
ip link set ipvl0 up
ip addr add 1.2.3.1/24 dev ipvl0
ip link set ipvl0 down
	-> ipvlan_ht_addr_del(1.2.3.1)
ip link del ipvl0
	-> ipvlan_ht_addr_del(1.2.3.1)
-> crash

Or:

ip link add link eth0 name ipvl0 type ipvlan mode l2
ip addr add 1.2.3.1/24 dev ipvl0
	-> ipvlan_ht_addr_add(1.2.3.1)
ip link set ipvl0 up
	-> ipvlan_ht_addr_add(1.2.3.1)
-> does not crash immediately but the list is corrupted, go see how the
   pointers in port->hlhead[hash] list look now

> ipvlan_ht_addr_del() does use synchronize_rcu() expect when the device
> in dismantle state. Could that be a reason?

This has nothing to do with RCU.

 Jiri

-- 
Jiri Benc