Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp160776imu; Thu, 8 Nov 2018 16:58:18 -0800 (PST) X-Google-Smtp-Source: AJdET5c+Tm5qYjeJON5Cj1ND7JyJW5Ai8vTw9lJIvm5VrhAHdkyn7j9FiIcivGBNVNxCAxXhneBS X-Received: by 2002:a62:8208:: with SMTP id w8-v6mr6805756pfd.150.1541725098542; Thu, 08 Nov 2018 16:58:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541725098; cv=none; d=google.com; s=arc-20160816; b=BHohZ3UfsM4yYNqwsCs8AJehWYQ0PViHdyZeh00ikJWbScXn9f1UHf58EyTTIIZ6tQ 23fEb20bkJpHfo8Brb0FtKuRmnMfosqnV+DRyrGIiEh37+PZ/y8JpclNBHHYNz5hc8ik PW8ql0kN67EygjC7RtAb4xIVgPtLxNZJ8svPJxaX+H5nv9GRQ2YiXs/XcRs3kxmkC3C5 fcUgTGNxEG+pk9N6tOuIOvpfNA+eGpLp5891rAArcnEKhkLrqj/zvAe27tmQeCKbT8QX EMwAQ8g/MiXXIY/2EjZ3avs9NqRHhH01pxu+ruQCshdMBKY/ZfjvXPRCb06TNJHG0AKq CnJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=/2BNUnFbMg/HjW7Ya1+jphrhLq+2HXSFK1Ttd7Ct9C0=; b=IZqRBQhsrkYiNn/IEz97/NGAA9B+Fq1FC/6lu/IJNbtwYeenhniPLC/vBS3En0/Pex Tc+v3XKYXZMQ9lbeEAWjq/P99KZ/N9QlbT5Pxxv/KYD/LiuvSRVtI9ps7oUmeM4iYtKz a1I5K/pB3TJNMfH29ZQn6sDfMyUOgRZ+MqMYT6UCw7noRadUKroWusM43417ikU7ul0o lTlot+r6OyX3bwScJuOaLa7eL4VzCt7j8yKXFcZQVms1gbUlRX1fe0iYQ6cpIRzqUczA aN/DLUgC1WZieCJKaZJ8FWsdMLVDHmG+fR84kEV8uHxvg5NF70irt+rMeV7RBjqw/6Z9 A6Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=3zpXw2nc; 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=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o10-v6si5785133plk.295.2018.11.08.16.58.02; Thu, 08 Nov 2018 16:58:18 -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=@oracle.com header.s=corp-2018-07-02 header.b=3zpXw2nc; 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=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727667AbeKIKft (ORCPT + 99 others); Fri, 9 Nov 2018 05:35:49 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:48114 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727447AbeKIKfs (ORCPT ); Fri, 9 Nov 2018 05:35:48 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA90rpe9184122; Fri, 9 Nov 2018 00:57:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=/2BNUnFbMg/HjW7Ya1+jphrhLq+2HXSFK1Ttd7Ct9C0=; b=3zpXw2ncwmg2P4QQjaqvmvFdOFR2aCs84kKeLKAFORuB/QW1i2oKujm7nWpdDf9UQfML GYGNvRC2YOykSm5MaDq0r6I4Mf5JCA+bWXcHk1RNqHMx9hyWUFYMZBjoBavJXgzTnQO4 1qxqf04tfwjuthAtuSJIYdtDjIm4T0tFaTq7RNv0Ahim4VtjKjRUhglEycSy2HXdU3EX OCry2H0NywVF5CwJkR0Pk0et17Ztyn99/djv+PhWY3iwovGBOi2aQcVhtYip13LfgPys 5z89x1nNOp7sXQxDHdODJ7m8dMgvLY1OF5JsgTl0aEX551A7eK2LVqph4OWFiZmfBkX2 tg== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2nh3mq4k8m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 09 Nov 2018 00:57:30 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wA90vU90007463 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Nov 2018 00:57:30 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wA90vUii030609; Fri, 9 Nov 2018 00:57:30 GMT Received: from manjunathpatil.us.oracle.com (/10.211.44.52) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 08 Nov 2018 16:57:29 -0800 From: Manjunath Patil To: boris.ostrovsky@oracle.com, jgross@suse.com, konrad.wilk@oracle.com, roger.pau@citrix.com Cc: axboe@kernel.dk, xen-devel@lists.xenproject.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] xen-blkfront: fix kernel panic with blkfront_remove() Date: Thu, 8 Nov 2018 16:58:28 -0800 Message-Id: <1541725108-1468-1-git-send-email-manjunath.b.patil@oracle.com> X-Mailer: git-send-email 1.7.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9071 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=884 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1811090007 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a hot-attaching device fails inside domU[ex:negotiate_mq() returns with ENOMEM] we clear the blkfront_info struct in talk_to_blkback() When we try to detach the device, blkfront_remove() tries to access blkfront_info leading to kernel panic. Typical call stack involving panic - #10 page_fault at ffffffff816f25df [exception RIP: blkif_free+46] #11 blkfront_remove at ffffffffa004de47 [xen_blkfront] #12 xenbus_dev_remove at ffffffff813faa4c #13 __device_release_driver at ffffffff814769aa #14 device_release_driver at ffffffff81476a63 #15 bus_remove_device at ffffffff814762eb #16 device_del at ffffffff81472684 #17 device_unregister at ffffffff814727e2 #18 xenbus_dev_changed at ffffffff813fa89f #19 frontend_changed at ffffffff813fca19 #20 xenwatch_thread at ffffffff813f88f9 #21 kthread at ffffffff810a486b #22 ret_from_fork at ffffffff816ed2a8 Cc: stable@vger.kernel.org Signed-off-by: Manjunath Patil --- drivers/block/xen-blkfront.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index dc8fe25..144cda8 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -2496,6 +2496,9 @@ static int blkfront_remove(struct xenbus_device *xbdev) dev_dbg(&xbdev->dev, "%s removed", xbdev->nodename); + if(!info) + return 0; + blkif_free(info, 0); mutex_lock(&info->mutex); -- 1.7.1