sunshowers opened issue #9660:
Discovered this while working on #9652.
Looking at
LocalMemory::new
:It passes in
alloc.byte_size()
as theaccessible
parameter toMemoryImageSlot::create
:
self.accessible
is not rounded up to the host page size and is instead stored directly. But other places assume thatself.accessible
is page-aligned, for example:This ends up resolving to
mprotect
:
mprotect
requires that its address is page-aligned, and will produce anEINVAL
if it isn't.I think there are likely also places where it panics or possibly even causes UB.
sunshowers edited issue #9660:
Discovered this while working on #9652.
Looking at
LocalMemory::new
:It passes in
alloc.byte_size()
as theaccessible
parameter toMemoryImageSlot::create
:
self.accessible
is not rounded up to the host page size and is instead stored directly. But other places assume thatself.accessible
is page-aligned, for example:This ends up resolving to
mprotect
:
mprotect
requires that its address is page-aligned, and will produce anEINVAL
if it isn't.I think there are likely also places where it panics or possibly even causes UB.
sunshowers commented on issue #9660:
In Zulip we decided to:
- for now, skip attempting to do CoW if
byte_size
is smaller than the host page size- in the future, extend
MemoryImageSlot
to track both the accessible size and a rounded-up form of it.
Last updated: Dec 23 2024 at 12:05 UTC