Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp3737146imd; Mon, 29 Oct 2018 11:32:08 -0700 (PDT) X-Google-Smtp-Source: AJdET5eIarkldUa5K435KK7COmIAJ78+hml71buvOyc9dbAWX4uPSKhE1lgHKP2tYxGioaVIToRI X-Received: by 2002:a63:1765:: with SMTP id 37-v6mr15060184pgx.131.1540837928849; Mon, 29 Oct 2018 11:32:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540837928; cv=none; d=google.com; s=arc-20160816; b=j1u+qIUMJD+SUv01JbAEtZ4dXtn4Ltx/wmbXQYAYaR+IYbkYwbjBgEikNkdSpALHOD lanv8NxM0DDdatzEstV6XR0d9lUt3/HcrEY2GqqPQSxMo5u1fUcIrTGcvSjwuo+mLHMu FM6m6AMzKNFdQLtAXRsHpfDLLcMfVAtdn47U2xCzB+9IRw40sRHdPLFvSY+1fF4E4BG5 mnmX1i5TM9slqj/a/UMpVKOJxMvGa/GKZLa2RAMXg0Uv7mDqnV/E4Igc5TDKCE3XcJo/ SPL/fYmFanBirVx3jkXWKA8aRw6XNp7dqWcCDi/k8kSmrTvyMA+n2LKMVw1C3OJyCIeb gZcw== 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=uNEck6VbFQCDRibMcVbe76S46tF3WmTBMeYcqITmZQA=; b=v7rgeh3gIWlttCsvrESJdVw3QRtv+2ij5AY0ttnOOu4Z//Pxp0kI/cXku1THFvM9Fv 2LPw29oFMl/6krLkIsLJImpLTUDarPOWPmnFgoGaiK6bdRpPXGmoL2ph32wRn9LwnIw+ E+2p70El2n8QfNzdKNUdSz0bDDTdbF3KM1JVYWLHiCbH2baRwDYTOTbaKyMcAqSkh4Ng JhKmEMoxibj+heLD7PMijVIljVG6u54u9x3RSPZcgILBG3aRb0LG8JfLuBpfdWZo3dMp FGT6Fy2H+QlloFg1urWauhAzzftnzOatDIRp4J8uqF55EqAvDk5KOXk7sWMmv7iNYEP0 QnPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=YLsfM72Q; 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 l11-v6si6203985pls.340.2018.10.29.11.31.53; Mon, 29 Oct 2018 11:32:08 -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; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=YLsfM72Q; 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 S1729389AbeJ3DVN (ORCPT + 99 others); Mon, 29 Oct 2018 23:21:13 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:44886 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726852AbeJ3DVM (ORCPT ); Mon, 29 Oct 2018 23:21:12 -0400 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 w9TIT8kC157990; Mon, 29 Oct 2018 18:31:07 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=uNEck6VbFQCDRibMcVbe76S46tF3WmTBMeYcqITmZQA=; b=YLsfM72Qf8Okz1Gi2rWIOcbO0OXd7Cxr7J1Q3NxRwa9Ymei1o65MmSzGhvVCURX4YNhI RpjPQnOrAI4qnBmHCdVcujeloqCDLyYvHBsiRepvsopiaAubmsWEMD1JpbFyheNNJct0 r8H0AgHcMjk3yqGMyCPyJTGyu2kOhRMa9S1C4PP5eHXB54tSCrVK2qGjiVl0pSVgFagL 6YENmDUxAZ+sML3NQOs4skprYwVEaEu1u16DZFODaxcncQ1uABjiCABtI5gA2qo/brdZ 3UcdHXyG8SJ+qBgv/CIT8cI6UdAYV5Kx/FJViD2Hu2aLMg46aRqYteprORvYI00K4PME Gw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2ncfypqj1v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Oct 2018 18:31:07 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9TIV26c006366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Oct 2018 18:31:02 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9TIV2Q0028022; Mon, 29 Oct 2018 18:31:02 GMT Received: from manjunathpatil.us.oracle.com (/10.211.44.52) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 29 Oct 2018 11:31:01 -0700 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 Subject: [PATCH] xen-blkfront: fix kernel panic with negotiate_mq error path Date: Mon, 29 Oct 2018 11:31:56 -0700 Message-Id: <1540837916-14356-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=9061 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810290168 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org info->nr_rings isn't adjusted in case of ENOMEM error from negotiate_mq(). This leads to kernel panic in error path. Typical call stack involving panic - #8 page_fault at ffffffff8175936f [exception RIP: blkif_free_ring+33] RIP: ffffffffa0149491 RSP: ffff8804f7673c08 RFLAGS: 00010292 ... #9 blkif_free at ffffffffa0149aaa [xen_blkfront] #10 talk_to_blkback at ffffffffa014c8cd [xen_blkfront] #11 blkback_changed at ffffffffa014ea8b [xen_blkfront] #12 xenbus_otherend_changed at ffffffff81424670 #13 backend_changed at ffffffff81426dc3 #14 xenwatch_thread at ffffffff81422f29 #15 kthread at ffffffff810abe6a #16 ret_from_fork at ffffffff81754078 Though either of my changes avoid the panic, I included both the changes. This issue got introduced with "7ed8ce1 xen-blkfront: move negotiate_mq to cover all cases of new VBDs" Signed-off-by: Manjunath Patil --- drivers/block/xen-blkfront.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 429d201..dc8fe25 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -1350,8 +1350,10 @@ static void blkif_free(struct blkfront_info *info, int suspend) if (info->rq) blk_mq_stop_hw_queues(info->rq); - for (i = 0; i < info->nr_rings; i++) - blkif_free_ring(&info->rinfo[i]); + if (info->rinfo) { + for (i = 0; i < info->nr_rings; i++) + blkif_free_ring(&info->rinfo[i]); + } kfree(info->rinfo); info->rinfo = NULL; @@ -1919,6 +1921,7 @@ static int negotiate_mq(struct blkfront_info *info) GFP_KERNEL); if (!info->rinfo) { xenbus_dev_fatal(info->xbdev, -ENOMEM, "allocating ring_info structure"); + info->nr_rings = 0; return -ENOMEM; } -- 1.7.1