Page MenuHomeFreeBSD

Set ifm_cur to NULL in ifmedia_removeall.
ClosedPublic

Authored by mjoras on Jan 12 2017, 9:09 PM.
Tags
None
Referenced Files
F103582516: D9164.id23948.diff
Tue, Nov 26, 6:24 PM
Unknown Object (File)
Sat, Nov 2, 4:21 PM
Unknown Object (File)
Tue, Oct 29, 2:15 PM
Unknown Object (File)
Oct 21 2024, 6:22 PM
Unknown Object (File)
Oct 3 2024, 11:43 PM
Unknown Object (File)
Oct 3 2024, 10:04 AM
Unknown Object (File)
Oct 1 2024, 5:02 PM
Unknown Object (File)
Sep 24 2024, 6:04 PM
Subscribers

Details

Summary

ixgbe will call ifmedia_removeall on a link interrupt so it can refresh
the media types. ifmedia_removeall frees all the entries in the list,
but it does not reset ifm_cur (which is supposed to point to the current
media type) to NULL. As such, after a link interrupt ixgbe's media type
(which is read from ifm_cur) will show up as all sorts of fun things.
Additionally we want to set autoselect as the default after setting the
media types in the link interrupt.

Test Plan

You can see the problem pretty obviously on an INVARIANTS kernel, since the memory
gets overwritten with 0xdeadc0de:

mjoras-006-1# cat media.d 
fbt::ifmedia_ioctl:entry /execname == "ifconfig"/ {printf("%x", ((struct ifmedia_entry *)((struct ifmedia *)args[2])->ifm_cur)->ifm_media);} 
mjoras-006-1# dtrace -s media.d&
[1] 31997
mjoras-006-1# dtrace: script 'media.d' matched 1 probe
mjoras-006-1# ifconfig ix0 down
mjoras-006-1# ifconfig ix0   
ix0: flags=808802<BROADCAST,SIMPLEX,MULTICAST,ISIUSERDOWN> metric 0 mtu 1500
	options=e407bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,VLAN_HWTSO,RXCSUM_IPV6,TXCSUM_IPV6>
	ether 00:60:48:3c:3c:60
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: Ethernet 10Gbase-SR (autoselect)
	status: no carrier
mjoras-006-1#   5  14589              ifmedia_ioctl:entry 33
  5  14589              ifmedia_ioctl:entry 33
  5  14589              ifmedia_ioctl:entry 33

mjoras-006-1# ifconfig ix0 up
mjoras-006-1# 
mjoras-006-1# ifconfig ix0
ix0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=e407bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,VLAN_HWTSO,RXCSUM_IPV6,TXCSUM_IPV6>
	ether 00:60:48:3c:3c:60
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: <unknown type> (10Gbase-SR <full-duplex,rxpause>)
	status: active
mjoras-006-1#   7  14589              ifmedia_ioctl:entry deadc0de
  7  14589              ifmedia_ioctl:entry deadc0de
  7  14589              ifmedia_ioctl:entry deadc0de

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

mjoras retitled this revision from to Set ifm_cur to NULL in ifmedia_removeall..
mjoras updated this object.
mjoras edited the test plan for this revision. (Show Details)
mjoras edited edge metadata.
  • Accidentally left in internal tag.
mjoras edited edge metadata.
mjoras set the repository for this revision to rS FreeBSD src repository - subversion.
mjoras edited the test plan for this revision. (Show Details)
mjoras added a subscriber: network.
erj added a reviewer: erj.
This revision is now accepted and ready to land.Jan 13 2017, 7:23 PM
sbruno edited edge metadata.

Commit this nowish and I'll suck it into my iflib-ification

This revision was automatically updated to reflect the committed changes.