Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2397143imm; Thu, 11 Oct 2018 09:35:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV614WwXDSj3fyBAW3Fu6988c+L4JNkfIGoHn/u9QhzaxUW4+48Sxsnig9HAv0S7Z8UiQKhhL X-Received: by 2002:a17:902:104:: with SMTP id 4-v6mr2258444plb.189.1539275729861; Thu, 11 Oct 2018 09:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539275729; cv=none; d=google.com; s=arc-20160816; b=i7pSfMxOlWlor5z48iBoZnr6S0I+ElGnGELcZW7eRYWol1I3+l7Se+1jACbR6Q9+Ir ih/MRD+Eo7xtT4Fo3n84hexHoA0qtk6ab2I1GhsQZvP8++18svjKS+EkVdcyHcbIwuxF BQuRQGg3FdXO21oGgqV6RpM+oH7nnS5x2ZeGhfu9WEHw+vj9Ise0BWMHWgvNuh6k7D15 G/Y8HW6Hg/5RYwwBYjRkfbdGUMSNGkOksD38vxVud5ikbVo5fe/1/eBk7AgmASVdMTRD TD098FVmi2wOE3EwCfEw/PJXtpXHlxb9EeDYjhUjfVF02f0HZvlDK8rH7jpoXYW1MS6x osMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=79363Dktw5Q0RQZs2RYodIywkIdUOUdLe/IE4skcZQc=; b=mYnxiZFuV1hGldkR6Q+/AcvEMKKGieDLR4t8pxIdlQT+R6xD8Nr4sfVvv/g8EPQtku ZSwkNdwHPkH9KfuQfz6kNYsAPy3LffDpdoI8zCa8v+WcWFq/nL6fYCBIrLoKpoJaQBEP GOcUIrP/s4adQSUp6iwhUISYeBKNhS2OEzBSOvAz6ZQsstyQ7NPqGpkRrbNAc1i5zhK+ fYT5NGeu51LQZUwxp3s/XiCZMVeNCHhFT5v+wLq4/D6skqq1c8sBsX4pMNdfZ3obAJyL SJG9fzFHuCpk6wurzaHYdyy2dbypIGL0xy+GC96TJJu+Lai09WP1xwi7ClnZoDUtrVup HkTw== 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 12-v6si29141355pfb.268.2018.10.11.09.35.08; Thu, 11 Oct 2018 09:35:29 -0700 (PDT) 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 S1729961AbeJLACe (ORCPT + 99 others); Thu, 11 Oct 2018 20:02:34 -0400 Received: from smtp.ctxuk.citrix.com ([185.25.65.24]:55311 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727990AbeJLACe (ORCPT ); Thu, 11 Oct 2018 20:02:34 -0400 X-IronPort-AV: E=Sophos;i="5.54,369,1534809600"; d="scan'208";a="80324648" Date: Thu, 11 Oct 2018 18:34:27 +0200 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Vasilis Liaskovitis CC: , , , , , , Subject: Re: [Xen-devel] [PATCH] xen/blkfront: avoid NULL blkfront_info dereference on device removal Message-ID: <20181011163427.ilpsl4hxb2y3hcfp@mac.bytemobile.com> References: <20181011162000.19191-1-vliaskovitis@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20181011162000.19191-1-vliaskovitis@suse.com> User-Agent: NeoMutt/20180716 X-ClientProxiedBy: AMSPEX02CAS01.citrite.net (10.69.22.112) To AMSPEX02CL02.citrite.net (10.69.22.126) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 11, 2018 at 06:20:00PM +0200, Vasilis Liaskovitis wrote: > 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. > > Signed-off-by: Vasilis Liaskovitis > --- > drivers/block/xen-blkfront.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c > index 429d20131c7e..92cc6cb6b078 100644 > --- a/drivers/block/xen-blkfront.c > +++ b/drivers/block/xen-blkfront.c > @@ -2493,6 +2493,9 @@ static int blkfront_remove(struct xenbus_device *xbdev) > > dev_dbg(&xbdev->dev, "%s removed", xbdev->nodename); > > + if (!info) > + goto out; I don't see the point in adding the 'out' label. Can you just return 0 here? Thanks, Roger.