From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, titusr@google.com, hskinnemoen@google.com,
wuhaotsh@google.com, qemu-arm@nongnu.org,
Tyrone Ting <kfting@nuvoton.com>
Subject: Re: [PATCH] hw/misc/npcm_clk: fix buffer-overflow
Date: Tue, 25 Feb 2025 12:57:06 -0800 [thread overview]
Message-ID: <829e9fd0-2d0f-45e6-ab89-d933d344cfe2@linaro.org> (raw)
In-Reply-To: <CAFEAcA_sz-_6WGCQ=4kC2vtK2RUBXbAtMVzh3iZsp0xmNbgaxQ@mail.gmail.com>
On 2/25/25 05:41, Peter Maydell wrote:
> On Mon, 24 Feb 2025 at 20:51, Pierrick Bouvier
> <pierrick.bouvier@linaro.org> wrote:
>>
>> Regression introduced by cf76c4
>> (hw/misc: Add nr_regs and cold_reset_values to NPCM CLK)
>>
>> cold_reset_values has a different size, depending on device used
>> (NPCM7xx vs NPCM8xx). However, s->regs has a fixed size, which matches
>> NPCM8xx. Thus, when initializing a NPCM7xx, we go past cold_reset_values
>> ending.
>
>
>> diff --git a/hw/misc/npcm_clk.c b/hw/misc/npcm_clk.c
>> index d1f29759d59..0e85974cf96 100644
>> --- a/hw/misc/npcm_clk.c
>> +++ b/hw/misc/npcm_clk.c
>> @@ -964,8 +964,9 @@ static void npcm_clk_enter_reset(Object *obj, ResetType type)
>> NPCMCLKState *s = NPCM_CLK(obj);
>> NPCMCLKClass *c = NPCM_CLK_GET_CLASS(s);
>>
>> - g_assert(sizeof(s->regs) >= c->nr_regs * sizeof(uint32_t));
>> - memcpy(s->regs, c->cold_reset_values, sizeof(s->regs));
>> + size_t sizeof_regs = c->nr_regs * sizeof(uint32_t);
>> + g_assert(sizeof(s->regs) >= sizeof_regs);
>> + memcpy(s->regs, c->cold_reset_values, sizeof_regs);
>> s->ref_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
>> npcm7xx_clk_update_all_clocks(s);
>> /*
>
> Whoops, thanks for catching this. Applied to target-arm.next, thanks.
>
> (Looking more closely at the cold_reset_values handling
> in npcm_gcr.c, that looks not quite right in a different
> way; I'll send a reply to that patch email about that.)
>
It may be a hole in our CI right now.
Would that be interesting for CI to run all tests (check-functional +
check w/o functional) with both ubsan and asan?
> -- PMM
next prev parent reply other threads:[~2025-02-25 20:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 20:50 [PATCH] hw/misc/npcm_clk: fix buffer-overflow Pierrick Bouvier
2025-02-24 20:54 ` Hao Wu
2025-02-25 13:41 ` Peter Maydell
2025-02-25 20:57 ` Pierrick Bouvier [this message]
2025-02-26 11:50 ` Peter Maydell
2025-02-26 19:03 ` Pierrick Bouvier
2025-02-26 20:50 ` Peter Maydell
2025-03-17 13:31 ` Thomas Huth
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=829e9fd0-2d0f-45e6-ab89-d933d344cfe2@linaro.org \
--to=pierrick.bouvier@linaro.org \
--cc=hskinnemoen@google.com \
--cc=kfting@nuvoton.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=titusr@google.com \
--cc=wuhaotsh@google.com \
/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).