Re: [PATCH v4 06/10] mm/mremap: check remap conditions earlier
From: Lorenzo Stoakes
Date: Sun Jul 20 2025 - 07:05:52 EST
Hi Andrew,
It turns out there's some undocumented, unusual behaviour in mremap()
around shrinking of a range which was previously missed, but an LTP test
flagged up (seemingly by accident).
Basically, if you specify an input range that spans multiple VMAs, this is
in nearly all cases rejected (this is the point of this series, after all,
for VMA moves).
However, it turns out if you a. shrink a range and b. the new size spans
only a single VMA in the original range - then this requirement is entirely
dropped.
So I need to slightly adjust the logic to account for this. I will also be
documenting this in the man page as it appears the man page contradicts
this or is at least very unclear.
I attach a fix-patch, however there's some very trivial conflicts caused
due to code being moved around.
If you'd therefore prefer me to send a respin, I can do so.
This doesn't reflect on the series itself, which with the corner-case VMA
iterator stuff sorted is fine, but is rather just an undocumented and
unusual behaviour that it seems very few were aware of.
With all other tests passing this series should be fine with this fix
applied. I've run all self-tests and the LTP tests against this.
Cheers, Lorenzo
[0]: https://lore.kernel.org/all/202507201002.69144b74-lkp@xxxxxxxxx/
----8<----