Received: by 10.223.176.5 with SMTP id f5csp784054wra; Sat, 3 Feb 2018 10:11:24 -0800 (PST) X-Google-Smtp-Source: AH8x2279DManpQ3ytNtZvBpVnUiYoFyzhB9KAfeVCVZ7OvB06RIeGjfu/OkpMF9MDvQSwRjPdtYD X-Received: by 10.98.160.142 with SMTP id p14mr2644015pfl.151.1517681484307; Sat, 03 Feb 2018 10:11:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517681484; cv=none; d=google.com; s=arc-20160816; b=IOMDZx1wPDwadCn8Aa2YxGlucxRCJPSjn/lBcuJGwd5ywVpo0rejk1L0GLaIG4pif1 d8weth628gS4iJ9heHrT18MA2Fw+7sLaS9KmiYLl9GIrcAZJu7poRayYIHjt6s/NP8D1 n6RRK8XYvLvK+OU8XMPZDsWyAIBqCZEW+9A89N8SFNfHd965CqWDfYp6MWMgnRgSJ+1D 571x0sRm+Bpk7+eEklmIL/cpzpFZFOHkUUyRsQqNgfd7eDPLWZFYrd8jrIfgwVhlmo6M oKO8JFz4RKotHkcOLh4vwP4Vka+GK5esGYDwrx4j1g4XhJQWvsVb109mHRwhxGLne5dy sauA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=oHyt1WUd49mAMytDzvqNqu5ZbMUzdJc6evDbnL0rBDs=; b=Y9QrQ2zuA6s69St+j37TmccMofKkC8m/F4k+dwGlLhS5xcRO1Bb4f+QXQZbFPElN+g fKfGst+Jn7WNBMza/VHaC1ERQMdCXl28pYo11PNJAdDlNkXOZR2skDcQefFqEfEfQ6oC sqSsPjw0AmTtuq2Bmwev/n2PwQTFqlcpnD0CBRu2e7ZlKoiiYHhL+DKN3TNps/rTYaLH YZsfHp3XuwIyHKKoVVTZAFmqRV7/geNSQQL49SIKlGYjwOnIYcuDmUPqbXVUNKWJZm3O Kjt3CLv/mmNEDXCEbcindcuPWhk1PPFG7JMe0HUP+c6edAaSZKR6ACvkoVzdZCyqzDpV fg9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=ZIjZmakS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n64si1299079pfi.369.2018.02.03.10.11.09; Sat, 03 Feb 2018 10:11:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=ZIjZmakS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753770AbeBCSJQ (ORCPT + 99 others); Sat, 3 Feb 2018 13:09:16 -0500 Received: from mail-by2nam03on0136.outbound.protection.outlook.com ([104.47.42.136]:45129 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753366AbeBCSFR (ORCPT ); Sat, 3 Feb 2018 13:05:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=oHyt1WUd49mAMytDzvqNqu5ZbMUzdJc6evDbnL0rBDs=; b=ZIjZmakSjJGQawIDtmBmgY29PHVrbBQ21a9/8im5Ypisk55hiF9zRuzGiYMN7Ea/+p3UWqv2LZhfYLIVLstAt32gd4wZUlVXrIoV8EGWcRLZQOeu3ZNjuhBLwEME2kSDEmheYHZ+XH17oi24tk/128AE/nYuhsVytZOuWSlhsm4= Received: from BL0PR2101MB1027.namprd21.prod.outlook.com (52.132.20.161) by BL0PR2101MB1105.namprd21.prod.outlook.com (52.132.24.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.485.5; Sat, 3 Feb 2018 18:02:10 +0000 Received: from BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9]) by BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9%3]) with mapi id 15.20.0485.006; Sat, 3 Feb 2018 18:02:10 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Gao Feng , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 077/110] macvlan: Fix one possible double free Thread-Topic: [PATCH AUTOSEL for 4.14 077/110] macvlan: Fix one possible double free Thread-Index: AQHTnRj9cQCtIt56b0G1P+0Fbo2gTQ== Date: Sat, 3 Feb 2018 18:01:18 +0000 Message-ID: <20180203180015.29073-77-alexander.levin@microsoft.com> References: <20180203180015.29073-1-alexander.levin@microsoft.com> In-Reply-To: <20180203180015.29073-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BL0PR2101MB1105;6:1JSIJQzt3HdE/DoleuE0kJioePy5DoEcN5xitvXVfw6YESC8ctuhDBVaSJB/oElC5mTf8kEQt+0z/Z+BlARBiHlFQAQET/u6AtAhgvEbSG8q1XdnCKru9zXPGn3C0Uqu63t67Wm0WOnI7oC0KaJ+m+vC7SoF8V2Ivfar63o12bi3yl0wqQmmpEzuBedlT8xTNlYbCWf6ORBlnTSN4XxqduVQeUHHtdyrTXniLrelgvqB2L2KTXSHbHmDLqZ1R31CQEsW7kXJ0U8N8gaC4prD42cLmZJWyXD5BygKuWf0B9Vra1qS9iEfUFct/s8AE2KOhjBdHYnQMDm7RXao+iAxpjti2dO/SSF8Gp+43+gndZxQXzH3Kkk238EQmcgvDoHN;5:Jv8JfRdQ6wUV19fc4JEi2wex3v95MhWwbsmZiiYhT2qfaIlKf3ykhLhUPY4Se0FZdltZLwSqoh7P2nepE+vi+b/hzKEAY7XnUQ7NOomzWvxQ0G/NYQ0CPcoPj5xam9bzkZjQhrpTh1r+iEPJXVVjnlPewFstl3TKER9NqmOg7U0=;24:fxoZAFtPNJSwzPIf8VTwkw7uPW7JRC4dtNaPj9+yGT+IRdMYV0MuGjso3oGv91QEk9WPpK3G4jEAosCtfDBTKQYgqW5j9WqNQLUizygPdTk=;7:7jHwcrxICt5VWoadmlO36wb+MFX4Iawtzcpo3p1/pkp647Fnf3imRJk8qKLfO9lVCYf9ObA0dyIoRk4b/2gS6fW/pBtvisaq23zmWm/AW3S8Pj6AwOFEy6pSVCJAnYURHUuJYFrReLjup86edrpfwlW85SMmE5a9tSC2rUZbEKtWtuR3W8N9b76T5FsRcx2zwYX+P1brPw52y5sI+H9wvfByZLqu4WzbcevkJGA0iRoTY5BvoFBsxRXaHnuJHCAu x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: c7420488-a81e-4d52-8a89-08d56b303f0e x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:BL0PR2101MB1105; x-ms-traffictypediagnostic: BL0PR2101MB1105: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(58107921199556)(89211679590171)(130843839470238); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231101)(2400082)(944501161)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:BL0PR2101MB1105;BCL:0;PCL:0;RULEID:;SRVR:BL0PR2101MB1105; x-forefront-prvs: 05724A8921 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(396003)(39380400002)(39860400002)(346002)(376002)(199004)(189003)(6346003)(97736004)(6512007)(7736002)(26005)(305945005)(102836004)(105586002)(68736007)(5250100002)(8936002)(59450400001)(6486002)(6436002)(106356001)(6506007)(81166006)(81156014)(2501003)(2906002)(10090500001)(99286004)(66066001)(54906003)(6116002)(3846002)(36756003)(1076002)(8676002)(110136005)(575784001)(107886003)(72206003)(2950100002)(478600001)(10290500003)(22452003)(5660300001)(2900100001)(4326008)(25786009)(14454004)(316002)(86362001)(53936002)(3280700002)(186003)(3660700001)(76176011)(86612001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BL0PR2101MB1105;H:BL0PR2101MB1027.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: /wHXt3dwhwlGws7oMCxUXDVQweBrcZGyPug7YH7XiKBlRzbAazPWy9CD3IiO6eA5uuI5R0fDEORO65QNFRkYjA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: c7420488-a81e-4d52-8a89-08d56b303f0e X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Feb 2018 18:01:18.9253 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR2101MB1105 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gao Feng [ Upstream commit d02fd6e7d2933ede6478a15f9e4ce8a93845824e ] Because the macvlan_uninit would free the macvlan port, so there is one double free case in macvlan_common_newlink. When the macvlan port is just created, then register_netdevice or netdev_upper_dev_link failed and they would invoke macvlan_uninit. Then it would reach the macvlan_port_destroy which triggers the double free. Signed-off-by: Gao Feng Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/macvlan.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index fb1c9e095d0c..176fc0906bfe 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -1441,9 +1441,14 @@ int macvlan_common_newlink(struct net *src_net, stru= ct net_device *dev, return 0; =20 unregister_netdev: + /* macvlan_uninit would free the macvlan port */ unregister_netdevice(dev); + return err; destroy_macvlan_port: - if (create) + /* the macvlan port may be freed by macvlan_uninit when fail to register. + * so we destroy the macvlan port only when it's valid. + */ + if (create && macvlan_port_get_rtnl(dev)) macvlan_port_destroy(port->dev); return err; } --=20 2.11.0