From patchwork Wed Feb 8 16:39:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 54499 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3560071wrn; Wed, 8 Feb 2023 08:42:26 -0800 (PST) X-Google-Smtp-Source: AK7set+oqgWkdaPDGH1bBI6wetHhqpAKzyYOdeHYu+WOhaPoIZoPoRPJtjygIPNkRXkvfgEfFrKb X-Received: by 2002:a62:ce01:0:b0:5a8:4de8:5425 with SMTP id y1-20020a62ce01000000b005a84de85425mr490050pfg.2.1675874546007; Wed, 08 Feb 2023 08:42:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675874545; cv=none; d=google.com; s=arc-20160816; b=L/9eu1o1RtKFYvy6viQK86uppG9HFj1R5vh1NxuItfSIVd/yZ6SorDB1nB5A9lMFtz mKz6a3JWq+YV7SxCy0jk9hXbM1vXi3jZTFEHckHzRM4gcUI1dAWRhsq7DJanNSDbUEYq NslEL5VXfVc6Z7sXsITkLZ+QrcXi9I0CClRlRCV7UJ7dk5cLyHRTUAtq+h7aaECpoFiu JEkVOwXtwwvOLqAN7FQxydnIES7Gnl5SUVFH55Q30YcQYzzEWi4KKoimj/kBEsWuh3Qw YB6ojbOiRo/ZvmCEiKE/rHcVqAfg13aFJgWpiYMSWyHAOoGPP35kXPkOgItQnf7q52ZW vGew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xvTbmEyJDH308Mr1kfAgZiukxgBd5MJ/ejaniJVGR/0=; b=LzfFI237alpr+E3M/y3jcKjoYaAV3NO596q/2K980wL1yBhx0uluY4gwU0ay2KbxYJ TTxx9bn02jRVApHeGt8jJBvOEMMwZvQLzDXtGas2quwVYsRznw51xUQmxoa1yPawE57O 4krYWeFDbqfATLNCQCFsDfK4J3P/6Goup7U1Bkx7I+gZAZk7um1yHBepImc64FcKihGh 3KBnNkATbSILKoN3BtmQAyxpwjrV1goNlqzv94Ecpl1XMH0RNfoa55NrwOd8yKl0Ljx/ wqChisVa8Vqrq1VXagWC18CZ3XESHIWQXgazqwo+hru82lfXhaJVMV6srbfElFxHtu5q sVGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q1mVQCj5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q14-20020a656a8e000000b004cf7904ba5csi17866225pgu.243.2023.02.08.08.42.13; Wed, 08 Feb 2023 08:42:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q1mVQCj5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231510AbjBHQku (ORCPT + 99 others); Wed, 8 Feb 2023 11:40:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231393AbjBHQkf (ORCPT ); Wed, 8 Feb 2023 11:40:35 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFE0839B9A for ; Wed, 8 Feb 2023 08:40:28 -0800 (PST) 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 06F60CE2247 for ; Wed, 8 Feb 2023 16:40:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70A29C433D2; Wed, 8 Feb 2023 16:40:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675874425; bh=wo/uMi/XKqmv4ZfEoOSWzfRWU2jBLxW4mP+OJhOyZ2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q1mVQCj5l1GVpNB7Kz/TXLUj/sGQvi8ZPMLHBFoMpbCI8ebfhNAivUbJywKe175rQ bALfIw4nCofYgEs6piTnSGSdsEm8jDvdH4Fi7hUHrpwgz1jzJ0/qpiONTPMbdhMhfG lZymSFQ4arYPRqfeu7IycuYSeZxd5AVofIMCzFs2filiBmYlRv7RALWgeFBCtIYVHx q6H07blzaLAo2gzBWlOaCGXQyLNuh1ryaFSwEh1+bfuEGG2QMg3jE+KoeA4o8epStL EdOwr6QVCbwTH9HyqS5q3EmXl/NeHZxL2V9Nbwftx+Xujj4z5x9hyEXVu+AQ+IoYb2 hyeGjbdlKaxsw== From: Arnd Bergmann To: Josh Poimboeuf , Peter Zijlstra , Alexander Potapenko , Andrew Morton , Marco Elver Cc: kasan-dev@googlegroups.com, Dmitry Vyukov , Andrey Ryabinin , Vincenzo Frascino , Andrey Konovalov , Arnd Bergmann , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] kmsan: disable ftrace in kmsan core code Date: Wed, 8 Feb 2023 17:39:56 +0100 Message-Id: <20230208164011.2287122-2-arnd@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230208164011.2287122-1-arnd@kernel.org> References: <20230208164011.2287122-1-arnd@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757281827694447816?= X-GMAIL-MSGID: =?utf-8?q?1757281827694447816?= From: Arnd Bergmann objtool warns about some suspicous code inside of kmsan: vmlinux.o: warning: objtool: __msan_metadata_ptr_for_load_n+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: __msan_metadata_ptr_for_store_n+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: __msan_metadata_ptr_for_load_1+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: __msan_metadata_ptr_for_store_1+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: __msan_metadata_ptr_for_load_2+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: __msan_metadata_ptr_for_store_2+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: __msan_metadata_ptr_for_load_4+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: __msan_metadata_ptr_for_store_4+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: __msan_metadata_ptr_for_load_8+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: __msan_metadata_ptr_for_store_8+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: __msan_instrument_asm_store+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: __msan_chain_origin+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: __msan_poison_alloca+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: __msan_warning+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: __msan_get_context_state+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: kmsan_copy_to_user+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: kmsan_unpoison_memory+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: kmsan_unpoison_entry_regs+0x4: call to __fentry__() with UACCESS enabled vmlinux.o: warning: objtool: kmsan_report+0x4: call to __fentry__() with UACCESS enabled Similar code already exists in kasan, which avoids this by skipping ftrace annotations, so do the same thing here. Fixes: f80be4571b19 ("kmsan: add KMSAN runtime core") Signed-off-by: Arnd Bergmann Acked-by: Alexander Potapenko --- mm/kmsan/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/kmsan/Makefile b/mm/kmsan/Makefile index 98eab2856626..389fd767a11f 100644 --- a/mm/kmsan/Makefile +++ b/mm/kmsan/Makefile @@ -16,6 +16,14 @@ CC_FLAGS_KMSAN_RUNTIME += -DDISABLE_BRANCH_PROFILING CFLAGS_REMOVE.o = $(CC_FLAGS_FTRACE) +# Disable ftrace to avoid recursion. +CFLAGS_REMOVE_core.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_hooks.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_init.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_instrumentation.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_report.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_shadow.o = $(CC_FLAGS_FTRACE) + CFLAGS_core.o := $(CC_FLAGS_KMSAN_RUNTIME) CFLAGS_hooks.o := $(CC_FLAGS_KMSAN_RUNTIME) CFLAGS_init.o := $(CC_FLAGS_KMSAN_RUNTIME)