Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4933985imd; Tue, 30 Oct 2018 09:28:55 -0700 (PDT) X-Google-Smtp-Source: AJdET5ejU7BiYHUeZy3Rvx2Ox27gFfbrK9mceuUey1lIbPvOBF7oegyqvWNMLhPKwn3ZFggOplSH X-Received: by 2002:a17:902:6bc9:: with SMTP id m9-v6mr19720993plt.106.1540916935214; Tue, 30 Oct 2018 09:28:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540916935; cv=none; d=google.com; s=arc-20160816; b=pIsKq10CSNb3ctLKhX0bwffpfUnLWrC3uecz/HP/Av5YGh6SbDLNT2Qv9sGM83Bk1k GBsmYD03nETtMo1OBHqnCvaI39i3SNAuEvk8oDr6U5ATZEervvd0RDircRvamKsOWxuS gSNHGcIbBsHehtAFMHUuOYvqKS8jfjf+3kR2SiHbsfbEXvFILCKeMegM+sVtxnJZvyyf tQYL2LRwJ0muv3h8eODa84D4FXGtX90jlDPucwSKZkJcFusXSn3dJdu6QQgBtjcJd4FR n3c+69cXUDNGps1mPdbIQoLwLicayjHgKeYtHxZp2GUNDuRmLaBmPLQAFXo2BLqvIn+E TK3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=SM7mBkCODtz4FAhzP8nKJCqWAmrCM/Nl3VpN4x3IKfg=; b=RDTExUWVig7f3Sya4gUEV3z6bQ6JTt7fOjYUqog3CpHZI2bg6OCObJGkKDydx4O4C/ bRIEuTeUheqSdzuK0x7qP6Z7t5s56xEzOBB0xxJsjVS1c65l6/BBBOuLuz5NJL1Wfmav J4NRfmafHp/QEfZOd7BkIDe8eMLrlv4FPDbkP1YU1FSpwD0gV+QoVA8R8/eqBxbR9hGy /5R84Vmx7ALMK88DdY6/7us08LsE4ED+mG9c6lEXQXNBLJHeZXcKAuOwhtcoNCiQCNgs W9REd7Q1poE2n2bTR4R6EuSof5wmrK7fgBxVuj3j2aZ26jnqFNsFa56Bre5S4/PoVbhz MrPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=oDK6xB3B; 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 h1-v6si23722194pgs.493.2018.10.30.09.28.39; Tue, 30 Oct 2018 09:28:55 -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=oDK6xB3B; 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 S1727751AbeJaBWH (ORCPT + 99 others); Tue, 30 Oct 2018 21:22:07 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:40202 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbeJaBWG (ORCPT ); Tue, 30 Oct 2018 21:22:06 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9UGQBmP055112; Tue, 30 Oct 2018 16:27:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=SM7mBkCODtz4FAhzP8nKJCqWAmrCM/Nl3VpN4x3IKfg=; b=oDK6xB3BGSiilZDq7q4BX1rtquy8nHJ89yOGuGtObV+PxKiimbh+70e2Oxvy0OUzXAUb /qCtIiIWAx4dwWM0nZEclges4OqTNq+FcGrcs8IRH2PPHhO8hkbhzd5n8ZckUqMmqKaw RiATVstsTuW4PVBdBuqlv7BjACyRZgPaXGGoFj+hnU1Fdn/kj+UbZkvx/+GH0RzLU9te nEtLF1hpLoNvZ3nFXnhzqS/Kt1CkCRQO9hhMqhj7zH1mjiBmgAhby5RqnIZ13lV6O9Vv M/EcgBtfo9dwbg+hOSbLRkUvvnAks1HfqS+asRkW5pk1F3SmVYvGHFz6xojS0miHaLpI JQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2nducm26ed-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Oct 2018 16:27:46 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9UGRj1X003460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Oct 2018 16:27:45 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9UGRjwm029126; Tue, 30 Oct 2018 16:27:45 GMT Received: from [10.211.46.57] (/10.211.46.57) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 30 Oct 2018 09:27:45 -0700 Subject: Re: [Xen-devel] [PATCH] xen-blkfront: fix kernel panic with negotiate_mq error path To: Juergen Gross , boris.ostrovsky@oracle.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 References: <1540837916-14356-1-git-send-email-manjunath.b.patil@oracle.com> <65b5d648-d9dc-9248-751c-b6e15109b52e@suse.com> From: Manjunath Patil Organization: Oracle Corporation Message-ID: Date: Tue, 30 Oct 2018 09:27:43 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <65b5d648-d9dc-9248-751c-b6e15109b52e@suse.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9062 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-1810300139 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thank you Juergen for your comments. I will soon send v2 patch. -Thanks, Manjunath On 10/30/2018 12:04 AM, Juergen Gross wrote: > On 29/10/2018 19:31, Manjunath Patil wrote: >> 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" > Please us the correct format for specifying another commit. > >> Signed-off-by: Manjunath Patil > Can you please add a "Fixes:" tag and "Cc: stable@vger.kernel.org" ? > >> --- >> 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]); >> + } > I'd drop this change. > >> >> 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; >> } > > Juergen >