google / gvisor

Application Kernel for Containers
https://gvisor.dev
Apache License 2.0
15.86k stars 1.3k forks source link

Fix memmap.MappingIdentity.Device/InodeID() lock ordering. #11187

Closed copybara-service[bot] closed 1 day ago

copybara-service[bot] commented 3 days ago

Fix memmap.MappingIdentity.Device/InodeID() lock ordering.

For vfs.FileDescriptions for which FileDescriptionOptions.UseDentryMetadata is true, memmap.MappingIdentity.Device/InodeID() => FileDescription.Stat() => FilesystemImpl.StatAt() takes fsimpl locks for path traversal, which violates the lock ordering and is unnecessary since no path is being traversed. Fix this by carving out a special case where FilesystemImpl.Stat() (and FileDescriptionImpl.Stat()) are required to meet the lock ordering requirements of memmap.MappingIdentity.Device/InodeID(), and implement that special case by skipping path traversal (and gofer revalidation) locks when not required.