On 1/29/24 05:26, Ilya Leoshkevich wrote:
On Tue, Jan 02, 2024 at 12:57:57PM +1100, Richard Henderson wrote:
Work much harder to get alignment and mapping beyond the end
of the file correct. Both of which are excercised by our
test-mmap for alpha (8k pages) on any 4k page host.
Signed-off-by: Richard Henderson <richard.hender...@linaro.org>
---
linux-user/mmap.c | 156 +++++++++++++++++++++++++++++++++++++---------
1 file changed, 125 insertions(+), 31 deletions(-)
[...]
+ if (fileend_adj) {
+ void *t = mmap(p, len - fileend_adj, host_prot,
+ (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED,
+ fd, offset);
+ assert(t != MAP_FAILED);
Is it possible to recover here? Of course, we are remapping the memory
we've mapped a few lines earlier, but asserting the syscall result
looks a bit odd.
This first one we cannot recover from, because we've already (potentially) overwritten the
previous memory mapping.
+ if (!(flags & MAP_ANONYMOUS)) {
+ void *t = mmap(p, len - fileend_adj, host_prot,
+ flags | MAP_FIXED, fd, offset);
+ assert(t != MAP_FAILED);
Same here.
This one we could, because the memory was previously unmapped.
r~