Page MenuHomeFreeBSD

tun/tap: close race between destroy/ioctl handler
ClosedPublic

Authored by kevans on Apr 23 2019, 4:28 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Sep 24, 5:56 AM
Unknown Object (File)
Tue, Sep 24, 2:24 AM
Unknown Object (File)
Mon, Sep 23, 11:00 PM
Unknown Object (File)
Mon, Sep 23, 2:38 PM
Unknown Object (File)
Mon, Sep 23, 12:53 AM
Unknown Object (File)
Sun, Sep 22, 10:39 PM
Unknown Object (File)
Sun, Sep 22, 10:28 PM
Unknown Object (File)
Sun, Sep 22, 9:51 PM
Subscribers

Details

Summary

It seems that there should be a better way to handle this, but this seems to be the more common approach and it should likely get replaced in all of the places it happens... Basically, thread 1 is in the process of destroying the tun/tap while thread 2 is executing one of the ioctls that requires the tun/tap mutex and the mutex is destroyed before the ioctl handler can acquire it.

This is only one of the races described/found in PR 233955.

PR: 233955

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 23861

Event Timeline

Actually functional, after a little bit more coffee and testing... previous version caused trivial deadlock as follows:

1.) ifconfig tun1 create
2.) ifconfig tun1 10.10.1.1 10.10.1.2
3.) ifconfig tun1 destroy

*_destroy only needs to hold ioctl_sx long enough to invalidate the if_softc, while the ioctl handler needs to hold it to guarantee liveness until it's done. Minimize the destroy bits.

This revision is now accepted and ready to land.Apr 24 2019, 9:59 AM
This revision was automatically updated to reflect the committed changes.