linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dennis Zhou <dennisszhou@gmail.com>
To: Kees Cook <keescook@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>, Linux-MM <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	kasan-dev <kasan-dev@googlegroups.com>,
	Fengguang Wu <fengguang.wu@intel.com>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	Andrey Ryabinin <aryabinin@virtuozzo.com>
Subject: Re: [PATCH v2] KASAN: prohibit KASAN+STRUCTLEAK combination
Date: Fri, 20 Apr 2018 00:33:29 -0500	[thread overview]
Message-ID: <20180420053329.GA37680@big-sky.local> (raw)
In-Reply-To: <CAGXu5jK0fWnyQUYP3H5e8hP-6QbtmeC102a-2Mab4CSqj4bpgg@mail.gmail.com>

Hi,

On Thu, Apr 19, 2018 at 01:43:11PM -0700, Kees Cook wrote:
> On Thu, Apr 19, 2018 at 10:24 AM, Dmitry Vyukov <dvyukov@google.com> wrote:
> > Currently STRUCTLEAK inserts initialization out of live scope of
> > variables from KASAN point of view. This leads to KASAN false
> > positive reports. Prohibit this combination for now.
> >

I remember looking at this false positive in November. Please bear with
me as this is my first time digging through into gcc. It seems address
sanitizing is a process that starts adding instructions in the ompexp
pass, with I presume additional passes later doing other things.

It seems the structleak plugin isn't respecting the ASAN markings as it
also runs after ASAN starts adding instructions and before inlining.
Thus, the use-after-scope bugs from [1] and [2] get triggered by
subsequent iterations when looping over an inlined building block.

Would it be possible to run the structleak plugin say before
"*all_optimizations" instead of "early_optimizations"? Doing so has the
plugin run after inlining has been done placing initialization code in
an earlier block that is not a part of the loop. This seems to resolve
the issue for the latest one from [1] and the November repro case I had
in [2].

[1] https://lkml.org/lkml/2018/4/18/825
[2] https://lkml.org/lkml/2017/11/29/868

Thanks,
Dennis

--------
diff --git a/scripts/gcc-plugins/structleak_plugin.c b/scripts/gcc-plugins/structleak_plugin.c
index 10292f7..0061040 100644
--- a/scripts/gcc-plugins/structleak_plugin.c
+++ b/scripts/gcc-plugins/structleak_plugin.c
@@ -211,7 +211,7 @@ __visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gc
 	const struct plugin_argument * const argv = plugin_info->argv;
 	bool enable = true;
 
-	PASS_INFO(structleak, "early_optimizations", 1, PASS_POS_INSERT_BEFORE);
+	PASS_INFO(structleak, "*all_optimizations", 1, PASS_POS_INSERT_BEFORE);
 
 	if (!plugin_default_version_check(version, &gcc_version)) {
 		error(G_("incompatible gcc/plugin versions"));

  reply	other threads:[~2018-04-20  5:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-19 17:24 Dmitry Vyukov
2018-04-19 20:43 ` Kees Cook
2018-04-20  5:33   ` Dennis Zhou [this message]
2018-04-20  5:56     ` Dmitry Vyukov
2018-04-21 21:06       ` Dennis Zhou
2018-04-21 21:13         ` Kees Cook
2018-04-22  0:15           ` Dennis Zhou
2018-04-30 23:41 ` Kees Cook
2018-05-01  0:36   ` Dennis Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180420053329.GA37680@big-sky.local \
    --to=dennisszhou@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=aryabinin@virtuozzo.com \
    --cc=dvyukov@google.com \
    --cc=fengguang.wu@intel.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=keescook@google.com \
    --cc=linux-mm@kvack.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox