[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20170604.225740.1710058828586611741.davem@davemloft.net>
Date: Sun, 04 Jun 2017 22:57:40 -0400 (EDT)
From: David Miller <davem@...emloft.net>
To: f.fainelli@...il.com
Cc: netdev@...r.kernel.org, andrew@...n.ch,
vivien.didelot@...oirfairelinux.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net] net: dsa: Fix stale cpu_switch reference after
unbind then bind
From: Florian Fainelli <f.fainelli@...il.com>
Date: Fri, 2 Jun 2017 22:05:23 -0700
> Commit 9520ed8fb841 ("net: dsa: use cpu_switch instead of ds[0]")
> replaced the use of dst->ds[0] with dst->cpu_switch since that is
> functionally equivalent, however, we can now run into an use after free
> scenario after unbinding then rebinding the switch driver.
>
> The use after free happens because we do correctly initialize
> dst->cpu_switch the first time we probe in dsa_cpu_parse(), then we
> unbind the driver: dsa_dst_unapply() is called, and we rebind again.
> dst->cpu_switch now points to a freed "ds" structure, and so when we
> finally dereference it in dsa_cpu_port_ethtool_setup(), we oops.
>
> To fix this, simply set dst->cpu_switch to NULL in dsa_dst_unapply()
> which guarantees that we always correctly re-assign dst->cpu_switch in
> dsa_cpu_parse().
>
> Fixes: 9520ed8fb841 ("net: dsa: use cpu_switch instead of ds[0]")
> Signed-off-by: Florian Fainelli <f.fainelli@...il.com>
Applied and queued up for -stable, thanks.
Powered by blists - more mailing lists