Bug 220079 - [kern] sys/kern/vfs_subr.c: double mutex locks in vgone
Summary: [kern] sys/kern/vfs_subr.c: double mutex locks in vgone
Status: Closed Not A Bug
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 11.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Mateusz Guzik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-17 12:46 UTC by Jia-Ju Bai
Modified: 2017-06-17 13:06 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jia-Ju Bai 2017-06-17 12:46:41 UTC
The kernel may has double mutex locks, and the code path in file "sys/kern/vfs_subr.c" in FreeBSD 11.0 release is:
vflush [line 3050: acquire the lock by VI_LOCK]
  vgone [line 3057]
    VI_LOCK [line 3100] --> lock again

This bug is found by a static analysis tool written by myself, and it is checked by my review of the FreeBSD code.

Jia-Ju Bai
Comment 1 Mateusz Guzik freebsd_committer freebsd_triage 2017-06-17 13:06:04 UTC
The code is:

VOP_LOCK(rootvp, LK_EXCLUSIVE|LK_INTERLOCK);
vgone(rootvp);

The LK_INTERLOCK flags tells the locking routine that the interlock is held and the contract is that it is dropped prior to return, hence vgone is called without the lock held.