All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Dima Stepanov <dimastep@yandex-team.ru>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	wrfsh@yandex-team.ru
Subject: Re: [Qemu-devel] [PATCH v2 2/2] memory: fix possible NULL pointer dereference
Date: Wed, 11 Jul 2018 15:09:13 +0100	[thread overview]
Message-ID: <CAFEAcA_6mnQZA9HhaTW1oQ9wAVzpTkJq-bjyxg9NGDEqc55zoQ@mail.gmail.com> (raw)
In-Reply-To: <69f9565f-e5f9-54f3-03dd-e610bea47ddc@amsat.org>

On 11 July 2018 at 14:47, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> Hi Dima,
>
> On 07/11/2018 05:34 AM, Dima Stepanov wrote:
>> Gentle ping. CCing Paolo Bonzini.
>>
>> Regards, Dima.
>>
>> On Tue, Jun 19, 2018 at 05:12:16PM +0300, Dima Stepanov wrote:
>>> Ping.
>>>
>>> Regards, Dima.
>>>
>>> On Wed, Jun 13, 2018 at 11:19:55AM +0300, Dima Stepanov wrote:
>>>> In the memory_region_do_invalidate_mmio_ptr() routine the section
>>>> variable is intialized by the memory_region_find() call. The section.mr
>>>> field can be set to NULL.
>>>>
>>>> Add the check for NULL before trying to drop a section.
>>>>
>>>> Signed-off-by: Dima Stepanov <dimastep@yandex-team.ru>
>>>> ---
>>>>  memory.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/memory.c b/memory.c
>>>> index 3212acc..bb45248 100644
>>>> --- a/memory.c
>>>> +++ b/memory.c
>>>> @@ -2712,7 +2712,7 @@ static void memory_region_do_invalidate_mmio_ptr(CPUState *cpu,
>>>>      /* Reset dirty so this doesn't happen later. */
>>>>      cpu_physical_memory_test_and_clear_dirty(offset, size, 1);
>>>>
>>>> -    if (section.mr != mr) {
>>>> +    if (section.mr && (section.mr != mr)) {
>
> section.mr can't be NULL here.
>
> You can give the static analyzer a hint using "assert(section.mr);"

Not in my view much point in messing with this code, though:
(a) it's broken and unusable as it stands (race conditions)
(b) it's obsoleted by the execute-from-mmio patchset
http://patchwork.ozlabs.org/cover/942090/ and if/when that
goes in it will all just get deleted.

thanks
-- PMM

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

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-13  8:19 [Qemu-devel] [PATCH v2 0/2] misc fixes found by static analyzer Dima Stepanov
2018-06-13  8:19 ` [Qemu-devel] [PATCH v2 1/2] memfd: fix possible usage of the uninitialized file descriptor Dima Stepanov
2018-06-13 10:00   ` Marc-André Lureau
2018-08-31 17:16   ` Thomas Huth
2018-06-13  8:19 ` [Qemu-devel] [PATCH v2 2/2] memory: fix possible NULL pointer dereference Dima Stepanov
2018-06-19 14:12   ` Dima Stepanov
2018-07-11  8:34     ` Dima Stepanov
2018-07-11 13:47       ` Philippe Mathieu-Daudé
2018-07-11 14:09         ` Peter Maydell [this message]
2018-07-11 16:03           ` Dima Stepanov
2018-07-11 16:01         ` Dima Stepanov

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=CAFEAcA_6mnQZA9HhaTW1oQ9wAVzpTkJq-bjyxg9NGDEqc55zoQ@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=dimastep@yandex-team.ru \
    --cc=f4bug@amsat.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wrfsh@yandex-team.ru \
    /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.