Message ID | 53A40729.2080702@partner.samsung.com |
---|---|
State | New |
Headers | show |
On Fri, Jun 20, 2014 at 02:04:25PM +0400, Maxim Ostapenko wrote: > > This patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61530. > > Tested on x86_64-unknown-linux-gnu, no regressions. > > Ok to commit? > > -Maxim > gcc/ChangeLog: > > 2014-06-20 Yury Gribov <y.gribov@samsung.com> > Max Ostapenko <m.ostapenko@partner.samsung.com> > > * asan.c (build_check_stmt): Add condition. Please align your name below Yury's (i.e. tab + 4 spaces indent). Also, please add PR sanitizer/61530 to both changelog entries. Ok with those changes. > > gcc/testsuite/ChangeLog: > > 2014-06-20 Yury Gribov <y.gribov@samsung.com> > Max Ostapenko <m.ostapenko@partner.samsung.com> > > * c-c++-common/asan/pr61530.c: New test. Jakub
On 06/20/2014 02:07 PM, Jakub Jelinek wrote: > On Fri, Jun 20, 2014 at 02:04:25PM +0400, Maxim Ostapenko wrote: >> This patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61530. >> >> Tested on x86_64-unknown-linux-gnu, no regressions. >> >> Ok to commit? >> >> -Maxim >> gcc/ChangeLog: >> >> 2014-06-20 Yury Gribov <y.gribov@samsung.com> >> Max Ostapenko <m.ostapenko@partner.samsung.com> >> >> * asan.c (build_check_stmt): Add condition. > Please align your name below Yury's (i.e. tab + 4 spaces indent). > Also, please add > PR sanitizer/61530 > to both changelog entries. Ok with those changes. >> gcc/testsuite/ChangeLog: >> >> 2014-06-20 Yury Gribov <y.gribov@samsung.com> >> Max Ostapenko <m.ostapenko@partner.samsung.com> >> >> * c-c++-common/asan/pr61530.c: New test. > Jakub > Thanks, done in r211846. -Maxim
gcc/ChangeLog: 2014-06-20 Yury Gribov <y.gribov@samsung.com> Max Ostapenko <m.ostapenko@partner.samsung.com> * asan.c (build_check_stmt): Add condition. gcc/testsuite/ChangeLog: 2014-06-20 Yury Gribov <y.gribov@samsung.com> Max Ostapenko <m.ostapenko@partner.samsung.com> * c-c++-common/asan/pr61530.c: New test. diff --git a/gcc/asan.c b/gcc/asan.c index 281a795..4d87dad 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -1654,6 +1654,7 @@ build_check_stmt (location_t location, tree base, tree len, if (size_in_bytes > 1) { if ((size_in_bytes & (size_in_bytes - 1)) != 0 + || !is_scalar_access || size_in_bytes > 16) size_in_bytes = -1; else if (align && align < size_in_bytes * BITS_PER_UNIT) diff --git a/gcc/testsuite/c-c++-common/asan/pr61530.c b/gcc/testsuite/c-c++-common/asan/pr61530.c new file mode 100644 index 0000000..e306a71 --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/pr61530.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-shouldfail "asan" } */ + +__attribute__((noinline,noclone)) void +foo (char *a, char *b) { + a[0] = b[0] = 0; + __builtin_memcpy(a, b, 4); +} + +int +main () { + char a, b; + foo (&a, &b); + return 0; +} + +/* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow" } */