Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3432772imu; Sun, 11 Nov 2018 15:00:27 -0800 (PST) X-Google-Smtp-Source: AJdET5fohia2ScNIzPCiM2ZqBUddkmZshYgoLmT1xCCcboYMqX8W+FuSLJFcMnoK8ygLn/etL2ON X-Received: by 2002:a62:ed09:: with SMTP id u9-v6mr13498928pfh.188.1541977227013; Sun, 11 Nov 2018 15:00:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977226; cv=none; d=google.com; s=arc-20160816; b=FOR5D6U3QiP7mIjT/2MP4KXqCD87st7BDBFfMB637OA3eKTrm1Sgj1fHJcf26csQc9 SpAkZ+LWMixTLCLHxOggVl++3Y9Fb7ki3NIHYDHX5pCbGtSQOADOtk7ZqnCks0KDzJWT BQ9uDXcvdxW8Nxs4oRXQbQ/XlW6JS8m6Pt3ijLt11paMWNXbvdxx0J4KtK7VtEdQursp Pfsqt3BY+BdNy7cP2BuHDZOmgeJzraFE7IRFDkuIq7WOqtvxvWqueJ6QBv8u/ZfSjenk EDZ3p4RdG8p45l9BT+tQkJkU6bzd35l4Z7B0PN4Lqu43WDDAtW2x65qvT39ZyADFzUsD t25A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mlUKvbD4GrrlTOnnq19p14uouyCS26uHT5s9Eil2Q5A=; b=gv4ukxLsjgpKEpujwHmdZbSQsQhx4TWQumdwvIK9p43nbM01yqbQmBMEcDObcmA0ew SZ90AjVxTTQnw8yjTQ2jroBUSplg3kiC3As0HimuMSSNKW0a4pSvjQOSJNDNvGw4DJ4b 52NmVpf6YzXwmK3I5gPRkAz1d7lurvbh1IkJKp3KxeERzG9oAWOkla4AntBfG4TmG/IO IkuDV4dnFsLAVID10aWsLVy+vV/65aNSjoRw/DYW8JtwG859rguximtQmXiq1zkb/hP6 Jyv+Ifn4PK3RyEsIxiqeob9olYTWtayskErAHPoXnYnkMp+NwwnEezNkJQQQJ0hR87gw n0Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OwSoQ9vj; 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 m38si14855363pgl.125.2018.11.11.15.00.11; Sun, 11 Nov 2018 15:00:26 -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=@kernel.org header.s=default header.b=OwSoQ9vj; 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 S2390768AbeKLIWh (ORCPT + 99 others); Mon, 12 Nov 2018 03:22:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:51200 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390750AbeKLIWg (ORCPT ); Mon, 12 Nov 2018 03:22:36 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4CA04223C7; Sun, 11 Nov 2018 22:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975559; bh=RPPR5cxMLhs1+NGEsvBR8HWO2nmSG7YejkUeY6aH4J0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OwSoQ9vjUlaVnoUpZw3FlnKU1ONz5eZJpQZcq7Gn+f1RQSfECrnntizyF4/QrsQ7x VtwxuoDTtVeEvKw1m++faIeh/aJZOUzZOvOvx5AgR07OOdYP6S8IxOKGGEBQXEistT J7WBG6Pg2PUkvVpzOXtA0tWQIqiz8RbQcE3nr5Ro= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vasilis Liaskovitis , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Konrad Rzeszutek Wilk , Jens Axboe Subject: [PATCH 4.14 118/222] xen/blkfront: avoid NULL blkfront_info dereference on device removal Date: Sun, 11 Nov 2018 14:23:35 -0800 Message-Id: <20181111221658.273653692@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vasilis Liaskovitis commit f92898e7f32e3533bfd95be174044bc349d416ca upstream. If a block device is hot-added when we are out of grants, gnttab_grant_foreign_access fails with -ENOSPC (log message "28 granting access to ring page") in this code path: talk_to_blkback -> setup_blkring -> xenbus_grant_ring -> gnttab_grant_foreign_access and the failing path in talk_to_blkback sets the driver_data to NULL: destroy_blkring: blkif_free(info, 0); mutex_lock(&blkfront_mutex); free_info(info); mutex_unlock(&blkfront_mutex); dev_set_drvdata(&dev->dev, NULL); This results in a NULL pointer BUG when blkfront_remove and blkif_free try to access the failing device's NULL struct blkfront_info. Cc: stable@vger.kernel.org # 4.5 and later Signed-off-by: Vasilis Liaskovitis Reviewed-by: Roger Pau Monné Signed-off-by: Konrad Rzeszutek Wilk Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/block/xen-blkfront.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -2471,6 +2471,9 @@ static int blkfront_remove(struct xenbus dev_dbg(&xbdev->dev, "%s removed", xbdev->nodename); + if (!info) + return 0; + blkif_free(info, 0); mutex_lock(&info->mutex);