|
[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
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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |