diff options
author | Nicolas Lacasse <nlacasse@google.com> | 2019-10-04 17:02:22 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-10-04 17:03:50 -0700 |
commit | f24c3188b5d57b370ff048c87420a7f56a48b5b8 (patch) | |
tree | 7fea648277f769d8a75f335fa8b87101ecfa0638 /pkg/sentry | |
parent | b941e357615a7b0e04dbf6535cafacfbb4b7e276 (diff) |
Add sanity check that overlayCreate is called with an overlay parent inode.
PiperOrigin-RevId: 272987037
Diffstat (limited to 'pkg/sentry')
-rw-r--r-- | pkg/sentry/fs/inode_overlay.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pkg/sentry/fs/inode_overlay.go b/pkg/sentry/fs/inode_overlay.go index 246b97161..5a388dad1 100644 --- a/pkg/sentry/fs/inode_overlay.go +++ b/pkg/sentry/fs/inode_overlay.go @@ -15,6 +15,7 @@ package fs import ( + "fmt" "strings" "gvisor.dev/gvisor/pkg/abi/linux" @@ -207,6 +208,11 @@ func overlayLookup(ctx context.Context, parent *overlayEntry, inode *Inode, name } func overlayCreate(ctx context.Context, o *overlayEntry, parent *Dirent, name string, flags FileFlags, perm FilePermissions) (*File, error) { + // Sanity check. + if parent.Inode.overlay == nil { + panic(fmt.Sprintf("overlayCreate called with non-overlay parent inode (parent InodeOperations type is %T)", parent.Inode.InodeOperations)) + } + // Dirent.Create takes renameMu if the Inode is an overlay Inode. if err := copyUpLockedForRename(ctx, parent); err != nil { return nil, err |