From 3e69f5d088d121f1d3c4bf44ca637a48f13c4819 Mon Sep 17 00:00:00 2001 From: Bhasker Hariharan Date: Wed, 3 Mar 2021 12:18:04 -0800 Subject: Add checklocks analyzer. This validates that struct fields if annotated with "// checklocks:mu" where "mu" is a mutex field in the same struct then access to the field is only done with "mu" locked. All types that are guarded by a mutex must be annotated with // +checklocks: For more details please refer to README.md. PiperOrigin-RevId: 360729328 --- pkg/sentry/fsimpl/overlay/filesystem.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'pkg/sentry/fsimpl/overlay') diff --git a/pkg/sentry/fsimpl/overlay/filesystem.go b/pkg/sentry/fsimpl/overlay/filesystem.go index f7f795b10..917709d75 100644 --- a/pkg/sentry/fsimpl/overlay/filesystem.go +++ b/pkg/sentry/fsimpl/overlay/filesystem.go @@ -85,6 +85,8 @@ func putDentrySlice(ds *[]*dentry) { // but dentry slices are allocated lazily, and it's much easier to say "defer // fs.renameMuRUnlockAndCheckDrop(&ds)" than "defer func() { // fs.renameMuRUnlockAndCheckDrop(ds) }()" to work around this. +// +// +checklocks:fs.renameMu func (fs *filesystem) renameMuRUnlockAndCheckDrop(ctx context.Context, dsp **[]*dentry) { fs.renameMu.RUnlock() if *dsp == nil { @@ -110,6 +112,7 @@ func (fs *filesystem) renameMuRUnlockAndCheckDrop(ctx context.Context, dsp **[]* putDentrySlice(*dsp) } +// +checklocks:fs.renameMu func (fs *filesystem) renameMuUnlockAndCheckDrop(ctx context.Context, ds **[]*dentry) { if *ds == nil { fs.renameMu.Unlock() -- cgit v1.2.3