freebsd-src icon indicating copy to clipboard operation
freebsd-src copied to clipboard

nmdm: Allow module to be force-unloaded.

Open MegaManSec opened this issue 1 year ago • 4 comments

If an nmdm device was created by accident such as by running ls /dev/nmdmAA, it would restrict the module from being unloaded, despite no data passing through it.

With this patch, kldunload nmdm will still fail if any nmdm device still exists.

kldunload -f nmdm will try to destroy all nmdm devices before unloading. If an nmdm modem is either opened in blocking mode or data is being passed through it, after five seconds of trying, it will not be destroyed and the unload will also fail.

Likewise, fix an incorrect tty_lock, a typo, and the order of locking.

MegaManSec avatar Aug 06 '24 10:08 MegaManSec

Some problems with the locking bits, and IMO the other half is working around a bug. I don't see where the current implementation would be intentionally stopping destruction of a nmdm pair that was only ever half open.

Ah, right- we clone it in response to stat(), nothing actually opened it or ever planned on opening it. Hmm.

kevans91 avatar Aug 07 '24 04:08 kevans91

@kevans91 Looks like this is ready for you to re-review since it looks like your feedback has been applied.

bsdimp avatar Aug 23 '24 18:08 bsdimp

The remaining recommendation "Ideally, I think we'd have some kind of tty_drain_freed -> destroy_dev_drain_pending -> taskqueue_drain" is not done yet: I have not had time yet to try this.

MegaManSec avatar Aug 23 '24 18:08 MegaManSec

any update?

bsdimp avatar Sep 22 '24 08:09 bsdimp

looks like changes are still needed... any upate?

bsdimp avatar Jan 24 '25 21:01 bsdimp

last pinged over 6 months ago, with no update. Closing. Feel free to re-open this or to create a new pull request if the required changes are made. Thanks for your submission. Sorry that it didn't make it in. But we're open to having a fixed version.

bsdimp avatar Jun 12 '25 19:06 bsdimp

Unfortunately, I never got time to make the changes requested ("without the timeout by adding some plumbing through the tty layer to drain the deferred destroy_dev taskqueue").

Perhaps a freebsd bug report should be made for this, though.

MegaManSec avatar Sep 02 '25 17:09 MegaManSec