Kernel: Allow file backed mapping be larger than inode size
This is only allowed if the mapping does **not** exceed a page boundary. Some port was doing an exactly two-page-mapping on a file that was one and a half page long
This commit is contained in:
parent
d9c91589f0
commit
706cfeb443
|
@ -13,7 +13,12 @@ namespace Kernel
|
|||
|
||||
if (offset < 0 || offset % PAGE_SIZE || size == 0)
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
if ((size > (size_t)inode->size() || (size_t)offset > (size_t)inode->size() - size))
|
||||
|
||||
size_t inode_size_aligned = inode->size();
|
||||
if (auto rem = inode_size_aligned % PAGE_SIZE)
|
||||
inode_size_aligned += PAGE_SIZE - rem;
|
||||
|
||||
if ((size > inode_size_aligned || static_cast<size_t>(offset) > inode_size_aligned - size))
|
||||
return BAN::Error::from_errno(EOVERFLOW);
|
||||
|
||||
auto* region_ptr = new FileBackedRegion(inode, page_table, offset, size, type, flags, status_flags);
|
||||
|
|
Loading…
Reference in New Issue