RFC mm: Fix mremap behavior when using addr hints
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest5 patches 2 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | mm: mremap: Fix new_addr being used as a hint with MREMAP_DONTUNMAPmm/ | +19 | 1 reply | |
| 2/5 | mm: mremap: Use round_hint_to_min() for new_addr hintsinclude/ mm/ mm/ | +17 | 0 replies | |
| 3/5 | mm: mremap: Allow new_addr to be specified as a hintmm/ | +1 | 1 reply | |
| 4/5 | selftests: mm: Add a new MREMAP_DONTUNMAP self testtools/ | +40 | 0 replies | |
| 5/5 | selftests: mm: Add selftest for new_addr hint with MREMAP_MAYMOVE.tools/ | +112 | 0 replies |
Reviews trailers per patch
1 of 5 patches has a Reviewed-by or Acked-by.
| Patch | Marco Vanotti |
|---|---|
| 1/5 | R-b |
| 2/5 | |
| 3/5 | |
| 4/5 | |
| 5/5 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [RFC PATCH 0/5] mm: Fix mremap behavior when using addr hints
When MREMAP_DONTUNMAP was added in e346b38 ("mm/mremap: add MREMAP_DONTUNMAP to mremap()") we inadvertently allows for an address hint to be specified when not using MREMAP_FIXED. This is because mremap(2) with MREMAP_DONTUNMAP it shares a code path with MREMAP_FIXED in mremap_to(), which means this function can be called in 3 different
scenarios: MREMAP_FIXED only, MREMAP_DONTUNMAP
only, or MREMAP_FIXED | MREMAP_DONTUNMAP. In the second case when only MREMAP_DONTUNMAP the new_addr is passed to get_unmapped_area() which behaves like a hint as it does with mmap(2).
Glibc now expects this behavior so it would seem it probably cannot be removed [1]. Additionally, as Jann Horn pointed out Debian apparently has tests for this odd undocumented behavior [2].
This series attempts to reconcile this situation.
Patch 1: Will fix the checks that should only apply to the MREMAP_FIXED case, so that they don't apply to just MREMAP_MAYMOVE.
Patch 2: Addresses an actual bug where we can allow a hint which is lower than the mmap_min_addr.
Patch 3: Since we're stuck with this behavior we might as well support it for mremap(2) when MREMAP_MAYMOVE is specified.
Patch 4: Self tests for patch 1
Patch 5: Self tests for patch 3
I will mail man page updates once we finalize on the behavior for mremap(2).
1. https://sourceware.org/git/?p=glibc.git;a=commit;h=6c40cb0e9f893d49dc7caee580a055de53562206
2. https://sources.debian.org/src/glibc/2.40-4/debian/patches/git-updates.diff/?hl=22820#L22818
Brian Geffon (5):
mm: mremap: Fix new_addr being used as a hint with MREMAP_DONTUNMAP
mm: mremap: Use round_hint_to_min() for new_addr hints
mm: mremap: Allow new_addr to be specified as a hint
selftests: mm: Add a new MREMAP_DONTUNMAP self test
selftests: mm: Add selftest for new_addr hint with MREMAP_MAYMOVE.
include/linux/mm_inline.h | 14 +++ mm/mmap.c | 13 -- mm/mremap.c | 34 ++++-- tools/testing/selftests/mm/mremap_dontunmap.c | 41 ++++++- tools/testing/selftests/mm/mremap_test.c | 113 +++++++++++++++++- 5 files changed, 189 insertions(+), 26 deletions(-)
Signature · 1 line
2.47.0.338.g60cca15819-goog