[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v10 2/10] libs/guest: move batch_pfns into a separate structure


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Frediano Ziglio <freddy77@xxxxxxxxx>
  • Date: Thu, 13 Aug 2026 13:56:25 +0100
  • Arc-authentication-results: i=1; mx.google.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=wBkVfFa3I1a4xw0FRjxrPE/2JG7Xw2hq+rikZWfqA0M=; fh=9Qi9GuP6RaIdUPqcByINS4Lh6Dqx/46KOIm9RXXqrVw=; b=dzQM58jv1Pi55+cz4rAoFrm4Z48D07SpHcN3eHw568/GYUbt47gspWuFZuQBdJuRgt 0ROJnQP05JziYKdVLjr4a3BWRbSvUPaRBAEdrsxw+TpPGDE2xac1jMrIV+8yDNr0CJp5 M1DgjOP2J8YohePFTRWLwouua4MuTPxMXfauoCCvM707ewPC3WgCajbozgEmfWldDqwv rVfMPu45frH9jIMK5mPwm387yXCJFVhUVFOn/kcMtQkgy8ZEWGVVqGSps9icTK3QEX5j jBb9bdKQRj4mmKHoQFaaaup9ibwTB8SzsWMDtxQ6iILF8zxV0gfnBRYl4fFSQR30kyo8 Sq6g==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1786625796; cv=none; d=google.com; s=arc-20260327; b=ks2xryQh1+UQUU4XEQawZAy72cfItU+PUrJKKOYQO7rH4QHFudzTsPyKJnTDuBEKwF hGK9PisWM7D0kLLaNxlYYR1A66AP+NaenmcdVosMG25sAcT+ZrNFPIp4FxykkMrYdI4r 3aXVst4KHnU+UsD0VvrsDne+7Qwdi/g3ajKP5L7a55J6mPW4qIINZSJPygWsPkIs0r1V ZB3noKfvxMIoyPMjPVVGKcSmI15qCeaDuhsKYvo+f8F+I16ml+/3wPSeROM8L9MTiFl0 MI/d5zm4rM+zs/RS95PhO2LFgzptexlTifIM7Mz3/iAL9Z8eSO5hb7L+zm+JKOhXujwY 83EQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 13 Aug 2026 12:56:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, 13 Aug 2026 at 12:48, Andrew Cooper <andrew.cooper3@xxxxxxxxxx> wrote:
>
> On 13/08/2026 12:27 pm, Jan Beulich wrote:
> > On 13.08.2026 13:08, Andrew Cooper wrote:
> >> On 10/08/2026 11:30 am, Frediano Ziglio wrote:
> >>> Preparation for a followup patch "libs/guest: allocate various migration
> >>> arrays just once".
> >>>
> >>> Signed-off-by: Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>
> >>> Reviewed-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
> >> Coverity thinks this change has memory corruption.  I have to admit that
> >> I'm not completely sure why it's noticed now; possibly because now it
> >> can see the size of batch_pfns[] where previously it couldn't
> > I had looked into that too, and I'm puzzled that ...
> >
> >> ** CID 1700057:       Memory - corruptions  (OVERRUN)
> >> /tools/libs/guest/xg_sr_save.c: 284           in add_to_batch()
> >> _____________________________________________________________________________________________
> >> *** CID 1700057:         Memory - corruptions  (OVERRUN)
> >> /tools/libs/guest/xg_sr_save.c: 284             in add_to_batch()
> >> 278         int rc = 0;
> >> 279
> >> 280         if ( ctx->save.nr_batch_pfns == MAX_BATCH_SIZE )
> >> 281             rc = flush_batch(ctx);
> > ... the tool can't spot that flush_batch() resets ctx->save.nr_batch_pfns
> > to 0 in the success case. And ...
> >
> >> 283         if ( rc == 0 )
> > ... only the success case is what matters.
>
> Hmm.  Both flush_batch() and write_batch() are static, so fully visible
> to Coverity.
>
> I guess this means that Coverity failed to figure out the properties of
> write_batch(); it is a complicated function, even if it has become less
> complicated recently.
>
> I'm still advocating to remove the Valgrind logic rather than extend it
> in patch 3, and that will remove flush_batch() which might simplify things.
>
> ~Andrew

Hi,
   as said by Jan this is a false positive from Coverity.

It's not guaranteed that Coverity will detect that it's not an issue
if either valgrind macro is not called and/or flush_batch calling
write_batch, I would either test the change or simply add an explicit
Coverity comment.
If we decide to remove support for valgrind then what about the
valgrind patch on the series (4/10) ?

Frediano



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.