|Subject:||Re: [PATCH] linux-user: mprotect() should returns 0 when len is 0.|
|Date:||Fri, 7 Oct 2022 07:28:55 +0900|
On 10/6/22 11:13, Peter Maydell wrote:
> On Thu, 6 Oct 2022 at 19:05, Soichiro Isshiki
> <firstname.lastname@example.org> wrote:
>> From: sisshiki1969 <email@example.com>
>> For now, qemu-x86_64 returns ENOMEM when mprotect() was called with an argument
>> len is 0 from a guest process.
>> This behavior is incompatible with the current Linux implementation,
>> which mprotect() with len = 0 does nothing and returns 0,
>> although it does not appear to be explicitly described in man.
>> This is due to the following function which always returns false if len = 0.
>> static inline bool guest_range_valid_untagged(abi_ulong start, abi_ulong len)
>> return len - 1 <= GUEST_ADDR_MAX && start <= GUEST_ADDR_MAX - len + 1;
> Cc'ing Richard -- is this the right fix, or would it be better instead
> to make guest_range_valid_untagged() correctly handle a zero-length
> range ?
I think fixing the range check might be best.
|[Prev in Thread]||Current Thread||[Next in Thread]|