From patchwork Wed Feb 15 13:00: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: 57527 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp179497wrn; Wed, 15 Feb 2023 05:07:40 -0800 (PST) X-Google-Smtp-Source: AK7set/9k4DXG/LAtxM0tnv9m8OkzNO7YXT0Hpa7xA4OJoH5YQjIjXhvRM+AarQz3UgtzDSI7CLx X-Received: by 2002:a05:6402:121a:b0:4a2:5652:d8ba with SMTP id c26-20020a056402121a00b004a25652d8bamr2436868edw.18.1676466460075; Wed, 15 Feb 2023 05:07:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676466460; cv=none; d=google.com; s=arc-20160816; b=MHYyitkNbRQsiDtZ2DECU7aqqHjbxksbt8Y92Pg0v6jZwVbQrP0apxETrEesV/paEm yP1Wp/mvSfvUpIat6IS/V52Z4LTUG/qE3QgdTYYp8Md2BBwNM8P5vI1PQJaMzNmRnO0e V9/Ru9P54RLXJ1kfu/9O6tLMZ45l6fFWJb2EhIQkZVTKheESvyPCjavcJNyZUzm9NR/R VIvVh0clYU7ELqUbi0LVYFevU8cSEj7N6VZZVxoEdC5ZapfhRJez/4L9wNYu2jcYAKzC 5MRq9I0BIfAhnsS6Rz2zvCeEvxQ/wymMhIUnj/ir0kM2LLb5tdwRvjreOGwRvMv6A36h uYBw== 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=eEGF2dhJHQrOcjGWiEp/1K3Pqyv63qcrypNyumV54Yg=; b=gIGnGjcYlOFSvbxiXp1owudb49yWMBUhWuzolIahxiRyDyvjag+LlBzt/jNONqXUZm 32Fk2zwpw7UzcfJITM+4FURG1vREkafu2Rlw4Ip/WRifmkP2/DAuU9EbPZCi3jPGHKup 2GNxY+CMAsfgwNUnsFe08PdubyHQAlBZkKavZ65/ocsWGQcnshHd9qMEZuwUCcIJ6PDe k1tkUoTBV4BqHboFT95jpoNqvuAf1XVjZBVacYF52xFaScOsz9rOEawzh4HhXu+3mrup 9Qds8futIEfAlwaV+TT4fHhvtyXQ0AUuKQodBomzG8+biXWDuf2G+HXZmw1dovZWJ/r7 sLEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=R0VoQz6v; 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 f18-20020a056402005200b0049e37585a7bsi21887552edu.196.2023.02.15.05.07.16; Wed, 15 Feb 2023 05:07:40 -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=R0VoQz6v; 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 S230335AbjBONBU (ORCPT + 99 others); Wed, 15 Feb 2023 08:01:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233917AbjBONBS (ORCPT ); Wed, 15 Feb 2023 08:01:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61F7ACA3B for ; Wed, 15 Feb 2023 05:01:17 -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 dfw.source.kernel.org (Postfix) with ESMTPS id F1CF261B94 for ; Wed, 15 Feb 2023 13:01:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6819BC4339B; Wed, 15 Feb 2023 13:01:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676466076; bh=gjHAHHqwYm8o1x992R2kWv27BpeHlDcrRDtNIB6oM0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R0VoQz6vcJRMvwJmX8jY9JYLJ6IEQOqKG5hN5MD23CQx5K1TPX4HjelS4VNioCyw3 rRxumsiccf2phYjGDdQoD3SeM5AZmc6cvjwZOvxHWTc7NiBmbiL8nPtDgsnB1Jq3VH JAYDeL/C0k2JAfyi1BNJVf4BvguAmuyg/PmI++jrkzaYSGIN8RysFq6bJzEuLGj04Q HT0tIBlddiEC6XTcvgm7A2hdOIx6kcZAuIlkjEwzBSYfje5AnZ3Aq+bpjPsBy105BX 37oYXOxUG6vwUT06gEDFQ/0EXnoWg6kDAOGQfeO58yaYtOsG3XL1eXaETFTDTIozDq APgN5Cqa7Mg9g== From: Arnd Bergmann To: Andrew Morton , Josh Poimboeuf , Peter Zijlstra Cc: Arnd Bergmann , Alexander Potapenko , Andrey Konovalov , Andrey Ryabinin , Dmitry Vyukov , Kuan-Ying Lee , Marco Elver , Vincenzo Frascino , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] [v2] kasan: mark addr_has_metadata __always_inline Date: Wed, 15 Feb 2023 14:00:56 +0100 Message-Id: <20230215130058.3836177-2-arnd@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215130058.3836177-1-arnd@kernel.org> References: <20230215130058.3836177-1-arnd@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1757902494502172495?= X-GMAIL-MSGID: =?utf-8?q?1757902494502172495?= From: Arnd Bergmann When the compiler decides not to inline this function, objtool complains about incorrect UACCESS state: mm/kasan/generic.o: warning: objtool: __asan_load2+0x11: call to addr_has_metadata() with UACCESS enabled Acked-by: Peter Zijlstra (Intel) Reviewed-by: Marco Elver Reviewed-by: Andrey Konovalov Signed-off-by: Arnd Bergmann --- v2: fix objdump/objtool typo --- mm/kasan/kasan.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index 3231314e071f..9377b0789edc 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -297,7 +297,7 @@ static inline const void *kasan_shadow_to_mem(const void *shadow_addr) << KASAN_SHADOW_SCALE_SHIFT); } -static inline bool addr_has_metadata(const void *addr) +static __always_inline bool addr_has_metadata(const void *addr) { return (kasan_reset_tag(addr) >= kasan_shadow_to_mem((void *)KASAN_SHADOW_START)); @@ -316,7 +316,7 @@ bool kasan_check_range(unsigned long addr, size_t size, bool write, #else /* CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS */ -static inline bool addr_has_metadata(const void *addr) +static __always_inline bool addr_has_metadata(const void *addr) { return (is_vmalloc_addr(addr) || virt_addr_valid(addr)); } From patchwork Wed Feb 15 13:00:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 57530 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp179922wrn; Wed, 15 Feb 2023 05:08:26 -0800 (PST) X-Google-Smtp-Source: AK7set/p9s1qZbwCJn3jwu8QzPKOcnNtsDRpYyx1/uvmtOhVjy05JaDTIwntjhznAlukgKDdyBrh X-Received: by 2002:a17:90a:15:b0:230:bb46:787d with SMTP id 21-20020a17090a001500b00230bb46787dmr2886255pja.37.1676466506516; Wed, 15 Feb 2023 05:08:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676466506; cv=none; d=google.com; s=arc-20160816; b=Ovp7T8Ix/3qLfD7geKMQN8baL9zTXp1gUPd3TIFqu14mBPC15qkNQLig8m/+gbJpiw IbHOG5oHyF2pXyYQEC7xLUrfrC0qKXFJzNEddQuYQVw0An4Ggq1rg7RcCdMyWDPqmtUX HlvDjjP3tx0WCVS983hAAO187JE+cjCTptJy2PycRF/cdS6/DB2uENgQ2xukHTkeS5ME 5h/Vlnp6MfJHaTuaVsTwLZ6UfnDRY8KdpmXJCY78LA8vP/FsbxLVNS1b+MxnENKRCNMI N2m1iaUDhegHy9Hnhlk1XHGfk4nt3ExL2qbqJ/5rsTOxB0q/rHN5XRp3PlC6KAnmfyD4 2hDA== 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=BcBkGQIO+rb2iXcsy77cxTrQw5FMHDgpD40SU+OF/kE=; b=XpmEUNnu5bw2h7CTYB82YuTT2Sfd6EOZYOtfDKX5amBzBbO1GHgr5sEzmC7rfCwQCl KRz8PmIeRt3OAi854060e7FFd44KdJqQOGPRrkxm8EgIK6qEIMYnXUvC/ufAV/gZYrpu N8JyZ1BYGTYlreGwfnPUNICg8PKTz2bhq+DOCqSOelInhNWXG+QzY816Byn9dk8ipsia 8r/wYtujh+oR7QFm4sF2W/F22YVC/2og/4nm4JLYw8SuO4GUTwTCzo79XLhIRfXzhleI wQO8rwOkz8/4/ACsYjLvAinB/2KuGWs+ZLzPod+aKjJUUWq0sXZ8pI9wD0lq1+qW/k5A Utag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Lu0J/SbI"; 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 s25-20020a639259000000b004fbd5328bc0si5279463pgn.562.2023.02.15.05.08.12; Wed, 15 Feb 2023 05:08:26 -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="Lu0J/SbI"; 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 S233974AbjBONB2 (ORCPT + 99 others); Wed, 15 Feb 2023 08:01:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233243AbjBONBY (ORCPT ); Wed, 15 Feb 2023 08:01:24 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF4E432E7D for ; Wed, 15 Feb 2023 05:01:22 -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 ams.source.kernel.org (Postfix) with ESMTPS id 40593B821C3 for ; Wed, 15 Feb 2023 13:01:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D33BFC4339C; Wed, 15 Feb 2023 13:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676466079; bh=2ZHB4kXmO9QIInQQshGPPjNMQQVO/B7ppuR6Groskjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lu0J/SbIWS9+ixPccMmPzBFd9wQGiDgHS5tGpdfzu2X1ttNScPufVWKN4YxkY+2Fd yEvd/lrDUelvVUcKUlWelk6i41CpM+iakWnqD+45tJAakIshZlQoIASn/DShugRUdF LIAYGi8BbC04s3E6k7lyzwqfRsRdZFZ2paJdd6c4ZESmWCoX17BK/JqQwnUGpLEz9e b6yfeo3A3vbGVPmkyqDkRZ6v9UTwjWYjn4t9p9uVQmW1sSiZEzZPXmsGTmsHHdhxaq 2hmIuC3PhRN+4c4XlFCh79d4evkN+67G1XPbt2USq4bhhs0V1sugylow7OFJb9XcSi gi/4JcPUzP61A== From: Arnd Bergmann To: Andrew Morton , Josh Poimboeuf , Peter Zijlstra Cc: Arnd Bergmann , Alexander Potapenko , Andrey Konovalov , Andrey Ryabinin , Dmitry Vyukov , Kuan-Ying Lee , Marco Elver , Vincenzo Frascino , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] [v2] kmsan: disable ftrace in kmsan core code Date: Wed, 15 Feb 2023 14:00:57 +0100 Message-Id: <20230215130058.3836177-3-arnd@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215130058.3836177-1-arnd@kernel.org> References: <20230215130058.3836177-1-arnd@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1757902543613892492?= X-GMAIL-MSGID: =?utf-8?q?1757902543613892492?= 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 The Makefile contained a line to turn off ftrace for the entire directory, but this does not work. Replace it with individual lines, matching the approach in kasan. Fixes: f80be4571b19 ("kmsan: add KMSAN runtime core") Acked-by: Alexander Potapenko Signed-off-by: Arnd Bergmann --- v2: remove the old "CFLAGS_REMOVE.o = $(CC_FLAGS_FTRACE)" line --- mm/kmsan/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mm/kmsan/Makefile b/mm/kmsan/Makefile index 98eab2856626..91cfdde642d1 100644 --- a/mm/kmsan/Makefile +++ b/mm/kmsan/Makefile @@ -14,7 +14,13 @@ CC_FLAGS_KMSAN_RUNTIME := -fno-stack-protector CC_FLAGS_KMSAN_RUNTIME += $(call cc-option,-fno-conserve-stack) 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) From patchwork Wed Feb 15 13:00:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 57525 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp179308wrn; Wed, 15 Feb 2023 05:07:19 -0800 (PST) X-Google-Smtp-Source: AK7set9TertCx95v+FAu2Kr0rVY28jx7anDbUEi5IubmKPBKtcHfyfBB+RlySurGLan8VHSTK2mh X-Received: by 2002:a17:906:f1d8:b0:887:74b2:811 with SMTP id gx24-20020a170906f1d800b0088774b20811mr1832741ejb.74.1676466439573; Wed, 15 Feb 2023 05:07:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676466439; cv=none; d=google.com; s=arc-20160816; b=QCXzMGa/CoG9N6eAfX8wigHhYng6n21K8qzMIxEYyrNDSQR9IRfXEYxaXKKdjMxAC3 QIbqrJ2ooewbNIvSPz0TL+N5lZGGQ5jU6zw+aDTdJITcJyFvPbgsBdVw4I8JN5OIhrQe JyLkMKlucIaMsC0JufIfrpvHpdXnDLsIKcn+4sTaynRsPXN+orE02hSyjqYkPh2YqK7e D0Swk2lxJqGr2UWrKpBaUSUgn+01t5QXgC8H/kFYcwjQKkF13jrTChbn0ztN/oXscw9W loSIqK6s5LwfAq5vKyJFAqblYnF/BhS2IommudNxK5EKSYfYURAAEEG5NGvWeCGISYqH xhig== 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=TmXc5XX7mQ4tyyYhso+an7R7TS3SjE8ukS97BSt6G1c=; b=vAASvRHijPkTufjq8lyp9QzA2jZOSOfEKmZtN4t7nvwbPfWqvG4T5I2ovWC7fVJ9zS ZMIbQlNLVG2ANyyn6Q6p0ILa1fSKXT0wbWbz+2XJm3YYHvurjjDMbcjSWkoO3MiUIa4A 9BGb98f9jpdcABc+z1+ShwKf0cowR8Sb7jwPBB6KIPlyHnWdKx8guvRJgE9RB8vHf6XW TVqF5YtJMF9xkMIe+f6qiwD1vW+PCqgw8aq1RZOYwVWX91Ds92kuTxH90pKeHijeYcC/ sxyTZZV6qjTDYDbROQphwCvS7am5qyB/Wn2QLL9B+/CFRiPJ8Y4LlUg3HPzrQqLo9SSc 9OXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=trjIqlwZ; 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 l8-20020a170907914800b008b146f78141si1345760ejs.974.2023.02.15.05.06.55; Wed, 15 Feb 2023 05:07:19 -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=trjIqlwZ; 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 S233993AbjBONBb (ORCPT + 99 others); Wed, 15 Feb 2023 08:01:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233786AbjBONB1 (ORCPT ); Wed, 15 Feb 2023 08:01:27 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0854431E33 for ; Wed, 15 Feb 2023 05:01:26 -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 ams.source.kernel.org (Postfix) with ESMTPS id A7164B821C4 for ; Wed, 15 Feb 2023 13:01:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4813DC433EF; Wed, 15 Feb 2023 13:01:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676466083; bh=LCrzUXqbVxh67TyCMfdqY6tY7QeA2lgRgFNm/o1Clp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=trjIqlwZyO+lwC6wY2BwIi2/mShc9WUDm9YrsjZ24D2fsCN/XdBERQW+gmteC8VNN YK4uldLchrzIGLzJ3nz93yG0XY7arZ3i4YgZ2Lc9Mu9lA7KxV1k4dey5CH+NCH8XPe T12gdgRSJvbK/HMFSkuKhQgI07jjONQ6YMov3TAIPRXlQM0Xh0TamEqo1+hkqCwWit A/HGHQ8tTFEqzT5Y7HhQ4ZkU+ePlRphqBw0io5rRVIm9/ye4Ja+OE3AAvycLdCH3OP m22aM8Hqp22iEmk+ci6F6qJRnjS2DdmigNWX2mZU7KKQzMWrXtKyApa/5ozRNmPlry yABFYRztl4azg== From: Arnd Bergmann To: Andrew Morton , Josh Poimboeuf , Peter Zijlstra Cc: Arnd Bergmann , Alexander Potapenko , Andrey Konovalov , Andrey Ryabinin , Dmitry Vyukov , Kuan-Ying Lee , Marco Elver , Vincenzo Frascino , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] [v2] objtool: add UACCESS exceptions for __tsan_volatile_read/write Date: Wed, 15 Feb 2023 14:00:58 +0100 Message-Id: <20230215130058.3836177-4-arnd@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215130058.3836177-1-arnd@kernel.org> References: <20230215130058.3836177-1-arnd@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1757902472933120198?= X-GMAIL-MSGID: =?utf-8?q?1757902472933120198?= From: Arnd Bergmann A lot of the tsan helpers are already excempt from the UACCESS warnings, but some more functions were added that need the same thing: kernel/kcsan/core.o: warning: objtool: __tsan_volatile_read16+0x0: call to __tsan_unaligned_read16() with UACCESS enabled kernel/kcsan/core.o: warning: objtool: __tsan_volatile_write16+0x0: call to __tsan_unaligned_write16() with UACCESS enabled vmlinux.o: warning: objtool: __tsan_unaligned_volatile_read16+0x4: call to __tsan_unaligned_read16() with UACCESS enabled vmlinux.o: warning: objtool: __tsan_unaligned_volatile_write16+0x4: call to __tsan_unaligned_write16() with UACCESS enabled As Marco points out, these functions don't even call each other explicitly but instead gcc (but not clang) notices the functions being identical and turns one symbol into a direct branch to the other. Fixes: 75d75b7a4d54 ("kcsan: Support distinguishing volatile accesses") Acked-by: Marco Elver Signed-off-by: Arnd Bergmann --- tools/objtool/check.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index b0b467d9608a..da52ce861cc2 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1237,6 +1237,8 @@ static const char *uaccess_safe_builtin[] = { "__tsan_atomic64_compare_exchange_val", "__tsan_atomic_thread_fence", "__tsan_atomic_signal_fence", + "__tsan_unaligned_read16", + "__tsan_unaligned_write16", /* KCOV */ "write_comp_data", "check_kcov_mode",