diff options
Diffstat (limited to 'pkg/sentry')
-rw-r--r-- | pkg/sentry/mm/special_mappable.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/pkg/sentry/mm/special_mappable.go b/pkg/sentry/mm/special_mappable.go index aa2f87107..5d7bd33bd 100644 --- a/pkg/sentry/mm/special_mappable.go +++ b/pkg/sentry/mm/special_mappable.go @@ -138,10 +138,15 @@ func (m *SpecialMappable) Length() uint64 { // uses an ephemeral file created by mm/shmem.c:shmem_zero_setup(); we should // do the same to get non-zero device and inode IDs. func NewSharedAnonMappable(length uint64, p platform.Platform) (*SpecialMappable, error) { - if length == 0 || length != uint64(usermem.Addr(length).RoundDown()) { + if length == 0 { return nil, syserror.EINVAL } - fr, err := p.Memory().Allocate(length, usage.Anonymous) + alignedLen, ok := usermem.Addr(length).RoundUp() + if !ok { + return nil, syserror.EINVAL + } + + fr, err := p.Memory().Allocate(uint64(alignedLen), usage.Anonymous) if err != nil { return nil, err } |