From patchwork Mon Oct 31 05:38:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongli Zhang X-Patchwork-Id: 9405023 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C686260585 for ; Mon, 31 Oct 2016 05:42:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B65BB2897B for ; Mon, 31 Oct 2016 05:42:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A953A28B06; Mon, 31 Oct 2016 05:42:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 39CE82897B for ; Mon, 31 Oct 2016 05:42:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c15KG-000448-FR; Mon, 31 Oct 2016 05:40:04 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c15KF-0003we-ND for xen-devel@lists.xenproject.org; Mon, 31 Oct 2016 05:40:03 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id D0/D2-09407-239D6185; Mon, 31 Oct 2016 05:40:02 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrILMWRWlGSWpSXmKPExsXSO6nOVdfwpli EQf9pG4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNWP5nw2sBfe4KiYcu83ewLiZs4uRi0NIoINJ 4v7PdUwQzjdGiT//37FBOBsYJb7tuweV6WaUuHq/g6WLkZODTUBHYtqBU2C2iECCxKv/r1lBb GYBD4kVN48zgdjCAiESR3pegsVZBFQl9v0+yg5i8wq4SZy4PJkZxJYQkJO4ea4TyjaW6JvVxz KBkWcBI8MqRo3i1KKy1CJdIzO9pKLM9IyS3MTMHF1DA1O93NTi4sT01JzEpGK95PzcTYxA79c zMDDuYLw92e8QoyQHk5Io735H0QghvqT8lMqMxOKM+KLSnNTiQ4waHBwCfWtWX2CUYsnLz0tV kuA1uyEWISRYlJqeWpGWmQMMT5hSCQ4eJRFeYZA0b3FBYm5xZjpE6hSjopQ479/rQAkBkERGa R5cGywmLjHKSgnzMjIwMAjxFKQW5WaWoMq/YhTnYFQS5n0EMoUnM68EbvoroMVMQIvTCkVAFp ckIqSkGhhVy/+F3enPYMvz3LHm7G6ezR/UGV29Mtqmttrt5zRauSJ1boSDgfan4zOZe4MkK1r yp65xj/7veP3HYjbGe7/WnTWOP+PQMPPaZtWUxcJSs9KeyvS9v7F7/9F/v81Lp06ZIdz2Rann n+a9dyUSVsu3JR56/jjjrcbKFq4HMsFuvxTjTMSyOWcrsRRnJBpqMRcVJwIAJrHO2YQCAAA= X-Env-Sender: dongli.zhang@oracle.com X-Msg-Ref: server-8.tower-206.messagelabs.com!1477892400!67458161!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 9.0.13; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12767 invoked from network); 31 Oct 2016 05:40:01 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-8.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 31 Oct 2016 05:40:01 -0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u9V5dvDM002432 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 31 Oct 2016 05:39:57 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u9V5dv0v022428 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 31 Oct 2016 05:39:57 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u9V5dspi018652; Mon, 31 Oct 2016 05:39:55 GMT Received: from linux.cn.oracle.com (/10.182.70.252) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 30 Oct 2016 22:39:54 -0700 From: Dongli Zhang To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, netdev@vger.kernel.org Date: Mon, 31 Oct 2016 13:38:29 +0800 Message-Id: <1477892309-7150-1-git-send-email-dongli.zhang@oracle.com> X-Mailer: git-send-email 2.7.4 X-Source-IP: aserv0021.oracle.com [141.146.126.233] Cc: jgross@suse.com, boris.ostrovsky@oracle.com, david.vrabel@citrix.com Subject: [Xen-devel] [PATCH 1/1] xen-netfront: do not cast grant table reference to signed short X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP While grant reference is of type uint32_t, xen-netfront erroneously casts it to signed short in BUG_ON(). This would lead to the xen domU panic during boot-up or migration when it is attached with lots of paravirtual devices. Signed-off-by: Dongli Zhang --- drivers/net/xen-netfront.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index e17879d..189a28d 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -304,7 +304,7 @@ static void xennet_alloc_rx_buffers(struct netfront_queue *queue) queue->rx_skbs[id] = skb; ref = gnttab_claim_grant_reference(&queue->gref_rx_head); - BUG_ON((signed short)ref < 0); + WARN_ON_ONCE(IS_ERR_VALUE((unsigned long)ref)); queue->grant_rx_ref[id] = ref; page = skb_frag_page(&skb_shinfo(skb)->frags[0]); @@ -428,7 +428,7 @@ static void xennet_tx_setup_grant(unsigned long gfn, unsigned int offset, id = get_id_from_freelist(&queue->tx_skb_freelist, queue->tx_skbs); tx = RING_GET_REQUEST(&queue->tx, queue->tx.req_prod_pvt++); ref = gnttab_claim_grant_reference(&queue->gref_tx_head); - BUG_ON((signed short)ref < 0); + WARN_ON_ONCE(IS_ERR_VALUE((unsigned long)ref)); gnttab_grant_foreign_access_ref(ref, queue->info->xbdev->otherend_id, gfn, GNTMAP_readonly);