summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrstone <rstone@FreeBSD.org>2017-02-07 15:12:27 +0000
committerrstone <rstone@FreeBSD.org>2017-02-07 15:12:27 +0000
commit6009c6b075bf69c68e24b1510faf84faa9c570dd (patch)
tree13f05c0d9a7a63b19ac9865fbc54c8d13dbadb15
parent7498f7ec15040238451a0b77de9406c817e45b3e (diff)
downloadFreeBSD-src-6009c6b075bf69c68e24b1510faf84faa9c570dd.zip
FreeBSD-src-6009c6b075bf69c68e24b1510faf84faa9c570dd.tar.gz
MFC r312544
Fix reference to free memory in ixgbe/if_media.c When ixgbe receives an interrupt indicating that a new optical module may have been inserted, it discards all of its current media types by calling ifmedia_removeall() and then creates a new set of media types for the supported media on the new module. However, ifmedia_removeall() was maintaining a pointer to whatever the current media type was before the call to ifmedia_removealL(). The result of this was that any attempt to read the current media type of the interface (e.g. via ifconfig) would return potentially garbage data from free memory (or if one were particularly unlucky on an architecture that does not malloc() from a direct map, page fault the kernel). Fix this by NULL'ing out the current media field in if_media.c, and have ixgbe update the current media type after recreating them. Submitted by: Matt Joras <matt.joras AT gmail DOT com> Reviewed by: sbruno, erj MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D9164
-rw-r--r--sys/dev/ixgbe/if_ix.c1
-rw-r--r--sys/net/if_media.c1
2 files changed, 2 insertions, 0 deletions
diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c
index 2e85942..509fccd 100644
--- a/sys/dev/ixgbe/if_ix.c
+++ b/sys/dev/ixgbe/if_ix.c
@@ -3885,6 +3885,7 @@ ixgbe_handle_msf(void *context, int pending)
/* Adjust media types shown in ifconfig */
ifmedia_removeall(&adapter->media);
ixgbe_add_media_types(adapter);
+ ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO);
IXGBE_CORE_UNLOCK(adapter);
return;
}
diff --git a/sys/net/if_media.c b/sys/net/if_media.c
index 32e0712..7216220 100644
--- a/sys/net/if_media.c
+++ b/sys/net/if_media.c
@@ -105,6 +105,7 @@ ifmedia_removeall(ifm)
LIST_REMOVE(entry, ifm_list);
free(entry, M_IFADDR);
}
+ ifm->ifm_cur = NULL;
}
/*
OpenPOWER on IntegriCloud