summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorkmacy <kmacy@FreeBSD.org>2012-02-23 18:21:37 +0000
committerkmacy <kmacy@FreeBSD.org>2012-02-23 18:21:37 +0000
commita99e9d281db6624cf9b88f07759a77f7b2d96a33 (patch)
tree3a2da57fb6f6af971e7fb849770dc0f9b231bca2 /sys/netinet
parentffbbf1cb2c6c124090347c8c43c4eefb65ae1bd5 (diff)
downloadFreeBSD-src-a99e9d281db6624cf9b88f07759a77f7b2d96a33.zip
FreeBSD-src-a99e9d281db6624cf9b88f07759a77f7b2d96a33.tar.gz
When using flowtable llentrys can outlive the interface with which they're associated
at which the lle_tbl pointer points to freed memory and the llt_free pointer is no longer valid. Move the free pointer in to the llentry itself and update the initalization sites. MFC after: 2 weeks
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/in.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 58cd062..ac0aada 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -1260,6 +1260,20 @@ struct in_llentry {
struct sockaddr_in l3_addr4;
};
+/*
+ * Deletes an address from the address table.
+ * This function is called by the timer functions
+ * such as arptimer() and nd6_llinfo_timer(), and
+ * the caller does the locking.
+ */
+static void
+in_lltable_free(struct lltable *llt, struct llentry *lle)
+{
+ LLE_WUNLOCK(lle);
+ LLE_LOCK_DESTROY(lle);
+ free(lle, M_LLTABLE);
+}
+
static struct llentry *
in_lltable_new(const struct sockaddr *l3addr, u_int flags)
{
@@ -1277,25 +1291,11 @@ in_lltable_new(const struct sockaddr *l3addr, u_int flags)
lle->base.la_expire = time_uptime; /* mark expired */
lle->l3_addr4 = *(const struct sockaddr_in *)l3addr;
lle->base.lle_refcnt = 1;
+ lle->base.lle_free = in_lltable_free;
LLE_LOCK_INIT(&lle->base);
return &lle->base;
}
-/*
- * Deletes an address from the address table.
- * This function is called by the timer functions
- * such as arptimer() and nd6_llinfo_timer(), and
- * the caller does the locking.
- */
-static void
-in_lltable_free(struct lltable *llt, struct llentry *lle)
-{
- LLE_WUNLOCK(lle);
- LLE_LOCK_DESTROY(lle);
- free(lle, M_LLTABLE);
-}
-
-
#define IN_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \
(((ntohl((d)->sin_addr.s_addr) ^ (a)->sin_addr.s_addr) & (m)->sin_addr.s_addr)) == 0 )
@@ -1577,7 +1577,6 @@ in_domifattach(struct ifnet *ifp)
llt = lltable_init(ifp, AF_INET);
if (llt != NULL) {
- llt->llt_free = in_lltable_free;
llt->llt_prefix_free = in_lltable_prefix_free;
llt->llt_lookup = in_lltable_lookup;
llt->llt_dump = in_lltable_dump;
OpenPOWER on IntegriCloud