From patchwork Wed Feb 8 16:39:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 54493 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3559529wrn; Wed, 8 Feb 2023 08:41:26 -0800 (PST) X-Google-Smtp-Source: AK7set9Aop1A+WyPeFqlBZXxDjxvTo2FAt+vmh1q9APLP2t0lYKSTOfpjc56dgZydeoCVXaPlNuG X-Received: by 2002:a17:90a:4b4a:b0:22c:64c6:b7c4 with SMTP id o10-20020a17090a4b4a00b0022c64c6b7c4mr7663409pjl.2.1675874485697; Wed, 08 Feb 2023 08:41:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675874485; cv=none; d=google.com; s=arc-20160816; b=fSJFJWT6c0dBM5S7uvslYwMNWdd8C/3LPeGMcmHLZVlwT/MJoz0JlE5t67sBXD15Ia q+XGkIfC9qiyf+mePywLD9n1nverMPJAa4zWCHnPU6DbDGu5NezrtSTDmae5ey7M/nys wfMS7cqLFVWKDBrwxMt+WLQnWQM/oSCOBIfKCYB6esI5Ac0DLpkaHIPhJu5XRHOhTMBd 6L6W8X1Yxe08mJe44V5fStDYxvR0I8s7L5ZnW39UBG4zVtN7lTG89NSVHC30YXaaLH+d 33MLRxB049w1WaC1fa3ReV2msoY97uNUNUUw8FMLJg6XJM+3v7LFY20JV31dMhBkqBXr KezA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=/9gCt/DXMCz5FsPggffU4ASpM56svrE/8oAUHWynS+o=; b=uWabV5fFeJ2RalNcmQe/CtbBi40Yqg5aYedotQM5qn10lXlMxJq79HhP2+cS6FCCeU TK2vBsKymt4sFSoW0LFIOk0J/URM5o3lpluvOYuF8jgL8A/ZFzEX8tLOI5pwwkmFD+fm G4nKZqZmpm5y1mxGht5DCiG9SYDPFHGA6x5+TnG4GN0gfEQHrcaNxTQAiK9LJu6Yb9ip n6rU60ntMtdWjQpxS0/RWnBE/HAKq3k6O9Mu5bJRK8U74KY4ETVIz2jZbZPb1VKCuw/V 5ZBJ4bqiM9LVx7fm1qWTq7rWIZKh/SRyhIXTykWB2ShlHE5FhfvjczyEJ4nN2th3DxWT nZnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WbTBU4bb; 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 y63-20020a638a42000000b004fb1d903b3csi4845661pgd.37.2023.02.08.08.41.11; Wed, 08 Feb 2023 08:41: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=WbTBU4bb; 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 S230331AbjBHQkh (ORCPT + 99 others); Wed, 8 Feb 2023 11:40:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231670AbjBHQk0 (ORCPT ); Wed, 8 Feb 2023 11:40:26 -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 8ECF64DE2C for ; Wed, 8 Feb 2023 08:40:21 -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 9ED27CE2246 for ; Wed, 8 Feb 2023 16:40:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CEC1C433D2; Wed, 8 Feb 2023 16:40:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675874417; bh=+5YG0ew14LGHHwHHweKoIWpxQOFrZZOOumCgJpF1eCM=; h=From:To:Cc:Subject:Date:From; b=WbTBU4bbJfZy8N5AHyAEElkmZ0+jh4Z0bDAxfpPzv17D5tzwUiCXxp8oPouaj2eK/ 1BmCiw2rGIGBCI8XnBZ5ZvV3JYw1KgXr6F3oHdHze/wuRGyFR2hqdEfX0xFPNoMGRO /TNYy8dw4r4PBkTxJXd36hXR9rtLam1yu0wIUVRpwwxyAkSNTxt1QKp9rf/zM58dQY W2knpPx/3Ejks1aXkMt4xBmnThZp0+qPiXgff1uXhn7MIKU2WqlFBjJ2QEs2+nw0ua 2Q56IVf/AplSFNOOwaudlBMZT7cy5+N44tv0fRss47/F2TYFsmdVV31/d4e5Hl1Z+5 t0VunwZfiXPzA== From: Arnd Bergmann To: Josh Poimboeuf , Peter Zijlstra , Andrey Ryabinin , Andrew Morton Cc: kasan-dev@googlegroups.com, Marco Elver , Dmitry Vyukov , Alexander Potapenko , Vincenzo Frascino , Andrey Konovalov , Arnd Bergmann , Kuan-Ying Lee , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] kasan: mark addr_has_metadata __always_inline Date: Wed, 8 Feb 2023 17:39:55 +0100 Message-Id: <20230208164011.2287122-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.1 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?1757281764410696138?= X-GMAIL-MSGID: =?utf-8?q?1757281764410696138?= From: Arnd Bergmann When the compiler decides not to inline this function, objdump complains about incorrect UACCESS state: mm/kasan/generic.o: warning: objtool: __asan_load2+0x11: call to addr_has_metadata() with UACCESS enabled Signed-off-by: Arnd Bergmann Reviewed-by: Marco Elver Acked-by: Peter Zijlstra (Intel) Reviewed-by: Andrey Konovalov --- 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 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) From patchwork Wed Feb 8 16:39: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: 54501 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3560221wrn; Wed, 8 Feb 2023 08:42:44 -0800 (PST) X-Google-Smtp-Source: AK7set9H1o6yO6VNLhL1ZxeyoycOe0NJ+RW20fQAyz5NsVR8vLfbtqzswRNz5mPvqLRw8oFQYbDa X-Received: by 2002:a62:828c:0:b0:5a8:4d93:8864 with SMTP id w134-20020a62828c000000b005a84d938864mr618518pfd.3.1675874563831; Wed, 08 Feb 2023 08:42:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675874563; cv=none; d=google.com; s=arc-20160816; b=PnOj+qB2bSKlaG6ta9OxF/M+mlrHBBCzmWiL/t/pPVtflqgx6ss3l+CHXSmGt097Nc wfRYFYV8bFR8NtpBb4rW0Czkj2lSJ7Z4jKLMqyk53dDBbJiQYITlfMQszJiEkbZm8MVP UntOpjQkAzANGBDY+WRBSbOGbDqs1/u39r+1z33SL5FghBkXijZa/g2YqrDRkGMzya41 jhIq92Po2755w0bwUY6+psQcUKwH8lA3di7fexnHYwxk5cg2gmpnYkFjQs9DJEDXqDYb o7qJGYB0NN6LDSLuIktnRlqVGpux/esHWuZrAL87z3oLyp15YVbFfCHQdD5qgS1cJ/Ak MXMg== 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=jF2tD5+GeZfdR+u2uMsmszDgDaCRZ/+kDNXUB3+Ta/s=; b=gzfr/43Z49/hxbaKdZ3dAqZJQoFiIxDC6IMa2FqFhshtTT35hXCRm3x1xMLUMlS6/q P7R6LjK56+BchLxPUWxL+96ZNj6kl5wbXm3UsIB9beay5bQrow/znGllCZBFCTqH276A xm5Qqia13v1R3bcCgMJ7Un0MYKMy8IqcyuX+3AgZ7TF9tJSG92QNPAewPa6cWvplmIfw e7QlCZQ3qhjAHSXAITt0+GwNFKEgWPd0LxBl4yfyk/mtQmm16AU/H96VrZ5sOwmauo5F GdE9KFDoTH1NeiIyZrhDT3cRQjQC5MKo98le5aIpqP4hg8zjBXeNrUTRYteYL8hZsLuH DMbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ewkkWjBP; 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 186-20020a6218c3000000b0057509d0411esi18242685pfy.192.2023.02.08.08.42.30; Wed, 08 Feb 2023 08:42:43 -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=ewkkWjBP; 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 S231668AbjBHQlI (ORCPT + 99 others); Wed, 8 Feb 2023 11:41:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231644AbjBHQkh (ORCPT ); Wed, 8 Feb 2023 11:40:37 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 701D74DE00 for ; Wed, 8 Feb 2023 08:40:33 -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 0D09D61734 for ; Wed, 8 Feb 2023 16:40:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52B31C433EF; Wed, 8 Feb 2023 16:40:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675874432; bh=GGeAEaRt65it3PXlOo+5hSPcgSq11pcqA9eKquHfzZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ewkkWjBPkbuENbTspA2LMFcdZN6Zua6IVR1vYYB/KD3R8+7kCWOzWIfI2C/nmkE3G zMm/o67vRk2/twf7DStLfKvMwqqsWuL0MN77JEipi6dwrltf0RiCyAWs5Wchgq0UjO rbO3uDttgAqTQeVRyfLfxxrAmoSQk+4BJqwIrjQ2gFvPeqWPypeJRxy+5AxKYMbpOx NDJMkTEda9UD98e1awEk2Hf054FJmvlaq83KvxIqVAUeYsOG52SOMXxSS3VXKE9YI5 iMzucZ84z3ZsxGPSIkYVCSmQug3Kh521Mo+qCZm1fRabb9tzLa7fOJvFKIwMUulRCE TioEaRvHFnyCQ== From: Arnd Bergmann To: Josh Poimboeuf , Peter Zijlstra Cc: kasan-dev@googlegroups.com, Marco Elver , Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin , Vincenzo Frascino , Andrey Konovalov , Arnd Bergmann , Borislav Petkov , Miroslav Benes , Michael Ellerman , Sathvika Vasireddy , linux-kernel@vger.kernel.org Subject: [PATCH 3/4] objdump: add UACCESS exception for more stringops Date: Wed, 8 Feb 2023 17:39:57 +0100 Message-Id: <20230208164011.2287122-3-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?1757281846755804166?= X-GMAIL-MSGID: =?utf-8?q?1757281846755804166?= From: Arnd Bergmann The memset/memmove/memcpy string functions are wrapped in different ways based on configuration. While the __asan_mem* functions already have exceptions, the ones called from those do not: mm/kasan/shadow.o: warning: objtool: __asan_memset+0x30: call to __memset() with UACCESS enabled mm/kasan/shadow.o: warning: objtool: __asan_memmove+0x51: call to __memmove() with UACCESS enabled mm/kasan/shadow.o: warning: objtool: __asan_memcpy+0x51: call to __memcpy() with UACCESS enabled vmlinux.o: warning: objtool: .altinstr_replacement+0x1406: call to memcpy_erms() with UACCESS enabled vmlinux.o: warning: objtool: .altinstr_replacement+0xed0: call to memset_erms() with UACCESS enabled vmlinux.o: warning: objtool: memset+0x4: call to memset_orig() with UACCESS enabled vmlinux.o: warning: objtool: memset+0x4: call to memset_orig() with UACCESS enabled Add these to the list as well. Signed-off-by: Arnd Bergmann --- tools/objtool/check.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 0f67c6a8bc98..e8fb3bf7a2e3 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1248,6 +1248,13 @@ static const char *uaccess_safe_builtin[] = { "clear_user_erms", "clear_user_rep_good", "clear_user_original", + "__memset", + "__memcpy", + "__memmove", + "memset_erms", + "memcpy_erms", + "memset_orig", + "memcpy_orig", NULL }; From patchwork Wed Feb 8 16:39: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: 54500 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3560194wrn; Wed, 8 Feb 2023 08:42:40 -0800 (PST) X-Google-Smtp-Source: AK7set8OHKC/pUArsGlIvbzCL1Q5UZccH3JCw376yd8pOxpJZXp6llHQQ9vHDSA6kUIuFvMHU0VI X-Received: by 2002:a17:902:d48a:b0:196:6308:c9d3 with SMTP id c10-20020a170902d48a00b001966308c9d3mr8666487plg.0.1675874559998; Wed, 08 Feb 2023 08:42:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675874559; cv=none; d=google.com; s=arc-20160816; b=d+IesmFi5Q3bGrzYdRkkG70cHZt9zCdvr30ZqVX7j3hp7ziLz2HKDWI3QLKSvBlKm3 LT9eNJ+jj9dfuuTR/K/mHDp4g24wsbtueasZWzhQVRVESOhvKeZ5NimHnWhcttsPAm/G OMwJ1uzI+kmR5O+kTQ5GeM8aj8OpM4YOWMFJ0Z8F3DiPtneqQ3o3BT0xY1yZ0VSmljYG rwkdJPe61R4GQHwFZIHBS+ZZH/SbZKnMirc0tuEZ4zn3hPj1tmRRQMgS2+ozdrEueqAS 00ewAVjxMWSr1NXL5xLKj5UKh8Z9iaTIybfyAfctazLGfICEOMdIUxNJQsyX7QPZSADb C4mQ== 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=643+SwLgNy1RbLG04tqRWPpetLAovg4NxWaY4lJrCag=; b=Zcla0R3yVkxuInIUEVV/S6BGp/EEMw9q4IYy3Z1B4ILS9zioFrCmNAEnvP2/HIRhGs ffdnVlV+z6Uu/BOWBMs3Hrg0MaaECSd7wwCRjkNptTAVdm+lPS4ivwk42nrD6QZZkWbu pRsTsVL+JFpLxI9EiBi3OHHrIkCZtgtpJmFz9iqAT3M1KWfvP0nbvRrkVJgFgCDDlFu+ qqR2/N3F7tdJDnPvfO8N1GuhI9Ok0433WnPGWcJYjdMiEgCL1GJwZTJcBtQFzhDcqB6Q qwy4D/rmyIoRpO9ot1ncqBz/hgRcbmsvR8hkHUP96KxSPSO3CUOwtXvijVY57R4MQcnb cRvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LFdiQq6g; 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 g4-20020a1709026b4400b001965acaade8si18062308plt.24.2023.02.08.08.42.27; Wed, 08 Feb 2023 08:42:39 -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=LFdiQq6g; 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 S231728AbjBHQlk (ORCPT + 99 others); Wed, 8 Feb 2023 11:41:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231582AbjBHQlD (ORCPT ); Wed, 8 Feb 2023 11:41:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D61ED4E513 for ; Wed, 8 Feb 2023 08:40:42 -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 C544161735 for ; Wed, 8 Feb 2023 16:40:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFC6DC433EF; Wed, 8 Feb 2023 16:40:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675874441; bh=KSTAGgDnOoF+Y8ilpIa2/cv9j+0fPW1oC9ZZcQLM2eE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LFdiQq6ga8XowSHjWP/gHx+MTRZ5gzHOeEQItB6u0vWi/qAM+7TSG3jKpbFM7ST7b HknJHLkLkxSrNsweBODYdwxdhCcwh0ZP6KDRwCyJU1yO6mOkKy8qYEKcaXvB64lfpn 5t0WDjHlkUTIUMzXJ9hPLJ4nKK1YA9uoSz8OxTLGZY/oGJ5o+BeDqc55kJL2VQ4B87 YxoQM4JHEJPWnH2N5G1XeloDTsyVU817GwYyN0sti+KNMVklvT04KqIeKt4+6xi5cW a1l5Zgc6knppsb6GttEz3n6W3/c7nvKpJaBEYvNlwc3B5kdBXl7a+j62nm6XTMgCh2 QXKjMqDmBb5uA== From: Arnd Bergmann To: Josh Poimboeuf , Peter Zijlstra , Borislav Petkov , Marco Elver , Will Deacon , Thomas Gleixner Cc: kasan-dev@googlegroups.com, Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin , Vincenzo Frascino , Andrey Konovalov , Arnd Bergmann , Miroslav Benes , "Naveen N. Rao" , Sathvika Vasireddy , linux-kernel@vger.kernel.org Subject: [PATCH 4/4] objtool: add UACCESS exceptions for __tsan_volatile_read/write Date: Wed, 8 Feb 2023 17:39:58 +0100 Message-Id: <20230208164011.2287122-4-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=-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?1757281842105729444?= X-GMAIL-MSGID: =?utf-8?q?1757281842105729444?= 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 Fixes: 75d75b7a4d54 ("kcsan: Support distinguishing volatile accesses") 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 e8fb3bf7a2e3..d89ef6957021 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1200,6 +1200,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",