Re: [PATCH 2/3] t/helper/test-delta: segfault on OOB access
- From
Jeff King <peff@peff.net>
- Date
- Aug 29, 2018, 21:48 UTC
- Message-ID
- <20180829214836.GE29880@sigill.intra.peff.net>
- In-Reply-To
- <20180829214621.GD29880@sigill.intra.peff.net>
On Wed, Aug 29, 2018 at 05:46:21PM -0400, Jeff King wrote:
Show 24 quoted lines
> > I think even with ASAN, you'd still need read_in_full() or an mmap()
> > wrapper that fiddles with the ASAN shadow, because mmap() always maps
> > whole pages:
> >
> > $ cat mmap-read-asan-blah.c
> > #include <sys/mman.h>
> > #include <stdlib.h>
> > int main(void) {
> > volatile char *p = mmap(NULL, 1, PROT_READ|PROT_WRITE,
> > MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
> > p[200] = 1;
> > }
> > $ gcc -o mmap-read-asan-blah mmap-read-asan-blah.c -fsanitize=address
> > $ ./mmap-read-asan-blah
> > $
>
> Yeah, I was just trying to run your tests with ASan and couldn't
> convince it to complain. I also tried MSan, but no luck.
>
> > But that aside, you do have a point about having some custom hack for
> > a single patch.
>
> I'm also not sure how portable it is. Looks like we have a Windows
> wrapper for getpagesize(), but I don't see any other uses of mprotect().Actually, there is no real need for this test helper to use mmap. I suppose we could swap it out for malloc + read_in_full() and let ASan (or even valgrind) handle the tricky parts.
-Peff