* [PATCH] Do not handle VLA in sanitization (PR sanitizer/81460).
@ 2017-07-28 8:44 Martin Liška
2017-07-28 9:20 ` Jakub Jelinek
0 siblings, 1 reply; 2+ messages in thread
From: Martin Liška @ 2017-07-28 8:44 UTC (permalink / raw)
To: gcc-patches; +Cc: Jakub Jelinek
[-- Attachment #1: Type: text/plain, Size: 721 bytes --]
Hi.
Simple patch that bails out when having a variable-length parameter of a function.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
Ready to be installed?
Martin
gcc/ChangeLog:
2017-07-17 Martin Liska <mliska@suse.cz>
PR sanitizer/81460
* sanopt.c (sanitize_rewrite_addressable_params): Do not rewrite
parameters that are of a variable-length.
gcc/testsuite/ChangeLog:
2017-07-17 Martin Liska <mliska@suse.cz>
PR sanitizer/81460
* gcc.dg/asan/pr81460.c: New test.
---
gcc/sanopt.c | 5 +++--
gcc/testsuite/gcc.dg/asan/pr81460.c | 8 ++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/asan/pr81460.c
[-- Attachment #2: 0001-Do-not-handle-VLA-in-sanitization-PR-sanitizer-81460.patch --]
[-- Type: text/x-patch, Size: 1184 bytes --]
diff --git a/gcc/sanopt.c b/gcc/sanopt.c
index b7740741d43..f6a3d6eadc7 100644
--- a/gcc/sanopt.c
+++ b/gcc/sanopt.c
@@ -894,11 +894,12 @@ sanitize_rewrite_addressable_params (function *fun)
for (tree arg = DECL_ARGUMENTS (current_function_decl);
arg; arg = DECL_CHAIN (arg))
{
- if (TREE_ADDRESSABLE (arg) && !TREE_ADDRESSABLE (TREE_TYPE (arg)))
+ tree type = TREE_TYPE (arg);
+ if (TREE_ADDRESSABLE (arg) && !TREE_ADDRESSABLE (type)
+ && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
{
TREE_ADDRESSABLE (arg) = 0;
/* The parameter is no longer addressable. */
- tree type = TREE_TYPE (arg);
has_any_addressable_param = true;
/* Create a new automatic variable. */
diff --git a/gcc/testsuite/gcc.dg/asan/pr81460.c b/gcc/testsuite/gcc.dg/asan/pr81460.c
new file mode 100644
index 00000000000..00c1bb7c9f2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/pr81460.c
@@ -0,0 +1,8 @@
+/* PR sanitizer/80460 */
+/* { dg-do compile } */
+
+int
+f (int a, struct { int b[a]; } c) /* { dg-warning "anonymous struct declared inside parameter list will not be visible outside of this definition or declaration" } */
+{
+ return c.b[0];
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Do not handle VLA in sanitization (PR sanitizer/81460).
2017-07-28 8:44 [PATCH] Do not handle VLA in sanitization (PR sanitizer/81460) Martin Liška
@ 2017-07-28 9:20 ` Jakub Jelinek
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2017-07-28 9:20 UTC (permalink / raw)
To: Martin Liška; +Cc: gcc-patches
On Fri, Jul 28, 2017 at 10:44:36AM +0200, Martin Liška wrote:
> Simple patch that bails out when having a variable-length parameter of a function.
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>
> Ready to be installed?
> Martin
>
> gcc/ChangeLog:
>
> 2017-07-17 Martin Liska <mliska@suse.cz>
>
> PR sanitizer/81460
> * sanopt.c (sanitize_rewrite_addressable_params): Do not rewrite
> parameters that are of a variable-length.
>
> gcc/testsuite/ChangeLog:
>
> 2017-07-17 Martin Liska <mliska@suse.cz>
>
> PR sanitizer/81460
> * gcc.dg/asan/pr81460.c: New test.
Ok, thanks.
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-07-28 9:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-28 8:44 [PATCH] Do not handle VLA in sanitization (PR sanitizer/81460) Martin Liška
2017-07-28 9:20 ` Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).