[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-stable] [PATCH v5 05/11] linux-user: fix mmap/munmap/mprotect/
From: |
Max Filippov |
Subject: |
Re: [Qemu-stable] [PATCH v5 05/11] linux-user: fix mmap/munmap/mprotect/mremap/shmat |
Date: |
Wed, 7 Mar 2018 09:45:57 -0800 |
On Wed, Mar 7, 2018 at 2:08 AM, Laurent Vivier <address@hidden> wrote:
>> +static inline int guest_range_valid(unsigned long start, unsigned long len)
>> +{
>> + if (len)
>> + return guest_addr_valid(len - 1) && start <= GUEST_ADDR_MAX - len +
>> 1;
>> + else
>> + return guest_addr_valid(start);
>> +}
>
> I think we can consider len == 0 is invalid and use only:
>
> return start + (len - 1) <= GUEST_ADDR_MAX;
start + len - 1 may wrap around, that's why I first validate len and then have
len at the right side of the comparison. I.e. if we drop check for len == 0 I'd
still write it as
guest_addr_valid(len - 1) && start <= GUEST_ADDR_MAX - len + 1;
--
Thanks.
-- Max