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

Re: [PATCH v9 4/4] libs/guest: use Valgrind to detect various buffer overflows


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Frediano Ziglio <freddy77@xxxxxxxxx>
  • Date: Mon, 20 Jul 2026 11:11:19 +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=NXJHWPuAL4rkXjz51HNntRUzNe2yDQqqI6DSiDO6oVk=; fh=pmfIAu1zZ/y4MK+Ok8pH+KJi8l1vy8Cep5fL3L/xSOQ=; b=UjYKWNeehecMWy0s4MBeDvl7Zm6GBPX1n3HE9rfIXSR9biMyszHVCzk06/hr4hKOqd WBu1NGZyCiahXY5Y7o/mzsz78tEy1u5AlqKEbIm+SGZXYUhmnj7y5rIhGIZRAcUFl5MX CIxwagyDYSIicOa5mjscgLqpcmB5McEN7vHIVGS9u0bywHCEBoAtdhKlxHHESgvL8aZA 78DRKZU03tO6MkG0i23wbukKIvvY+f2zg3JLGwei3+9WieWjN3wMK5BV2/rhJVk6foBq 6zSC5XRT4WTaBQIZ5bwuqnh52JjAyAcGEHF5R3qkRWuORWrFGRw4hAhK/Kf415mwpGKb Gllw==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1784542292; cv=none; d=google.com; s=arc-20260327; b=jZbfnpZ6W2N/tK1cY+ob/wJ34u/bsTjrjEfdF6Tn//kjJm83KfnwR+CyYTST4coTFG uJBDGU+kPk2dA6H/SmHs4N3s9SJ8dFpm8XQdoVN4L0FAd8hePViLwjEtwxE1nnBJ31W1 ljtZ0WUMDeswJo2GBpUpgWnElKXmlfsRVE/Nkh53EMTQXzqCg8n3IITlT8W9o65+WhJx nNJNgdVckvLbexyZt5Y08w7H5M8vTlllYsL2hLkOsEqZuEl+KCuQJzuBlUevVjavkWYi kHIJEdSm8N0tary6iGBU9frG0EcA7LJZ3v4WN8Mn2fsddrPtNJNR/GvE9xVRBFgbx4PW GBMw==
  • 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: xen-devel@xxxxxxxxxxxxxxxxxxxx, Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Mon, 20 Jul 2026 10:11:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, 15 Jul 2026 at 14:38, Andrew Cooper <andrew.cooper3@xxxxxxxxxx> wrote:
>
> On 13/07/2026 9:48 pm, Frediano Ziglio wrote:
> > diff --git a/tools/libs/guest/xg_sr_common.h 
> > b/tools/libs/guest/xg_sr_common.h
> > index c07c6db59e..d3fc7f363e 100644
> > --- a/tools/libs/guest/xg_sr_common.h
> > +++ b/tools/libs/guest/xg_sr_common.h
> > @@ -245,13 +245,21 @@ struct xc_sr_context
> >              xc_hypercall_buffer_t dirty_bitmap_hbuf;
> >              struct xc_sr_context_save_buffers
> >              {
> > +                MEM_NOACCESS_BUFFER(na0, 16);
> >                  xen_pfn_t batch_pfns[MAX_BATCH_SIZE];
> > +                MEM_NOACCESS_BUFFER(na1, 16);
> >                  xen_pfn_t mfns[MAX_BATCH_SIZE];
> > +                MEM_NOACCESS_BUFFER(na2, 16);
> >                  xen_pfn_t types[MAX_BATCH_SIZE];
> > +                MEM_NOACCESS_BUFFER(na3, 16);
> >                  void *local_pages[MAX_BATCH_SIZE];
> > +                MEM_NOACCESS_BUFFER(na4, 16);
> >                  struct iovec iov[MAX_BATCH_SIZE + 2]; /* Headers + data. */
> > +                MEM_NOACCESS_BUFFER(na5, 16);
> >                  uint64_t rec_pfns[MAX_BATCH_SIZE];
> > +                MEM_NOACCESS_BUFFER(na6, 16);
> >                  int errors[MAX_BATCH_SIZE];
> > +                MEM_NOACCESS_BUFFER(na7, 16);
>
> If you're going to do this, use 64 not 16, and put iov[] at the end.  It
> is good practice to misalign large buffers by one cacheline, not that I
> suspect the access pattern in this algorithm is relevant.
>

Easily doable. Why put "iov" at the end?

> But, I'm not sure of the utility of doing this.  By removing the dynamic
> allocations you also prevent ASAN from working.
>

It can be extended to ASAN using "sanitizer/asan_interface.h",
specifically "ASAN_POISON_MEMORY_REGION" macro.

> We either care about them all (and keep the dynamic allocations), or
> don't care, and get rid of it all.  This half-way-house serves no good
> purpose.
>
> ~Andrew

Why is a half-way-house ?

Frediano



 


Rackspace

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