Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3335818imu; Sun, 11 Nov 2018 12:38:45 -0800 (PST) X-Google-Smtp-Source: AJdET5d0nIn00MaV9RPjS9lmvju02v3ATuoUB5uEwRVEvCsUwN93CfmoBbdO9XRwszq+oERhxelI X-Received: by 2002:a17:902:3064:: with SMTP id u91-v6mr17302576plb.164.1541968725339; Sun, 11 Nov 2018 12:38:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541968725; cv=none; d=google.com; s=arc-20160816; b=te7isLl2IjDlrCwwugkeUY31BH9+aW1fdYVoRD8lP2atFA+sMUof+mlMwCRCv8UVfb qcFTOKpDDqtrrCEsGdaHODLAnlTN86/d6VMvE2heSj46zwG76rDZsTtuV0g+CpIR/KkJ GOT9WhfyJ8BClskeOYNsdzswE79Y6PZ5ZHB++YdToiFraQtl8ftqDmwuN85Y1uzwzuXF Gq79iSrOTKl63i2TNrzq3IopwsidFFEskbM6vN2TyiwQMddLe8tj8a9CcEW0kRTqRflX xzTt6Qp7zoj2r4hTlnA9nLViXLRW67pu4svgLzO/nWKV8VtasWCfrRdCNlmNyaDljtkz Ug7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=8ktN8eFVIGx47l0fDIh8fbJQ82S4Ifq+yqwDXN022TA=; b=gJ5ZdlU/xKGJZb3pv0vsOdOlDMgu8CGa0KjACCsPP6GrjLe6iJ9dG8+HuYFVcK9TvR PKl9faigsB/P3L0ckHhkNnKRGuEAts26mrb5xoxsQM14BksGakPooZ89tncp77s2HeGe z9E1uHfKORZcuJ89XoRXbgsdt61TmVTRrniQO2Ox36MVhd2tPShrFurcWEQ8HDZs7Vnn omMmcG91KkbmmDsj6IMzCmT7rpg0ZiAoGoGWLX0wLBUs7E383k0NK6vCbVh9JgNxSeW3 UjEUYsLoPLUB67mm9/awQlcckEyYzMRDnGU9B3VcxaaEL516QZonafFocp9o5JIeBCue eikw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y207-v6si15984863pfb.59.2018.11.11.12.38.30; Sun, 11 Nov 2018 12:38:45 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730299AbeKLG0W (ORCPT + 99 others); Mon, 12 Nov 2018 01:26:22 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:49710 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730069AbeKLFsL (ORCPT ); Mon, 12 Nov 2018 00:48:11 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsW-0000lG-CS; Sun, 11 Nov 2018 19:58:40 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsT-0001b4-6I; Sun, 11 Nov 2018 19:58:37 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "David Vrabel" , "David S. Miller" , "Boris Ostrovsky" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 167/366] xen-netfront: properly destroy queues when removing device In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: David Vrabel commit ad0681185770716523c81b156c44b9804d7b8ed2 upstream. xennet_remove() freed the queues before freeing the netdevice which results in a use-after-free when free_netdev() tries to delete the napi instances that have already been freed. Fix this by fully destroy the queues (which includes deleting the napi instances) before freeing the netdevice. Signed-off-by: David Vrabel Reviewed-by: Boris Ostrovsky Signed-off-by: David S. Miller [bwh: Backported to 3.16: I already backported most of this along with the later commit 74470954857c "xen-netfront: Delete rx_refill_timer in xennet_disconnect_backend()"; don't move the del_timer_sync() again.] Signed-off-by: Ben Hutchings --- --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -2294,7 +2294,6 @@ static const struct xenbus_device_id net static int xennet_remove(struct xenbus_device *dev) { struct netfront_info *info = dev_get_drvdata(&dev->dev); - unsigned int num_queues = info->netdev->real_num_tx_queues; dev_dbg(&dev->dev, "%s\n", dev->nodename); @@ -2302,11 +2301,7 @@ static int xennet_remove(struct xenbus_d unregister_netdev(info->netdev); - if (num_queues) { - kfree(info->queues); - info->queues = NULL; - } - + xennet_destroy_queues(info); xennet_free_netdev(info->netdev); return 0;