summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/syscalls/linux/vfs2/mmap.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-09-18 20:28:30 +0000
committergVisor bot <gvisor-bot@google.com>2020-09-18 20:28:30 +0000
commit6e8d229edf071293fc1212f191de386f693a9d7b (patch)
treec84d9c26ae1ba3f14655f3a560ce8bebb4b6a1c8 /pkg/sentry/syscalls/linux/vfs2/mmap.go
parent7d83427b10c1cdbd603c2814b5f674e819dd6fb6 (diff)
parentca4ecf481d617edfae22a5735a657d60186392e1 (diff)
Merge release-20200907.0-148-gca4ecf481 (automated)
Diffstat (limited to 'pkg/sentry/syscalls/linux/vfs2/mmap.go')
-rw-r--r--pkg/sentry/syscalls/linux/vfs2/mmap.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/pkg/sentry/syscalls/linux/vfs2/mmap.go b/pkg/sentry/syscalls/linux/vfs2/mmap.go
index dc05c2994..9d9dbf775 100644
--- a/pkg/sentry/syscalls/linux/vfs2/mmap.go
+++ b/pkg/sentry/syscalls/linux/vfs2/mmap.go
@@ -17,6 +17,7 @@ package vfs2
import (
"gvisor.dev/gvisor/pkg/abi/linux"
"gvisor.dev/gvisor/pkg/sentry/arch"
+ "gvisor.dev/gvisor/pkg/sentry/fsimpl/tmpfs"
"gvisor.dev/gvisor/pkg/sentry/kernel"
"gvisor.dev/gvisor/pkg/sentry/memmap"
"gvisor.dev/gvisor/pkg/syserror"
@@ -85,6 +86,17 @@ func Mmap(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.SyscallC
if err := file.ConfigureMMap(t, &opts); err != nil {
return 0, nil, err
}
+ } else if shared {
+ // Back shared anonymous mappings with an anonymous tmpfs file.
+ opts.Offset = 0
+ file, err := tmpfs.NewZeroFile(t, t.Credentials(), t.Kernel().ShmMount(), opts.Length)
+ if err != nil {
+ return 0, nil, err
+ }
+ defer file.DecRef(t)
+ if err := file.ConfigureMMap(t, &opts); err != nil {
+ return 0, nil, err
+ }
}
rv, err := t.MemoryManager().MMap(t, opts)