Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941465AbcKQRP0 (ORCPT ); Thu, 17 Nov 2016 12:15:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54710 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936284AbcKQRPD (ORCPT ); Thu, 17 Nov 2016 12:15:03 -0500 From: Josh Poimboeuf To: x86@kernel.org Cc: Peter Zijlstra , Vince Weaver , linux-kernel@vger.kernel.org, Ingo Molnar , Arnaldo Carvalho de Melo , davej@codemonkey.org.uk, dvyukov@google.com, Stephane Eranian Subject: [PATCH 1/2] unwind: prevent KASAN false positive warnings in guess unwinder Date: Thu, 17 Nov 2016 09:57:23 -0600 Message-Id: <61939c0b2b2d63ce97ba59cba3b00fd47c2962cf.1479398226.git.jpoimboe@redhat.com> In-Reply-To: <20161116130337.GT3142@twins.programming.kicks-ass.net> References: <20161116130337.GT3142@twins.programming.kicks-ass.net> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 17 Nov 2016 15:57:54 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1238 Lines: 42 The guess unwinder scans the entire stack, which can cause KASAN "stack-out-of-bounds" false positive warnings. Tell KASAN to ignore it. Reported-by: Peter Zijlstra Signed-off-by: Josh Poimboeuf --- arch/x86/kernel/unwind_guess.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/unwind_guess.c b/arch/x86/kernel/unwind_guess.c index 2d721e5..b80e8bf 100644 --- a/arch/x86/kernel/unwind_guess.c +++ b/arch/x86/kernel/unwind_guess.c @@ -7,11 +7,13 @@ unsigned long unwind_get_return_address(struct unwind_state *state) { + unsigned long addr = READ_ONCE_NOCHECK(*state->sp); + if (unwind_done(state)) return 0; return ftrace_graph_ret_addr(state->task, &state->graph_idx, - *state->sp, state->sp); + addr, state->sp); } EXPORT_SYMBOL_GPL(unwind_get_return_address); @@ -23,8 +25,10 @@ bool unwind_next_frame(struct unwind_state *state) return false; do { + unsigned long addr = READ_ONCE_NOCHECK(*state->sp); + for (state->sp++; state->sp < info->end; state->sp++) - if (__kernel_text_address(*state->sp)) + if (__kernel_text_address(addr)) return true; state->sp = info->next_sp; -- 2.7.4