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)
Sun, Jun 23, 2:11 AM
Unknown Object (File)
Sat, Jun 22, 2:02 PM
Unknown Object (File)
Tue, Jun 18, 1:56 AM
Unknown Object (File)
Sat, Jun 8, 9:08 PM
Unknown Object (File)
May 4 2024, 10:21 PM
Unknown Object (File)
Apr 30 2024, 8:28 AM
Unknown Object (File)
Apr 30 2024, 3:47 AM
Unknown Object (File)
Apr 21 2024, 2:09 AM
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 Not Applicable
Unit
Tests Not Applicable

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.