Page MenuHomeFreeBSD

Fix a vnode lock leak in vm_fault_hold().
ClosedPublic

Authored by markj on Oct 13 2016, 5:42 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 17 2024, 4:18 AM
Unknown Object (File)
Sep 15 2024, 6:54 PM
Unknown Object (File)
Sep 7 2024, 11:53 AM
Unknown Object (File)
Aug 28 2024, 9:39 PM
Unknown Object (File)
Aug 11 2024, 11:35 PM
Unknown Object (File)
Aug 10 2024, 10:26 PM
Unknown Object (File)
Aug 1 2024, 10:19 PM
Unknown Object (File)
Jun 18 2024, 3:02 PM
Subscribers
None

Details

Summary

Suppose the fault handler sleeps for an (exclusive) vnode lock. When it
wakes up, it does a "goto RetryFault" with the lock held. If the
subsequent map lookup fails, we may return with the lock held since no
unlock_and_deallocate() call is present in that error path.

We cannot call unlock_and_deallocate() unconditionally in this path,
since the fault state may not yet be fully initialized and we don't want
to waste cycles initializing it just for this rare error case.
Furthermore, we generally release resources before a "goto RetryFault",
and unlock_and_deallocate() is not idempotent. Therefore, I added a call
to vput() rather than unlock_and_deallocate() in the error case.

Test Plan

We've been seeing this lock leak occasionally in stress tests,
presumably due to an application bug. For some reason, it's only
been happening in our "BSD refresh" branch, which brings our
OS up-to-date with respect to FreeBSD.

I added an assertion to the error case for the vm_map_lookup() call
to confirm the scenario I described above.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj retitled this revision from to Fix a vnode lock leak in vm_fault_hold()..
markj updated this object.
markj edited the test plan for this revision. (Show Details)
markj added reviewers: alc, kib.
kib edited edge metadata.
This revision is now accepted and ready to land.Oct 13 2016, 6:10 PM
alc edited edge metadata.
This revision was automatically updated to reflect the committed changes.