Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASAN intruments address taken arguments just for small types #823

Closed
marxin opened this issue Jun 14, 2017 · 4 comments
Closed

ASAN intruments address taken arguments just for small types #823

marxin opened this issue Jun 14, 2017 · 4 comments

Comments

@marxin
Copy link

marxin commented Jun 14, 2017

cat pr81040-3.cpp && clang++ pr81040-3.cpp -fsanitize=address && ./a.out
struct A
{
  int a[4];
};

static __attribute__ ((noinline)) int
goo (A *a)
{
  int *ptr = &a->a[0];
  return *(volatile int *) (ptr - 1);
}

__attribute__ ((noinline)) int
foo (A a)
{
  return goo (&a);
}

int
main ()
{
  return foo (A ());
}
=================================================================
==19878==ERROR: AddressSanitizer: stack-buffer-underflow on address 0x7ffea1dad07c at pc 0x0000004f32bb bp 0x7ffea1dad020 sp 0x7ffea1dad018
...

While following problem is not caught:

cat pr81040.cpp && clang++ pr81040.cpp -fsanitize=address && ./a.out
struct A
{
  int a[5];
};

static __attribute__ ((noinline)) int
goo (A *a)
{
  int *ptr = &a->a[0];
  return *(volatile int *) (ptr - 1);
}

__attribute__ ((noinline)) int
foo (A a)
{
  return goo (&a);
}

int
main ()
{
  return foo (A ());
}
[no output]

Apart from that is the sanitization of function arguments documented in manual?
Thanks.

@eugenis
Copy link
Contributor

eugenis commented Jun 14, 2017 via email

@morehouse
Copy link
Contributor

@eugenis Are you suggesting two passes for instrumentation? Pass 1 would copy byval arguments a second time to get an AllocaInst, and pass 2 would perform ASan as usual?

@eugenis
Copy link
Contributor

eugenis commented Jun 26, 2017 via email

@morehouse
Copy link
Contributor

Fixed by r308677 and r308387.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants