diff options
author | Shawn Routhier <sar@isc.org> | 2012-09-19 14:27:44 -0700 |
---|---|---|
committer | Shawn Routhier <sar@isc.org> | 2012-09-19 14:27:44 -0700 |
commit | 67b2cb451b409b6e5a7e3e838c9352243466e795 (patch) | |
tree | 657733abd579ed059ad1f8b5965d0f1e65419609 | |
parent | 529be52a84e882afb3efcc33e8dd898dd655f0ad (diff) | |
download | isc-dhcp-67b2cb451b409b6e5a7e3e838c9352243466e795.tar.gz |
[master]
Update the memory leakage debug code to work with v6.
-rw-r--r-- | RELNOTES | 3 | ||||
-rw-r--r-- | common/options.c | 96 | ||||
-rw-r--r-- | doc/devel/debug.dox | 12 | ||||
-rw-r--r-- | omapip/alloc.c | 6 | ||||
-rw-r--r-- | server/salloc.c | 5 |
5 files changed, 75 insertions, 47 deletions
@@ -117,6 +117,9 @@ work on other platforms. Please report any problems and suggested fixes to [ISC-Bugs #30281] CVE: CVE-2012-3955 +- Update the memory leakage debug code to work with v6. + [ISC-Bugs #30297] + Changes since 4.2.3 ! Add a check for a null pointer before calling the regexec function. diff --git a/common/options.c b/common/options.c index f3a3db07..79db3669 100644 --- a/common/options.c +++ b/common/options.c @@ -3749,55 +3749,51 @@ void do_packet (interface, packet, len, from_port, from, hfrom) #endif #if defined (TRACING) - trace_inpacket_stash (interface, packet, len, from_port, from, hfrom); + trace_inpacket_stash(interface, packet, len, from_port, from, hfrom); #endif - decoded_packet = (struct packet *)0; - if (!packet_allocate (&decoded_packet, MDL)) { - log_error ("do_packet: no memory for incoming packet!"); + decoded_packet = NULL; + if (!packet_allocate(&decoded_packet, MDL)) { + log_error("do_packet: no memory for incoming packet!"); return; } - decoded_packet -> raw = packet; - decoded_packet -> packet_length = len; - decoded_packet -> client_port = from_port; - decoded_packet -> client_addr = from; - interface_reference (&decoded_packet -> interface, interface, MDL); - decoded_packet -> haddr = hfrom; - - if (packet -> hlen > sizeof packet -> chaddr) { - packet_dereference (&decoded_packet, MDL); - log_info ("Discarding packet with bogus hlen."); + decoded_packet->raw = packet; + decoded_packet->packet_length = len; + decoded_packet->client_port = from_port; + decoded_packet->client_addr = from; + interface_reference(&decoded_packet->interface, interface, MDL); + decoded_packet->haddr = hfrom; + + if (packet->hlen > sizeof packet->chaddr) { + packet_dereference(&decoded_packet, MDL); + log_info("Discarding packet with bogus hlen."); return; } /* If there's an option buffer, try to parse it. */ - if (decoded_packet -> packet_length >= DHCP_FIXED_NON_UDP + 4) { - if (!parse_options (decoded_packet)) { - if (decoded_packet -> options) + if (decoded_packet->packet_length >= DHCP_FIXED_NON_UDP + 4) { + if (!parse_options(decoded_packet)) { + if (decoded_packet->options) option_state_dereference - (&decoded_packet -> options, MDL); + (&decoded_packet->options, MDL); packet_dereference (&decoded_packet, MDL); return; } - if (decoded_packet -> options_valid && - (op = lookup_option (&dhcp_universe, - decoded_packet -> options, - DHO_DHCP_MESSAGE_TYPE))) { + if (decoded_packet->options_valid && + (op = lookup_option(&dhcp_universe, + decoded_packet->options, + DHO_DHCP_MESSAGE_TYPE))) { struct data_string dp; - memset (&dp, 0, sizeof dp); - evaluate_option_cache (&dp, decoded_packet, - (struct lease *)0, - (struct client_state *)0, - decoded_packet -> options, - (struct option_state *)0, - (struct binding_scope **)0, - op, MDL); + memset(&dp, 0, sizeof dp); + evaluate_option_cache(&dp, decoded_packet, NULL, NULL, + decoded_packet->options, NULL, + NULL, op, MDL); if (dp.len > 0) - decoded_packet -> packet_type = dp.data [0]; + decoded_packet->packet_type = dp.data[0]; else - decoded_packet -> packet_type = 0; - data_string_forget (&dp, MDL); + decoded_packet->packet_type = 0; + data_string_forget(&dp, MDL); } } @@ -3809,19 +3805,17 @@ void do_packet (interface, packet, len, from_port, from, hfrom) } /* If the caller kept the packet, they'll have upped the refcnt. */ - packet_dereference (&decoded_packet, MDL); + packet_dereference(&decoded_packet, MDL); #if defined (DEBUG_MEMORY_LEAKAGE) - log_info ("generation %ld: %ld new, %ld outstanding, %ld long-term", - dmalloc_generation, - dmalloc_outstanding - previous_outstanding, - dmalloc_outstanding, dmalloc_longterm); -#endif -#if defined (DEBUG_MEMORY_LEAKAGE) - dmalloc_dump_outstanding (); + log_info("generation %ld: %ld new, %ld outstanding, %ld long-term", + dmalloc_generation, + dmalloc_outstanding - previous_outstanding, + dmalloc_outstanding, dmalloc_longterm); + dmalloc_dump_outstanding(); #endif #if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY) - dump_rc_history (0); + dump_rc_history(0); #endif } @@ -3855,6 +3849,9 @@ do_packet6(struct interface_info *interface, const char *packet, const struct dhcpv6_packet *msg; const struct dhcpv6_relay_packet *relay; struct packet *decoded_packet; +#if defined (DEBUG_MEMORY_LEAKAGE) + unsigned long previous_outstanding = dmalloc_outstanding; +#endif if (!packet6_len_okay(packet, len)) { log_info("do_packet6: " @@ -3882,8 +3879,8 @@ do_packet6(struct interface_info *interface, const char *packet, /* decoded_packet->circuit_id_len = 0; */ /* decoded_packet->remote_id = NULL; */ /* decoded_packet->remote_id_len = 0; */ - decoded_packet->raw = (struct dhcp_packet *) packet; - decoded_packet->packet_length = (unsigned) len; + decoded_packet->raw = (struct dhcp_packet *)packet; + decoded_packet->packet_length = (unsigned)len; decoded_packet->client_port = from_port; decoded_packet->client_addr = *from; interface_reference(&decoded_packet->interface, interface, MDL); @@ -3935,6 +3932,17 @@ do_packet6(struct interface_info *interface, const char *packet, dhcpv6(decoded_packet); packet_dereference(&decoded_packet, MDL); + +#if defined (DEBUG_MEMORY_LEAKAGE) + log_info("generation %ld: %ld new, %ld outstanding, %ld long-term", + dmalloc_generation, + dmalloc_outstanding - previous_outstanding, + dmalloc_outstanding, dmalloc_longterm); + dmalloc_dump_outstanding(); +#endif +#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY) + dump_rc_history(0); +#endif } #endif /* DHCPv6 */ diff --git a/doc/devel/debug.dox b/doc/devel/debug.dox index 5feac16d..f9f4696a 100644 --- a/doc/devel/debug.dox +++ b/doc/devel/debug.dox @@ -18,4 +18,16 @@ file dhcpd b lease_reference @endverbatim +DEBUG_MEMORY_LEAKAGE may be defined in includes/site.h to enable some debugging +code to help with debugging memory issues. This code keeps a running total +of the outstanding memory that has been allocated and a list of the outstanding +allocations. Both are updated whent he memory is freed. Status information is +printed when do_packet() and do_packet6() complete processing. The outstanding +value is expected to grow when new structures are used - for example when a new +IPv6 lease is created. It is not expected to grow when a structure is reused +for example when an IPv6 lease is renewed. + +DEBUG_RC_HISTORY and DEBUG_RC_HISTORY_EXHAUSTIVELY can also be defined to provide +more verbose information about reference counts on objects. + */ diff --git a/omapip/alloc.c b/omapip/alloc.c index 69172a5b..df695fb8 100644 --- a/omapip/alloc.c +++ b/omapip/alloc.c @@ -4,6 +4,7 @@ protocol... */ /* + * Copyright (c) 2012 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 2009-2010 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 2004-2007 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1999-2003 by Internet Software Consortium @@ -311,7 +312,7 @@ void dmalloc_dump_outstanding () inhistory = 1; if (!noted) { log_info (" %s(%d): %ld", dp -> file, - dp -> line, dp -> size); + dp -> line, (long) dp -> size); noted = 1; } print_rc_hist_entry (i); @@ -324,7 +325,8 @@ void dmalloc_dump_outstanding () if (!inhistory) #endif log_info (" %s(%d): %ld", - dp -> file, dp -> line, dp -> size); + dp -> file, dp -> line, + (long) dp -> size); } #endif } diff --git a/server/salloc.c b/server/salloc.c index 17a23b50..da6e0798 100644 --- a/server/salloc.c +++ b/server/salloc.c @@ -3,7 +3,8 @@ Memory allocation for the DHCP server... */ /* - * Copyright (c) 2004-2007,2009 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2009,2012 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2004-2007 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1996-2003 by Internet Software Consortium * * Permission to use, copy, modify, and distribute this software for any @@ -61,7 +62,9 @@ void relinquish_lease_hunks () if (!c) { log_info ("lease %s refcnt %d", piaddr (n [i].ip_addr), n [i].refcnt); +#if defined (DEBUG_RC_HISTORY) dump_rc_history (&n [i]); +#endif } } } |