Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758157AbcCCRRg (ORCPT ); Thu, 3 Mar 2016 12:17:36 -0500 Received: from mail-wm0-f47.google.com ([74.125.82.47]:33890 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754510AbcCCRRd convert rfc822-to-8bit (ORCPT ); Thu, 3 Mar 2016 12:17:33 -0500 MIME-Version: 1.0 In-Reply-To: <1457024068-2236-1-git-send-email-mark.rutland@arm.com> References: <1457024068-2236-1-git-send-email-mark.rutland@arm.com> Date: Thu, 3 Mar 2016 18:17:31 +0100 Message-ID: Subject: Re: [PATCHv2 0/3] KASAN: clean stale poison upon cold re-entry to kernel From: Alexander Potapenko To: Mark Rutland Cc: Linux Memory Management List , mingo@redhat.com, Andrew Morton , Andrey Ryabinin , catalin.marinas@arm.com, lorenzo.pieralisi@arm.com, peterz@infradead.org, will.deacon@arm.com, LKML , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3488 Lines: 87 Please replace "ASAN" with "KASAN". On Thu, Mar 3, 2016 at 5:54 PM, Mark Rutland wrote: > Functions which the compiler has instrumented for ASAN place poison on > the stack shadow upon entry and remove this poison prior to returning. > > In some cases (e.g. hotplug and idle), CPUs may exit the kernel a number > of levels deep in C code. If there are any instrumented functions on > this critical path, these will leave portions of the idle thread stack > shadow poisoned. > > If a CPU returns to the kernel via a different path (e.g. a cold entry), > then depending on stack frame layout subsequent calls to instrumented > functions may use regions of the stack with stale poison, resulting in > (spurious) KASAN splats to the console. > > Contemporary GCCs always add stack shadow poisoning when ASAN is > enabled, even when asked to not instrument a function [1], so we can't > simply annotate functions on the critical path to avoid poisoning. > > Instead, this series explicitly removes any stale poison before it can > be hit. In the common hotplug case we clear the entire stack shadow in > common code, before a CPU is brought online. > > On architectures which perform a cold return as part of cpu idle may > retain an architecture-specific amount of stack contents. To retain the > poison for this retained context, the arch code must call the core KASAN > code, passing a "watermark" stack pointer value beyond which shadow will > be cleared. Architectures which don't perform a cold return as part of > idle do not need any additional code. > > This is a combination of previous approaches [2,3], attempting to keep > as much as possible generic. > > Since v1 [4]: > * Clean from task_stack_page(task) > * Add acks from v1 > > Andrew, the conclusion [5] from v1 was that this should go via the mm tree. > Are you happy to pick this up? > > Ingo was happy for the sched patch to go via the arm64 tree, and I assume that > also holds for going via mm. Ingo, please shout if that's not the case! > > Thanks, > Mark. > > [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69863 > [2] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-February/409466.html > [3] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-February/411850.html > [4] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-March/413093.html > [5] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-March/413475.html > > Mark Rutland (3): > kasan: add functions to clear stack poison > sched/kasan: remove stale KASAN poison after hotplug > arm64: kasan: clear stale stack poison > > arch/arm64/kernel/sleep.S | 4 ++++ > include/linux/kasan.h | 6 +++++- > kernel/sched/core.c | 3 +++ > mm/kasan/kasan.c | 20 ++++++++++++++++++++ > 4 files changed, 32 insertions(+), 1 deletion(-) > > -- > 1.9.1 > -- Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Straße, 33 80636 München Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat sind, leiten Sie diese bitte nicht weiter, informieren Sie den Absender und löschen Sie die E-Mail und alle Anhänge. Vielen Dank. This e-mail is confidential. If you are not the right addressee please do not forward it, please inform the sender, and please erase this e-mail including any attachments. Thanks.