From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C42F4C433FE for ; Mon, 3 Oct 2022 21:15:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229709AbiJCVPS (ORCPT ); Mon, 3 Oct 2022 17:15:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230268AbiJCVNx (ORCPT ); Mon, 3 Oct 2022 17:13:53 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BE0354657 for ; Mon, 3 Oct 2022 14:09:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id B8969CE0E5D for ; Mon, 3 Oct 2022 21:09:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CADFEC433C1; Mon, 3 Oct 2022 21:09:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1664831347; bh=CIGAWtOMzD+/duR7zl05oSCl1DZ/avZ9pKvrpTrXujc=; h=Date:To:From:Subject:From; b=bwjjUJ6LgZuzZqy/ZQkcor/MNke6qm6qiVE87W7q7iGS9tUVQnRJfeb5n1B9WCjGC bLGWZg9pxbRoUMTg6FvWFIP5lTC782NAJqL3yVKuvhUKTlE4ELdgXJl36Ghb2JHCAH W9fZCSUF7jBtoFyw6Xa/JF0hvpEVkRT1+SUIGD64= Date: Mon, 03 Oct 2022 14:09:07 -0700 To: mm-commits@vger.kernel.org, willy@infradead.org, viro@zeniv.linux.org.uk, vegard.nossum@oracle.com, vbabka@suse.cz, tglx@linutronix.de, sfr@canb.auug.org.au, rostedt@goodmis.org, rientjes@google.com, pmladek@suse.com, peterz@infradead.org, penberg@kernel.org, mst@redhat.com, mingo@redhat.com, mark.rutland@arm.com, luto@kernel.org, keescook@chromium.org, iii@linux.ibm.com, iamjoonsoo.kim@lge.com, herbert@gondor.apana.org.au, hch@lst.de, gregkh@linuxfoundation.org, gor@linux.ibm.com, elver@google.com, edumazet@google.com, ebiggers@kernel.org, ebiggers@google.com, dvyukov@google.com, cl@linux.com, bp@alien8.de, axboe@kernel.dk, ast@kernel.org, arnd@arndb.de, andreyknvl@google.com, andreyknvl@gmail.com, glider@google.com, akpm@linux-foundation.org From: Andrew Morton Subject: [merged mm-stable] x86-kmsan-dont-instrument-stack-walking-functions.patch removed from -mm tree Message-Id: <20221003210907.CADFEC433C1@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The quilt patch titled Subject: x86: kmsan: don't instrument stack walking functions has been removed from the -mm tree. Its filename was x86-kmsan-dont-instrument-stack-walking-functions.patch This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm ------------------------------------------------------ From: Alexander Potapenko Subject: x86: kmsan: don't instrument stack walking functions Date: Thu, 15 Sep 2022 17:04:13 +0200 Upon function exit, KMSAN marks local variables as uninitialized. Further function calls may result in the compiler creating the stack frame where these local variables resided. This results in frame pointers being marked as uninitialized data, which is normally correct, because they are not stack-allocated. However stack unwinding functions are supposed to read and dereference the frame pointers, in which case KMSAN might be reporting uses of uninitialized values. To work around that, we mark update_stack_state(), unwind_next_frame() and show_trace_log_lvl() with __no_kmsan_checks, preventing all KMSAN reports inside those functions and making them return initialized values. Link: https://lkml.kernel.org/r/20220915150417.722975-40-glider@google.com Signed-off-by: Alexander Potapenko Cc: Alexander Viro Cc: Alexei Starovoitov Cc: Andrey Konovalov Cc: Andrey Konovalov Cc: Andy Lutomirski Cc: Arnd Bergmann Cc: Borislav Petkov Cc: Christoph Hellwig Cc: Christoph Lameter Cc: David Rientjes Cc: Dmitry Vyukov Cc: Eric Biggers Cc: Eric Biggers Cc: Eric Dumazet Cc: Greg Kroah-Hartman Cc: Herbert Xu Cc: Ilya Leoshkevich Cc: Ingo Molnar Cc: Jens Axboe Cc: Joonsoo Kim Cc: Kees Cook Cc: Marco Elver Cc: Mark Rutland Cc: Matthew Wilcox Cc: Michael S. Tsirkin Cc: Pekka Enberg Cc: Peter Zijlstra Cc: Petr Mladek Cc: Stephen Rothwell Cc: Steven Rostedt Cc: Thomas Gleixner Cc: Vasily Gorbik Cc: Vegard Nossum Cc: Vlastimil Babka Signed-off-by: Andrew Morton --- arch/x86/kernel/dumpstack.c | 6 ++++++ arch/x86/kernel/unwind_frame.c | 11 +++++++++++ 2 files changed, 17 insertions(+) --- a/arch/x86/kernel/dumpstack.c~x86-kmsan-dont-instrument-stack-walking-functions +++ a/arch/x86/kernel/dumpstack.c @@ -177,6 +177,12 @@ static void show_regs_if_on_stack(struct } } +/* + * This function reads pointers from the stack and dereferences them. The + * pointers may not have their KMSAN shadow set up properly, which may result + * in false positive reports. Disable instrumentation to avoid those. + */ +__no_kmsan_checks static void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, unsigned long *stack, const char *log_lvl) { --- a/arch/x86/kernel/unwind_frame.c~x86-kmsan-dont-instrument-stack-walking-functions +++ a/arch/x86/kernel/unwind_frame.c @@ -183,6 +183,16 @@ static struct pt_regs *decode_frame_poin } #endif +/* + * While walking the stack, KMSAN may stomp on stale locals from other + * functions that were marked as uninitialized upon function exit, and + * now hold the call frame information for the current function (e.g. the frame + * pointer). Because KMSAN does not specifically mark call frames as + * initialized, false positive reports are possible. To prevent such reports, + * we mark the functions scanning the stack (here and below) with + * __no_kmsan_checks. + */ +__no_kmsan_checks static bool update_stack_state(struct unwind_state *state, unsigned long *next_bp) { @@ -250,6 +260,7 @@ static bool update_stack_state(struct un return true; } +__no_kmsan_checks bool unwind_next_frame(struct unwind_state *state) { struct pt_regs *regs; _ Patches currently in -mm which might be from glider@google.com are