All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: Riku Voipio <riku.voipio@iki.fi>,
	1783362@bugs.launchpad.net, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 for 3.0 1/2] linux-user/mmap.c: handle invalid len maps correctly
Date: Mon, 30 Jul 2018 16:30:29 +0200	[thread overview]
Message-ID: <5b72e5b5-5bd6-9014-2cba-da3a0e9676cf@vivier.eu> (raw)
In-Reply-To: <87zhy8954d.fsf@linaro.org>

Le 30/07/2018 à 16:21, Alex Bennée a écrit :
> 
> Laurent Vivier <laurent@vivier.eu> writes:
> 
>> Le 30/07/2018 à 15:43, Alex Bennée a écrit:
>>> I've slightly re-organised the check to more closely match the
>>> sequence that the kernel uses in do_mmap(). We check for both the zero
>>> case (EINVAL) and the overflow length case (ENOMEM).
>>>
>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>> Cc: umarcor <1783362@bugs.launchpad.net>
>>>
>>> ---
>>> v2
>>>   - add comment on overflow
>>> ---
>>>  linux-user/mmap.c | 15 ++++++++++++---
>>>  1 file changed, 12 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/linux-user/mmap.c b/linux-user/mmap.c
>>> index d0c50e4888..41e0983ce8 100644
>>> --- a/linux-user/mmap.c
>>> +++ b/linux-user/mmap.c
>>> @@ -391,14 +391,23 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
>>>      }
>>>  #endif
>>>
>>> -    if (offset & ~TARGET_PAGE_MASK) {
>>> +    if (!len) {
>>>          errno = EINVAL;
>>>          goto fail;
>>>      }
>>>
>>> +    /* Also check for overflows... */
>>>      len = TARGET_PAGE_ALIGN(len);
>>> -    if (len == 0)
>>> -        goto the_end;
>>> +    if (!len) {
>>> +        errno = ENOMEM;
>>> +        goto fail;
>>> +    }
>>> +
>>> +    if (offset & ~TARGET_PAGE_MASK) {
>>> +        errno = EINVAL;
>>> +        goto fail;
>>> +    }
>>> +
>>>      real_start = start & qemu_host_page_mask;
>>>      host_offset = offset & qemu_host_page_mask;
>>>
>>>
>>
>> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> 
> Are you going to take this via your queue or do you want me to re-post
> with the r-b?

I can take this via my queue.

Thanks,
Laurent

  reply	other threads:[~2018-07-30 14:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-30 13:43 [Qemu-devel] [PATCH v2 for 3.0 0/2] fix for bug #1783362 Alex Bennée
2018-07-30 13:43 ` [Qemu-devel] [PATCH v2 for 3.0 1/2] linux-user/mmap.c: handle invalid len maps correctly Alex Bennée
2018-07-30 14:12   ` Laurent Vivier
2018-07-30 14:21     ` Alex Bennée
2018-07-30 14:30       ` Laurent Vivier [this message]
2018-07-30 21:42   ` Richard Henderson
2018-07-30 13:43 ` [Qemu-devel] [PATCH v2 for 3.0 2/2] tests: add check_invalid_maps to test-mmap Alex Bennée
2018-07-30 15:24 ` [Qemu-devel] [PATCH v2 for 3.0 0/2] fix for bug #1783362 no-reply
2018-07-31  4:08 ` no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5b72e5b5-5bd6-9014-2cba-da3a0e9676cf@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=1783362@bugs.launchpad.net \
    --cc=alex.bennee@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.