Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4937508imd; Tue, 30 Oct 2018 09:32:01 -0700 (PDT) X-Google-Smtp-Source: AJdET5ex/vqr046qnVfwBfzoHI14xua7TQJBRfd4Ler4cSPoCD8abWkDH4EQ7XNyN4f+B4JHws5P X-Received: by 2002:a63:4c4e:: with SMTP id m14-v6mr18822521pgl.173.1540917121408; Tue, 30 Oct 2018 09:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540917121; cv=none; d=google.com; s=arc-20160816; b=AUp3tnl8RnDvUrydL+D38zQG2VLyulxwdQ66jaX7Bs/lAyClA55O+v5Fv12n2+vZW+ 2ARXhdfdFSTv/m5rwbrQPni3i4dd3FoN5inwCM+cbDVXL45C5muyjrJH4AFTi0bU1jnU tK89dYf5FAAFMUXttpqroinZSmNl7i8Xsh1YIwI4ssItWwbSlOLPgOJa8oM2yHcHEd4p GHgmvp4/QsTBknMVhLsWL2OdtC73dZDehv1DfKPzoHxjMAsgvg63HHx6ZbJgjUylo4x1 cxhRNvokUfM/Wo7upGJTsfyRL8/eST7SKKGO4OhP9cc87hBVqDuwze+g0CNR98l9127R kf2g== 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=RACsy7TlQ5ePWekmihqOWNZt6NL2kOPSYk0UbgDXCdc=; b=MqCnwzHsEYD2OXd3qgyd9Ugzksl10jN7SuXX251k3ka4Z1jUGHjseHTShCAVcCmJMj /6/ey+d9BR9MawLGZtKeO/ZmPxgoFhYBBLE8AVmLK63W/DGwEBiSOFlfNRl6JdsMV7GM 0Od1uEmzMgJJHsk4WyzKVOKe2vq2h1I8fX5iPjrE3pbhkY/52m6p2092kvFacaAZkagB IqU43nH/pi7FnZcQoBjV+dp/8wj54xCIcZh3zt1kP+JJD2whrIWhv/nOWoTLYXFH4XdJ eI0Rvq8wghDR3LqoFlE1EGgwKJlJYwWYN2dbXElzf3O8hYnDytputKBA6QS/m497sd5j 0Tnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=cvhqsfIB; 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.31.44; Tue, 30 Oct 2018 09:32:01 -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=cvhqsfIB; 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 S1727836AbeJaBXU (ORCPT + 99 others); Tue, 30 Oct 2018 21:23:20 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:41428 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727508AbeJaBXU (ORCPT ); Tue, 30 Oct 2018 21:23:20 -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 w9UGQ1qG055015; Tue, 30 Oct 2018 16:29:04 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=RACsy7TlQ5ePWekmihqOWNZt6NL2kOPSYk0UbgDXCdc=; b=cvhqsfIBD7p6EExXWGNh9fN5wi0GJF0P1+5KRcYx20rKvIOqXlPc/b29Vjf7DjWmiJ+1 6bEMLhJnPzoS0I2upxT6vUUEHv2SN3Hf0CJXZAq1Uabgfmz0ouJzhrsjXQ1qsv7B0qkR rlYnNoL4cWGBB9Thy6PLj89NU25Ra635DVC+nn7juaBPfpDcSOQP9sqmhocRmNcXKPhQ rYLc2bKCGfV8c/cYqGWVOIpAksdIndpS1s0ZWxr48z/RbSWUnFBInTrWB5mWvNkmf0dJ nWlNoz3PyXy9BRCTvhe7Ehy4HzuLJufa7bMjLb2fuQzAgl1DGrh9qREYED24UedEStF0 1Q== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2nducm26pk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Oct 2018 16:29:04 +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 w9UGT3Wr022025 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Oct 2018 16:29:03 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9UGT3xT029872; Tue, 30 Oct 2018 16:29:03 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:29:02 -0700 Subject: Re: [Xen-devel] [PATCH] xen-blkfront: fix kernel panic with negotiate_mq error path To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Cc: boris.ostrovsky@oracle.com, jgross@suse.com, konrad.wilk@oracle.com, 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> <20181030103956.hew7gifjvpjviw7u@mac.citrite.net> From: Manjunath Patil Organization: Oracle Corporation Message-ID: Date: Tue, 30 Oct 2018 09:29:02 -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: <20181030103956.hew7gifjvpjviw7u@mac.citrite.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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 On 10/30/2018 3:39 AM, Roger Pau Monné wrote: > On Mon, Oct 29, 2018 at 11:31:56AM -0700, 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" >> >> 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]); >> + } > I don't see the point in the if case here, you already fixed it by > setting the nr_rings value which I think it's the correct way of > fixing it. > > Thanks, Roger. Thank you Roger for your comments. I will exclude this change and send for review again. -Thanks, Manjunath