Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3479697imu; Sun, 11 Nov 2018 16:03:30 -0800 (PST) X-Google-Smtp-Source: AJdET5cEw/7qhGQiMfB2bZl8gN3BGPq2nmPwzqQQGFxF0y4b9BT2qy7qQL6Mktye3BWAPdUMo4UY X-Received: by 2002:a62:302:: with SMTP id 2-v6mr18435487pfd.135.1541981010320; Sun, 11 Nov 2018 16:03:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981010; cv=none; d=google.com; s=arc-20160816; b=Rg4tWLMjNeJL3eJJ/4IUl2QtCh8w/sU977ItyAdahnT3kl8SDk8/NclSsm1hWlcKZr FVtsTyH5Rq0xfT/VtPtg6PoxuQMlRacpkSj8dutK+WCcjvKhYSrZxdhGxH+VCYzaFLtF WEdkMYb104sB+TQzzTHLitZbnV4UQl4WvBDYtMR/3ZlIsVdT/sVa6v9Xcuxjhj5Th2Gs G5VUmzQVoEcNgS9dhiZxur0RByLPPk5viUxWQChFKSUd4UuW4xmrvH+RMv2xqf8ncsuv Mq+TNUHvfGsSzZ/om7MtBbzendAn9z8w/snnskzPKBSgsvJJ+SdOQAdOatm46vkC5fqq kn+A== 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=I7H5ofV90wSiCB+Vp+BvXOl7pS9J4DJlvy80GxeOPks=; b=kD63556SsoLrbEVA5AoFG1O95otYJQZroMczuzFLhBGqvBzJrG7Qy1Di0yQDnaDBES 7dKxIQ5sXffnxQYACww1vq6ndWjE5upIjUzjMgDG8Rm3zUftsM5aAFwQDPOEtSECptRO 10Xxsjm01JN1td5azSH6BqoLUulhB7ya/3Sgt9OWKuDY6bxqusMrVFdeRdPyiQba46on w/x1mA+flo/NJt9iexMZhCROtd/TwuTx0+Dp6D2kqyLo54RCzYNXsSzDEWDMuLGzQ+hd XOsV1NfNmkH+/el6fkMKukzRCTlBueWlfjfB/Tqc+zrMYlDyZTNtXmch1O7a0UQ0Har/ MgNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tVHnEJFo; 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 t4-v6si16721626plb.237.2018.11.11.16.03.15; Sun, 11 Nov 2018 16:03:30 -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=tVHnEJFo; 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 S1732236AbeKLIR5 (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:35336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732213AbeKLIR4 (ORCPT ); Mon, 12 Nov 2018 03:17:56 -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 09CDA2154B; Sun, 11 Nov 2018 22:28:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975281; bh=v+8ILTYm08TldAlgfqxomvxdLa6oPXwSQ5DSPu8e0fc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tVHnEJFoleUXsNvCi5N47XOkXFBLIiAxx78+TJGZu0cqYNLpVke2XdY4VgHJFnaWi PogtR0nDlCWcq6J0c0+RcOXYODuC30Fh3gqCXJvdxwY/EdrD8nyxDzqZtcHVBDWjOe YpvcZHYwoyvvf2EU0fE9gRZlYKg6MMLY1gL9PAIU= 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.19 201/361] xen/blkfront: avoid NULL blkfront_info dereference on device removal Date: Sun, 11 Nov 2018 14:19:08 -0800 Message-Id: <20181111221648.571738035@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-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 @@ -2493,6 +2493,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);