[PATCH 0/2] linux: check mremap w/ MREMAP_DONTUNMAP correctly

Celeste Liu uwu@coelacanthus.name
Fri Feb 7 20:17:49 GMT 2025


Only when MREMAP_FIXED is specified, mremap will always use the fifth
argument as new address. Without MREMAP_FIXED, although the current
implementation of Linux kernel will try to allocate address at the hint
(in this case, the fifth argument) first. But this is not guaranteed: if
kernel found the hint address is not available, it will try other
address. But with MREMAP_FIXED, it will return MAP_FAILED if the hint
address is not available.

We found some test failure related to it on HiFive P550.

---
Celeste Liu (2):
      linux: prevent kernel choose addr by itself in mremap test
      linux: add test for mremap w/ MREMAP_DONTUNMAP but w/o MREMAP_FIXED

 sysdeps/unix/sysv/linux/Makefile                   |  1 +
 sysdeps/unix/sysv/linux/tst-linux-mremap1.c        | 19 +++++++--------
 .../{tst-linux-mremap1.c => tst-linux-mremap2.c}   | 27 ++++++++--------------
 3 files changed, 20 insertions(+), 27 deletions(-)
---
base-commit: cdb0800022110bc68a033944f09e501be5bd72d7
change-id: 20250208-fix-mremap-tst-1e458c977394

Best regards,
-- 
Celeste Liu <uwu@coelacanthus.name>



More information about the Libc-alpha mailing list