Re: [pcpu] BUG: KASAN: use-after-scope in pcpu_setup_first_chunk+0x1e3b/0x29e2

From: Ard Biesheuvel
Date: Thu Nov 30 2017 - 14:58:51 EST


On 30 November 2017 at 19:56, Kees Cook <keescook@xxxxxxxxxxxx> wrote:
> On Thu, Nov 30, 2017 at 11:22 AM, Dennis Zhou <dennisszhou@xxxxxxxxx> wrote:
>> Hi Dmitry and Kees,
>>
>> On Thu, Nov 30, 2017 at 10:10:41AM -0800, Kees Cook wrote:
>>> > Are we sure that structleak plugin is not at fault? If yes, then we
>>> > need to report this to https://gcc.gnu.org/bugzilla/ with instructions
>>> > on how to build/use the plugin.
>>
>> I believe this is an issue with the structleak plugin and not gcc. The
>> bug does not show up if you compile without
>> GCC_PLUGIN_STRUCTLEAK_BYREF_ALL.
>>
>> It seems to be caused by the initializer not respecting the ASAN_MARK
>> calls. Therefore, if an inlined function gets called from a for loop,
>> the initializer code gets invoked bugging in the second iteration. Below
>> is the tree dump for the structleak plugin from the reproducer in the
>> previous email. In bb 2 of INIT_LIST_HEAD, the __u = {} is before the
>> unpoison call. This is inlined in bb 3 of main.
>
> Ah-ha, okay. Thanks for the close examination. Ard, is this something
> you have a few moment to take a look at?
>

I must admit that I am a bit out of my depth here. Also, I am quite
sure this is a pre-existing issue with the plugin which is triggered
more easily because it affects many more initializers.