diff options
author | glebius <glebius@FreeBSD.org> | 2006-03-03 12:10:59 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2006-03-03 12:10:59 +0000 |
commit | 3c6ea150e2403bf8fc50f1370cdb052de3a30a78 (patch) | |
tree | 801827820cbee401ab7de49b1b870e7e13400e70 /sys/netinet/ip_fw2.c | |
parent | 9665ebce694f61563d84026feb89af620e743d0b (diff) | |
download | FreeBSD-src-3c6ea150e2403bf8fc50f1370cdb052de3a30a78.zip FreeBSD-src-3c6ea150e2403bf8fc50f1370cdb052de3a30a78.tar.gz |
- Do not leak read lock in IP_FW_TABLE_GETSIZE case of ipfw_ctl().
- Acquire read (not write) lock in case of IP_FW_TABLE_LIST.
In collaboration with: ru
Diffstat (limited to 'sys/netinet/ip_fw2.c')
-rw-r--r-- | sys/netinet/ip_fw2.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/sys/netinet/ip_fw2.c b/sys/netinet/ip_fw2.c index f735ca9..f02fd9f 100644 --- a/sys/netinet/ip_fw2.c +++ b/sys/netinet/ip_fw2.c @@ -1847,8 +1847,6 @@ dump_table(struct ip_fw_chain *ch, ipfw_table *tbl) { struct radix_node_head *rnh; - IPFW_WLOCK_ASSERT(ch); - if (tbl->tbl >= IPFW_TABLES_MAX) return (EINVAL); rnh = ch->tables[tbl->tbl]; @@ -3988,9 +3986,10 @@ ipfw_ctl(struct sockopt *sopt) sizeof(tbl)))) break; IPFW_RLOCK(&layer3_chain); - if ((error = count_table(&layer3_chain, tbl, &cnt))) - break; + error = count_table(&layer3_chain, tbl, &cnt); IPFW_RUNLOCK(&layer3_chain); + if (error) + break; error = sooptcopyout(sopt, &cnt, sizeof(cnt)); } break; @@ -4016,14 +4015,13 @@ ipfw_ctl(struct sockopt *sopt) } tbl->size = (size - sizeof(*tbl)) / sizeof(ipfw_table_entry); - IPFW_WLOCK(&layer3_chain); + IPFW_RLOCK(&layer3_chain); error = dump_table(&layer3_chain, tbl); + IPFW_RUNLOCK(&layer3_chain); if (error) { - IPFW_WUNLOCK(&layer3_chain); free(tbl, M_TEMP); break; } - IPFW_WUNLOCK(&layer3_chain); error = sooptcopyout(sopt, tbl, size); free(tbl, M_TEMP); } |