summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormjacob <mjacob@NetBSD.org>2001-10-20 18:37:54 +0000
committermjacob <mjacob@NetBSD.org>2001-10-20 18:37:54 +0000
commit5522109c39b635ecccfc223da0c16db38e1b64cb (patch)
treef49460b5c429499d6325bbb099b185bb556a6b73 /sys/dev
parent8f0b837cd484014d84741015fa7b3e7163e20821 (diff)
Protect against deranged fabric nameservers that spit out 10000 identical
port numbers.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/isp.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/sys/dev/ic/isp.c b/sys/dev/ic/isp.c
index 0885f6f5a51..04680f7092a 100644
--- a/sys/dev/ic/isp.c
+++ b/sys/dev/ic/isp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: isp.c,v 1.81 2001/10/06 20:34:49 mjacob Exp $ */
+/* $NetBSD: isp.c,v 1.82 2001/10/20 18:37:54 mjacob Exp $ */
/*
* This driver, which is contained in NetBSD in the files:
*
@@ -2291,11 +2291,11 @@ static int
isp_scan_fabric(struct ispsoftc *isp)
{
fcparam *fcp = isp->isp_param;
- u_int32_t portid, first_portid;
+ u_int32_t portid, first_portid, last_portid;
sns_screq_t *reqp;
sns_scrsp_t *resp;
mbreg_t mbs;
- int hicap, first_portid_seen;
+ int hicap, first_portid_seen, last_port_same;
if (fcp->isp_onfabric == 0) {
fcp->isp_loopstate = LOOP_FSCAN_DONE;
@@ -2308,6 +2308,8 @@ isp_scan_fabric(struct ispsoftc *isp)
* Since Port IDs are 24 bits, we can check against having seen
* anything yet with this value.
*/
+ last_port_same = 0;
+ last_portid = 0xffffffff; /* not a port */
first_portid = portid = fcp->isp_portid;
fcp->isp_loopstate = LOOP_SCANNING_FABRIC;
@@ -2386,9 +2388,20 @@ isp_scan_fabric(struct ispsoftc *isp)
fcp->isp_loopstate = LOOP_FSCAN_DONE;
return (0);
}
+ if (portid == last_portid) {
+ if (last_port_same++ > 20) {
+ isp_prt(isp, ISP_LOGWARN,
+ "tangled fabric database detected");
+ break;
+ }
+ } else {
+ last_portid = portid;
+ }
}
- isp_prt(isp, ISP_LOGWARN, "broken fabric nameserver...*wheeze*...");
+ if (hicap >= 65535) {
+ isp_prt(isp, ISP_LOGWARN, "fabric too big (> 65535)");
+ }
/*
* We either have a broken name server or a huge fabric if we get here.