tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Are modunload and ifconfig create racy?



Hi,

As riastradh@n.o pointed out below mail, it seems there is race in 
module unload processing about interfaces.
    http://mail-index.netbsd.org/tech-net/2017/01/19/msg006250.html
========== quote ==========
   +static int
   +l2tpdetach(void)
   +{
   +       int error;
   +
   +       if (!LIST_EMPTY(&l2tp_softc_list))
   +               return EBUSY;

Need lock here?  Need to first set flag preventing new creation?

mutex_enter(&l2tp_softc.lock);
KASSERT(!l2tp_softc.dying);
l2tp_softc.detaching = true;
if (!LIST_EMPTY(&l2tp_softc.list)) {
	l2tp_softc.detaching = false;
	mutex_exit(&l2tp_softc.lock);
	return EBUSY;
}
mutex_exit(&l2tp_softc.lock);

Anyone trying to add to l2tp_softc.list must also check
l2tp_softc.detaching before proceeding.
========== quote ==========

I think this detaching flag exclusion is required to kernel module'd
interfaces such as pppoe(4), gre(4) and so on. Is this correct?
# I am not familiar with kernel module load/unload locking... 

If correct, it seems some kind of exclusion is required in kernel module
framework to prevent race between modunload(8) kernel module of such
interface and ifconfig(8) create of such interface.


Could anyone have any ideas about this?


Thanks,

-- 
//////////////////////////////////////////////////////////////////////
Internet Initiative Japan Inc.

Device Engineering Section,
IoT Platform Development Department,
Network Division,
Technology Unit

Kengo NAKAHARA <k-nakahara%iij.ad.jp@localhost>


Home | Main Index | Thread Index | Old Index