mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Allow '/dev/zero' to be mapped with unaligned length
PiperOrigin-RevId: 212321271 Change-Id: I79d71c2e6f4b8fcd3b9b923fe96c2256755f4c48
This commit is contained in:
committed by
Shentubot
parent
da9ecb748c
commit
7e9e6745ca
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user