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)
Jan 21 2024, 9:44 PM
Unknown Object (File)
Dec 27 2023, 5:34 PM
Unknown Object (File)
Dec 27 2023, 5:09 PM
Unknown Object (File)
Dec 20 2023, 2:55 AM
Unknown Object (File)
Aug 18 2023, 4:59 AM
Unknown Object (File)
Jul 3 2023, 11:30 PM
Unknown Object (File)
Jun 8 2023, 9:49 PM
Unknown Object (File)
May 29 2023, 2:20 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.