summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@joyent.com>2011-12-23 14:29:49 -0500
committerRobert Mustacchi <rm@joyent.com>2011-12-23 14:29:49 -0500
commite2ea9c96cc52f45e2bd0daa0d68b4b602819cf1f (patch)
tree6cf6b910701fb12c4a5a9c96e228ab7f1c4033ad
parent7f2dc2cf1a1245bdd505d658a1dbcbda218daed1 (diff)
downloadillumos-joyent-e2ea9c96cc52f45e2bd0daa0d68b4b602819cf1f.tar.gz
1925 stack overflow from mac code
Reviewed by: Dan McDonald <danmcd@nexenta.com> Reviewed by: Michael Speer <michael.speer@pluribusnetworks.com> Reviewed by: Gordon Ross <gordon.w.ross@gmail.com> Reviewed by: Garrett D'Amore <garrett@damore.org> Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r--usr/src/uts/common/io/mac/mac_sched.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/usr/src/uts/common/io/mac/mac_sched.c b/usr/src/uts/common/io/mac/mac_sched.c
index 9e1b2b0a55..38967e5d15 100644
--- a/usr/src/uts/common/io/mac/mac_sched.c
+++ b/usr/src/uts/common/io/mac/mac_sched.c
@@ -22,6 +22,9 @@
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2011 Joyent, Inc. All rights reserved.
+ */
#include <sys/types.h>
#include <sys/callb.h>
@@ -29,6 +32,8 @@
#include <sys/strsubr.h>
#include <sys/strsun.h>
#include <sys/vlan.h>
+#include <sys/stack.h>
+#include <sys/archsystm.h>
#include <inet/ipsec_impl.h>
#include <inet/ip_impl.h>
#include <inet/sadb.h>
@@ -415,6 +420,28 @@ int mac_srs_worker_wakeup_ticks = 0;
}
/*
+ * MAC_RX_SRS_TOODEEP
+ *
+ * Macro called as part of receive-side processing to determine if handling
+ * can occur in situ (in the interrupt thread) or if it should be left to a
+ * worker thread. Note that the constant used to make this determination is
+ * not entirely made-up, and is a result of some emprical validation. That
+ * said, the constant is left as a static variable to allow it to be
+ * dynamically tuned in the field if and as needed.
+ */
+static uintptr_t mac_rx_srs_stack_needed = 10240;
+static uint_t mac_rx_srs_stack_toodeep;
+
+#ifndef STACK_GROWTH_DOWN
+#error Downward stack growth assumed.
+#endif
+
+#define MAC_RX_SRS_TOODEEP() (STACK_BIAS + (uintptr_t)getfp() - \
+ (uintptr_t)curthread->t_stkbase < mac_rx_srs_stack_needed && \
+ ++mac_rx_srs_stack_toodeep)
+
+
+/*
* Drop the rx packet and advance to the next one in the chain.
*/
static void
@@ -2419,11 +2446,12 @@ mac_rx_srs_process(void *arg, mac_resource_handle_t srs, mblk_t *mp_chain,
if (!(mac_srs->srs_state & SRS_PROC)) {
/*
- * If we are coming via loopback or if we are not
- * optimizing for latency, we should signal the
- * worker thread.
+ * If we are coming via loopback, if we are not optimizing for
+ * latency, or if our stack is running deep, we should signal
+ * the worker thread.
*/
- if (loopback || !(mac_srs->srs_state & SRS_LATENCY_OPT)) {
+ if (loopback || !(mac_srs->srs_state & SRS_LATENCY_OPT) ||
+ MAC_RX_SRS_TOODEEP()) {
/*
* For loopback, We need to let the worker take
* over as we don't want to continue in the same