kernel - Serialize ifioctl() with a mutex
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 7 Jun 2011 20:50:40 +0000 (13:50 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 7 Jun 2011 20:50:40 +0000 (13:50 -0700)
commit9683f229e6862b5d21b610cac390a826ba6b51de
treea8d874d362c8c3d406e0b66a7e8895c0461b1a8a
parente42208e6d1b8e1581d8df9b7458c1a51bb55253c
kernel - Serialize ifioctl() with a mutex

* ifioctl() calls (aka via ifconfig) make various assumptions about the
  stability of certain data structures and can panic otherwise.  Concurrent
  calls to ifioctl via ifconfig can create inconsistencies in the ifnet
  structure.

* Rearrange the ifioctl() code into a fall-through modem, add a struct mtx
  to the ifnet structure, and acquire and release the mutex in ifioctl()
  to enforce stability relative to concurrent ifconfig/ioctl commands
  issued on the interface.

* Fixes a panic reproduced via a while(1):

  while (1)
  echo -n x
  ifconfig re0 inet6 fe80::201:2eff:fe31:5469%re0 &
  ifconfig re0 inet6 fe80::201:2eff:fe31:5469%re0 delete &
  sleep 0.1
  end

* May fix other related panics.

NOTE: This mutex does not protect internal data structures related to
      network operation.  It is currently being used strictly to serialize
      ifconfig style operations on the interface.

Reported-by: Francois Tigeot <ftigeot@wolfpond.org>
sys/net/if.c
sys/net/if_var.h