Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965329AbbLOPbz (ORCPT ); Tue, 15 Dec 2015 10:31:55 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35266 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965229AbbLOPbv (ORCPT ); Tue, 15 Dec 2015 10:31:51 -0500 Date: Tue, 15 Dec 2015 15:31:49 +0000 From: Ben Hutchings To: Greg Kroah-Hartman Cc: David Ahern , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Nikolay Aleksandrov , "David S. Miller" Message-ID: <20151215153149.GO28542@decadent.org.uk> References: <56702E7E.5000604@cumulusnetworks.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Qa0ccP92Gc0Ko3P8" Content-Disposition: inline In-Reply-To: <56702E7E.5000604@cumulusnetworks.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: ben@decadent.org.uk Subject: [PATCH 4.3 1/2] Revert "vrf: fix double free and memory corruption on register_netdevice failure" X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on shadbolt.decadent.org.uk) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2699 Lines: 88 --Qa0ccP92Gc0Ko3P8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable This reverts commit b3abad339f8e268bb261e5844ab68b18a7797c29, which was an attempt to backport commit 7f109f7cc37108cba7243bc832988525b0d85909 upstream. The backport introduced a deadlock and other bugs. Signed-off-by: Ben Hutchings --- drivers/net/vrf.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c index c9e309c..488c6f5 100644 --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c @@ -581,6 +581,7 @@ static int vrf_newlink(struct net *src_net, struct net_= device *dev, { struct net_vrf *vrf =3D netdev_priv(dev); struct net_vrf_dev *vrf_ptr; + int err; =20 if (!data || !data[IFLA_VRF_TABLE]) return -EINVAL; @@ -589,16 +590,26 @@ static int vrf_newlink(struct net *src_net, struct ne= t_device *dev, =20 dev->priv_flags |=3D IFF_VRF_MASTER; =20 + err =3D -ENOMEM; vrf_ptr =3D kmalloc(sizeof(*dev->vrf_ptr), GFP_KERNEL); if (!vrf_ptr) - return -ENOMEM; + goto out_fail; =20 vrf_ptr->ifindex =3D dev->ifindex; vrf_ptr->tb_id =3D vrf->tb_id; =20 + err =3D register_netdevice(dev); + if (err < 0) + goto out_fail; + rcu_assign_pointer(dev->vrf_ptr, vrf_ptr); =20 - return register_netdev(dev); + return 0; + +out_fail: + kfree(vrf_ptr); + free_netdev(dev); + return err; } =20 static size_t vrf_nl_getsize(const struct net_device *dev) --Qa0ccP92Gc0Ko3P8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIVAwUBVnAyZee/yOyVhhEJAQojTxAAr9O216dOpzluBhfI0nPmbfrHy83hi6Aj Wy0uxTNOk6Mn7YG1w1sO7laUtgnv6wh2xxfb1dcj62rOfhemHflmW6oJ/R+knRE9 YbOmNNpcw4o2uE4a9X37f5pE4z78JyMz/QDNXoN4PdPSMR/VgAr8dh5Mu3YVqFux 8uoNB2uNTTUvAsEWnBZj8m+8HKUnHLUdVUE3gmwlXlLbhcA0PVM1Iekmevj7Lr67 WAS7TvqW07By+sZRho8XAvrONAhtMosIWGzg4zfZiTlpho3pLGDGUxX/PaYHmxm8 nyQzoFMfs73AyRTwK2kPvoCUqj9eZYBel7g9CO2X62iTYLRRM9iFEf+gpsf+BiSv QIO4ylVgjmXbftblBVb8iRIni7F93HHmpPODPDZbzdXaBBU3WLlub/QIsAxgIbKx TXcBJWec/FnUmX1regFghUROCIyspyusNYIdvCyQXj+mXWl1vOOKrtqj80YJTwiQ wCt6Qzg9uc1xBSwt6meNGxhB2jaRRztz8czILrxg1bE8BCb4iGdRPtenXx7tCX00 p/CPWcSX7g3kEdbkpS10o+vDUZAvskSbU9YZwmgloEH6r+dWfvN+buKAT0HVPG/f c+3czirNKpVzX7PbeL2mFAiNnShCUeIRrWjevdZfbJ24db0snEGsqtcDSmnSqjYs D4zoPJP3iTM= =D0au -----END PGP SIGNATURE----- --Qa0ccP92Gc0Ko3P8-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/