From: Daniel Henrique Barboza <danielhb413@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, "BALATON Zoltan" <balaton@eik.bme.hu>,
"Cédric Le Goater" <clg@kaod.org>
Subject: Re: [RFC 1/2] hw/ppc/ppc440_uc: Initialize length passed to cpu_physical_memory_map()
Date: Wed, 27 Jul 2022 11:11:11 -0300 [thread overview]
Message-ID: <067b069a-4930-f5a9-2ce7-d4eb225c0825@gmail.com> (raw)
In-Reply-To: <CAFEAcA8s9vgBFVuDVVednC4cv5Q4M7L+uTCc74tEmdht4ss+pA@mail.gmail.com>
On 7/26/22 15:24, Peter Maydell wrote:
> On Tue, 26 Jul 2022 at 19:23, Peter Maydell <peter.maydell@linaro.org> wrote:
>>
>> In dcr_write_dma(), there is code that uses cpu_physical_memory_map()
>> to implement a DMA transfer. That function takes a 'plen' argument,
>> which points to a hwaddr which is used for both input and output: the
>> caller must set it to the size of the range it wants to map, and on
>> return it is updated to the actual length mapped. The dcr_write_dma()
>> code fails to initialize rlen and wlen, so will end up mapping an
>> unpredictable amount of memory.
>>
>> Initialize the length values correctly, and check that we managed to
>> map the entire range before using the fast-path memmove().
>>
>> This was spotted by Coverity, which points out that we never
>> initialized the variables before using them.
>>
>> Fixes: Coverity CID 1487137
>
> Also CID 1487150 (it reports the wlen and rlen issues separately).
I amended in tree:
Fixes: Coverity CID 1487137, 1487150
I also believe that this Coverity fix isn't dependent on patch 2, which
apparently will take longer to get reviewed, so it's fine to take it
now.
Thanks,
Daniel
>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>
> -- PMM
next prev parent reply other threads:[~2022-07-27 14:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-26 18:23 [RFC 0/2] Fix Coverity and other errors in ppc440_uc DMA Peter Maydell
2022-07-26 18:23 ` [RFC 1/2] hw/ppc/ppc440_uc: Initialize length passed to cpu_physical_memory_map() Peter Maydell
2022-07-26 18:24 ` Peter Maydell
2022-07-27 14:11 ` Daniel Henrique Barboza [this message]
2022-07-28 9:43 ` Peter Maydell
2022-07-26 19:35 ` Richard Henderson
2022-07-26 18:23 ` [RFC 2/2] hw/ppc/ppc440_uc: Handle mapping failure in DMA engine Peter Maydell
2022-07-27 8:28 ` [RFC 0/2] Fix Coverity and other errors in ppc440_uc DMA Cédric Le Goater
2022-07-27 11:55 ` BALATON Zoltan
2022-07-27 13:01 ` Peter Maydell
2022-07-27 13:06 ` Peter Maydell
2022-07-28 18:03 ` BALATON Zoltan
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=067b069a-4930-f5a9-2ce7-d4eb225c0825@gmail.com \
--to=danielhb413@gmail.com \
--cc=balaton@eik.bme.hu \
--cc=clg@kaod.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).