qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] contrib/plugins/execlog: Explicitly check for qemu_plugin_read_register() failure
@ 2025-07-10 14:45 Peter Maydell
  2025-07-10 15:21 ` Pierrick Bouvier
  2025-09-01 17:09 ` Alex Bennée
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Maydell @ 2025-07-10 14:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alex Bennée, Alexandre Iooss, Mahmoud Mandour,
	Pierrick Bouvier

In insn_check_regs() we don't explicitly check whether
qemu_plugin_read_register() failed, which confuses Coverity into
thinking that sz can be -1 in the memcmp().  In fact the assertion
that sz == reg->last->len means this can't happen, but it's clearer
to both humans and Coverity if we explicitly assert that sz > 0, as
we already do in init_vcpu_register().

Coverity: CID 1611901, 1611902
Fixes: af6e4e0a22c1 ("contrib/plugins: extend execlog to track register changes")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 contrib/plugins/execlog.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c
index d67d0107613..8b07dd773e5 100644
--- a/contrib/plugins/execlog.c
+++ b/contrib/plugins/execlog.c
@@ -95,6 +95,7 @@ static void insn_check_regs(CPU *cpu)
 
         g_byte_array_set_size(reg->new, 0);
         sz = qemu_plugin_read_register(reg->handle, reg->new);
+        g_assert(sz > 0);
         g_assert(sz == reg->last->len);
 
         if (memcmp(reg->last->data, reg->new->data, sz)) {
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] contrib/plugins/execlog: Explicitly check for qemu_plugin_read_register() failure
  2025-07-10 14:45 [PATCH] contrib/plugins/execlog: Explicitly check for qemu_plugin_read_register() failure Peter Maydell
@ 2025-07-10 15:21 ` Pierrick Bouvier
  2025-09-01 16:19   ` Peter Maydell
  2025-09-01 17:09 ` Alex Bennée
  1 sibling, 1 reply; 4+ messages in thread
From: Pierrick Bouvier @ 2025-07-10 15:21 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: Alex Bennée, Alexandre Iooss, Mahmoud Mandour

On 7/10/25 7:45 AM, Peter Maydell wrote:
> In insn_check_regs() we don't explicitly check whether
> qemu_plugin_read_register() failed, which confuses Coverity into
> thinking that sz can be -1 in the memcmp().  In fact the assertion
> that sz == reg->last->len means this can't happen, but it's clearer
> to both humans and Coverity if we explicitly assert that sz > 0, as
> we already do in init_vcpu_register().
> 
> Coverity: CID 1611901, 1611902
> Fixes: af6e4e0a22c1 ("contrib/plugins: extend execlog to track register changes")
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   contrib/plugins/execlog.c | 1 +
>   1 file changed, 1 insertion(+)

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] contrib/plugins/execlog: Explicitly check for qemu_plugin_read_register() failure
  2025-07-10 15:21 ` Pierrick Bouvier
@ 2025-09-01 16:19   ` Peter Maydell
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2025-09-01 16:19 UTC (permalink / raw)
  To: Pierrick Bouvier
  Cc: qemu-devel, Alex Bennée, Alexandre Iooss, Mahmoud Mandour

Hi Alex -- this patch was reviewed back in July but didn't
make it into git before 10.1 freeze; would you like to
pick it up now we've reopened for 10.2 ?

thanks
-- PMM

On Thu, 10 Jul 2025 at 16:21, Pierrick Bouvier
<pierrick.bouvier@linaro.org> wrote:
>
> On 7/10/25 7:45 AM, Peter Maydell wrote:
> > In insn_check_regs() we don't explicitly check whether
> > qemu_plugin_read_register() failed, which confuses Coverity into
> > thinking that sz can be -1 in the memcmp().  In fact the assertion
> > that sz == reg->last->len means this can't happen, but it's clearer
> > to both humans and Coverity if we explicitly assert that sz > 0, as
> > we already do in init_vcpu_register().
> >
> > Coverity: CID 1611901, 1611902
> > Fixes: af6e4e0a22c1 ("contrib/plugins: extend execlog to track register changes")
> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> > ---
> >   contrib/plugins/execlog.c | 1 +
> >   1 file changed, 1 insertion(+)
>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] contrib/plugins/execlog: Explicitly check for qemu_plugin_read_register() failure
  2025-07-10 14:45 [PATCH] contrib/plugins/execlog: Explicitly check for qemu_plugin_read_register() failure Peter Maydell
  2025-07-10 15:21 ` Pierrick Bouvier
@ 2025-09-01 17:09 ` Alex Bennée
  1 sibling, 0 replies; 4+ messages in thread
From: Alex Bennée @ 2025-09-01 17:09 UTC (permalink / raw)
  To: Peter Maydell
  Cc: qemu-devel, Alexandre Iooss, Mahmoud Mandour, Pierrick Bouvier

Peter Maydell <peter.maydell@linaro.org> writes:

> In insn_check_regs() we don't explicitly check whether
> qemu_plugin_read_register() failed, which confuses Coverity into
> thinking that sz can be -1 in the memcmp().  In fact the assertion
> that sz == reg->last->len means this can't happen, but it's clearer
> to both humans and Coverity if we explicitly assert that sz > 0, as
> we already do in init_vcpu_register().
>
> Coverity: CID 1611901, 1611902
> Fixes: af6e4e0a22c1 ("contrib/plugins: extend execlog to track register changes")
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Queued to plugins/next, thanks.

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-09-01 17:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-10 14:45 [PATCH] contrib/plugins/execlog: Explicitly check for qemu_plugin_read_register() failure Peter Maydell
2025-07-10 15:21 ` Pierrick Bouvier
2025-09-01 16:19   ` Peter Maydell
2025-09-01 17:09 ` Alex Bennée

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).