Page MenuHomeFreeBSD

linker: Avoid invoking eventhandlers on incompletely loaded files
ClosedPublic

Authored by markj on Wed, Nov 26, 6:27 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 17, 12:37 PM
Unknown Object (File)
Mon, Dec 15, 3:55 PM
Unknown Object (File)
Mon, Dec 15, 12:37 PM
Unknown Object (File)
Sun, Dec 14, 11:26 AM
Unknown Object (File)
Sat, Dec 13, 8:48 PM
Unknown Object (File)
Sat, Dec 13, 8:47 PM
Unknown Object (File)
Mon, Dec 8, 9:38 AM
Unknown Object (File)
Sat, Dec 6, 4:10 AM
Subscribers

Details

Summary

We do not invoke the kld_load eventhandler until after the file is fully
linked, so don't invoke the kld_unload_try or kld_unload event handlers
unless the file is fully linked either.

In my case, the dtrace SDT kld unload handler was running before
relocations were processed against the file, and that caused problems
when sdt_kld_unload_probes() accesses elements of a linker set.

PR: 291238

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Wed, Nov 26, 6:27 PM

LGTM. I do wonder if there's a reason the steps in the kld_unload EVENTHANDLER aren't (shouldn't be) handled in the same place as sysctls / sysuninits?

This revision is now accepted and ready to land.Wed, Nov 26, 7:59 PM
  • Move the kld_unload eventhandler to immediately after sysuninits are invoked. This is more logically consistent and simplifies the patch.
This revision now requires review to proceed.Thu, Nov 27, 3:02 PM
This revision is now accepted and ready to land.Thu, Nov 27, 3:05 PM

Thanks. Thinking more about it, it does seem sensible to execute all of the teardown steps for this module before doing the dependencies.

Thanks. Thinking more about it, it does seem sensible to execute all of the teardown steps for this module before doing the dependencies.

Yeah, I added these eventhandlers originally many years ago and I'm pretty sure I had no particular reason for invoking kld_unload so late.

The difference now is in order in which dependencies are reported for unload.