Re: [PATCH v5 4/4] mm/msync: return ENOMEM if len overflows for msync
From: Lorenzo Stoakes (ARM)
Date: Fri Nov 20 2026 - 05:11:55 EST
On Fri, Nov 20, 2026 at 01:14:13PM +0800, Ding Feng wrote:
> Hi,
>
> This patch seems to have stalled with the mlock discussion on v4, but
> the msync part does not depend on it: a range whose page-aligned length
> wraps to 0 always covers unmapped addresses, so msync(2)'s "ENOMEM The
> indicated memory (or part of it) was not mapped" applies.
>
> It is still reproducible on v7.4-rc3 (65e4fd942), and the patch applies
> cleanly there. On a one-page anonymous mapping p (arm64, QEMU):
>
> call unpatched patched
> msync(p, SIZE_MAX - 4094, MS_SYNC) 0 ENOMEM
> msync(p, 1UL << 40, MS_SYNC) ENOMEM ENOMEM
> msync(p, 4096, MS_SYNC) 0 0
> msync(p, 0, MS_SYNC) 0 0
>
> Tested-by: Ding Feng <dingf3ng@xxxxxxxxx>
>
> Andrew, could this one go in on its own?
This is from 3.5 years ago, so please no :)
This doesn't really matter all the much and is a nice to have I suppose, so
let me send a patch for it to make life easier.
>
> Thanks,
> Ding Feng
--
Cheers, Lorenzo