WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Avoid stack overflow in netback by statically allocating

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Avoid stack overflow in netback by statically allocating the
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sun, 14 Aug 2005 05:16:11 -0400
Delivery-date: Sun, 14 Aug 2005 09:16:45 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 3fe7b0b7f6c5ffde300b6518c50d6e05e84a4c10
# Parent  e03ffa8839abbfc59f6916f9d81c7b689f78e1a9
Avoid stack overflow in netback by statically allocating the
grant-table map/unmap arrays. Spotted by Michael Vrable.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r e03ffa8839ab -r 3fe7b0b7f6c5 
linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Sun Aug 14 
09:07:56 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Sun Aug 14 
09:17:54 2005
@@ -58,7 +58,9 @@
 static struct sk_buff_head rx_queue;
 static multicall_entry_t rx_mcl[NETIF_RX_RING_SIZE*2+1];
 static mmu_update_t rx_mmu[NETIF_RX_RING_SIZE];
-#ifndef CONFIG_XEN_NETDEV_GRANT_RX
+#ifdef CONFIG_XEN_NETDEV_GRANT_RX
+static gnttab_donate_t grant_rx_op[MAX_PENDING_REQS];
+#else
 static struct mmuext_op rx_mmuext[NETIF_RX_RING_SIZE];
 #endif
 static unsigned char rx_notify[NR_EVENT_CHANNELS];
@@ -90,11 +92,9 @@
 
 #ifdef CONFIG_XEN_NETDEV_GRANT_TX
 static u16 grant_tx_ref[MAX_PENDING_REQS];
-#endif
-#ifdef CONFIG_XEN_NETDEV_GRANT_RX
-static gnttab_donate_t grant_rx_op[MAX_PENDING_REQS];
-#endif
-#ifndef CONFIG_XEN_NETDEV_GRANT_TX
+static gnttab_unmap_grant_ref_t tx_unmap_ops[MAX_PENDING_REQS];
+static gnttab_map_grant_ref_t tx_map_ops[MAX_PENDING_REQS];
+#else
 static multicall_entry_t tx_mcl[MAX_PENDING_REQS];
 #endif
 
@@ -492,7 +492,6 @@
 inline static void net_tx_action_dealloc(void)
 {
 #ifdef CONFIG_XEN_NETDEV_GRANT_TX
-    gnttab_unmap_grant_ref_t unmap_ops[MAX_PENDING_REQS];
     gnttab_unmap_grant_ref_t *gop;
 #else
     multicall_entry_t *mcl;
@@ -508,8 +507,9 @@
     /*
      * Free up any grants we have finished using
      */
-    gop = unmap_ops;
-    while (dc != dp) {
+    gop = tx_unmap_ops;
+    while ( dc != dp )
+    {
         pending_idx = dealloc_ring[MASK_PEND_IDX(dc++)];
         gop->host_addr    = MMAP_VADDR(pending_idx);
         gop->dev_bus_addr = 0;
@@ -517,10 +517,8 @@
         grant_tx_ref[pending_idx] = GRANT_INVALID_REF;
         gop++;
     }
-    if (unlikely(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref,
-                                           unmap_ops, gop - unmap_ops))) {
-        BUG();
-    }
+    BUG_ON(HYPERVISOR_grant_table_op(
+        GNTTABOP_unmap_grant_ref, tx_unmap_ops, gop - tx_unmap_ops));
 #else
     mcl = tx_mcl;
     while ( dc != dp )
@@ -583,7 +581,6 @@
     u16 pending_idx;
     NETIF_RING_IDX i;
 #ifdef CONFIG_XEN_NETDEV_GRANT_TX
-    gnttab_map_grant_ref_t map_ops[MAX_PENDING_REQS];
     gnttab_map_grant_ref_t *mop;
 #else
     multicall_entry_t *mcl;
@@ -594,7 +591,7 @@
         net_tx_action_dealloc();
 
 #ifdef CONFIG_XEN_NETDEV_GRANT_TX
-    mop = map_ops;
+    mop = tx_map_ops;
 #else
     mcl = tx_mcl;
 #endif
@@ -722,7 +719,7 @@
         pending_cons++;
 
 #ifdef CONFIG_XEN_NETDEV_GRANT_TX
-        if ((mop - map_ops) >= ARRAY_SIZE(map_ops))
+        if ( (mop - tx_map_ops) >= ARRAY_SIZE(tx_map_ops) )
             break;
 #else
         /* Filled the batch queue? */
@@ -732,20 +729,18 @@
     }
 
 #ifdef CONFIG_XEN_NETDEV_GRANT_TX
-    if (mop == map_ops) {
+    if ( mop == tx_map_ops )
         return;
-    }
-    if (unlikely(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref,
-                                           map_ops, mop - map_ops))) {
-        BUG();
-    }
-    mop = map_ops;
+
+    BUG_ON(HYPERVISOR_grant_table_op(
+        GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops));
+
+    mop = tx_map_ops;
 #else
     if ( mcl == tx_mcl )
         return;
 
-    if ( unlikely(HYPERVISOR_multicall(tx_mcl, mcl - tx_mcl) != 0) )
-        BUG();
+    BUG_ON(HYPERVISOR_multicall(tx_mcl, mcl - tx_mcl) != 0);
 
     mcl = tx_mcl;
 #endif
@@ -757,7 +752,8 @@
 
         /* Check the remap error code. */
 #ifdef CONFIG_XEN_NETDEV_GRANT_TX
-        if (unlikely(mop->dev_bus_addr == 0)) {
+        if ( unlikely(mop->dev_bus_addr == 0) )
+        {
             printk(KERN_ALERT "#### netback grant fails\n");
             make_tx_response(netif, txreq.id, NETIF_RSP_ERROR);
             netif_put(netif);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Avoid stack overflow in netback by statically allocating the, Xen patchbot -unstable <=