summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/host/host.go
diff options
context:
space:
mode:
authorDean Deng <deandeng@google.com>2020-06-17 11:32:23 -0700
committergVisor bot <gvisor-bot@google.com>2020-06-17 11:34:06 -0700
commite5d97cbcc1e64185b8fab1cf563c8754edd2e52e (patch)
treec621fe72067125d2b5c34bfd18cd52a428cd924b /pkg/sentry/fsimpl/host/host.go
parent50afec55c75dfd5bb88d100f77e17048dfbb3322 (diff)
Refactor host.canMap.
Simplify the canMap check. We do not have plans to allow mmap for anything beyond regular files, so we can just inline canMap() as a simple file mode check. Updates #1672. PiperOrigin-RevId: 316929654
Diffstat (limited to 'pkg/sentry/fsimpl/host/host.go')
-rw-r--r--pkg/sentry/fsimpl/host/host.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/pkg/sentry/fsimpl/host/host.go b/pkg/sentry/fsimpl/host/host.go
index 7906242c9..2b084860e 100644
--- a/pkg/sentry/fsimpl/host/host.go
+++ b/pkg/sentry/fsimpl/host/host.go
@@ -91,7 +91,9 @@ func NewFD(ctx context.Context, mnt *vfs.Mount, hostFD int, opts *NewFDOptions)
isTTY: opts.IsTTY,
wouldBlock: wouldBlock(uint32(fileType)),
seekable: seekable,
- canMap: canMap(uint32(fileType)),
+ // NOTE(b/38213152): Technically, some obscure char devices can be memory
+ // mapped, but we only allow regular files.
+ canMap: fileType == linux.S_IFREG,
}
i.pf.inode = i