Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1183513imw; Wed, 13 Jul 2022 15:22:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vuodtjt+WC5n4vhLG5IJwULCzVCTVvQX1XzpA24ja47g8Ljd6wJC7nBdsUoJK6UEWHB8Oc X-Received: by 2002:a17:906:8477:b0:72b:3e65:55c5 with SMTP id hx23-20020a170906847700b0072b3e6555c5mr5530675ejc.255.1657750926355; Wed, 13 Jul 2022 15:22:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657750926; cv=none; d=google.com; s=arc-20160816; b=PX3LCMQk29IsHKMTv1gTo5JCzIv6ke1YFJ+6NoxfbqiNa2OS3nZxjqzes3Gyrx1xq0 0fG5I/GxjtnQQkl5OMFokdyPevp9Pmy/yK+i84vcrgDfRQ6stNfRlecy5pMZFl0nMpTl vVlWL0gq9HBtdke6WnPe6+GfGvhLaXqQsMxrVZHClsZfUp8zJ9KAzhUbX757o3toQElj fWC48hOzGli+eP8wMtglm3q3WTN6/UCQRyCz6hrbkzA9rvj6Jck+wJ4dqWxZBeapMSz9 88Q3gD4c/9F+Qc9e8Ia4Xgkuo0gCrLAWQKbnFQ1iyiZnJrbdOvpzcx3wRgGIFn4gUuOX LItg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=CVPURYDSdi9kkIBxu2J8OfzWwrMxbZ9TkMBa/yDaqbI=; b=xvQK3QEFNCimcghh5ry8JRZi6b9U3/Zf0j3GTequNd9srnK7cA5gHNmpGGrlMuXeWY PVlYjYsqGPMo9awwinOcvFGRMChsWwhYj768agxZvMOVzN5AM49WkllVxG+WzqtQRfiY wmvRTwsrtKPx2pfO1JQxZ9qENZBgwlazXoonFOyrQtAWr+9Y1BwsASl0ayqN59okkyN7 V+yLW3TZxC9tK900W4S/w6UjlWLymBpp+2WFJml4Nl8p6lxVFNVQ4iyAxjm8rqzn088N OKAMDAIQoTlqD/5sSvaYgofiOnoFkXm0RDQG2jcxM0a7yue65zwmscpS+6VQ2IR3qken vSOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="LGx/babJ"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kb26-20020a1709070f9a00b0072b211d9463si16305393ejc.166.2022.07.13.15.21.39; Wed, 13 Jul 2022 15:22:06 -0700 (PDT) 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=@google.com header.s=20210112 header.b="LGx/babJ"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237049AbiGMWFr (ORCPT + 99 others); Wed, 13 Jul 2022 18:05:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236702AbiGMWFq (ORCPT ); Wed, 13 Jul 2022 18:05:46 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9482845049 for ; Wed, 13 Jul 2022 15:05:45 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id z25so21342848lfr.2 for ; Wed, 13 Jul 2022 15:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CVPURYDSdi9kkIBxu2J8OfzWwrMxbZ9TkMBa/yDaqbI=; b=LGx/babJfl+Y6xdyF7x7eVHkVsNPeGrKZXB/vlSpnRKiFwIEbEdT+om3gcdVShfutk ttzO/XQ7XccC/2fi6sSjNVa0/LRMuMIhuB3lBZsrUPOx7DOQocrpDdPkr9+woi/7yaUE iwGmpJYPewHHHKgAJNhl3WHWmBurU4N4+GfNeCPrNcT+5xEyqMjTWgEmu93skeXa21Ni J0nJpw5UIwPvM7FnfmHvJTo92zviDVIQ9fmLTjyK3trz8Bfu4ibZH3u3YNBxSf+RFoDf CvJD0c8F6WACY4CHiJ2Y+CsOT8lT8yIiiCxG37ojl5JAqpRSvgVr9yagvllN/ZtSvLfx 2ujw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CVPURYDSdi9kkIBxu2J8OfzWwrMxbZ9TkMBa/yDaqbI=; b=1a3G6rqTQojITKQIbUKfGrXv7C00WfoAOcQC+Dk0bLlIGdHg6jM1FPRgNKCN4QDcQV MOoDpaPggbrrwcmteCYLyvVx9BM5a4sgNv0ZjH1qkGFonejUiBn90jp025xCdDHzEt+o 91oIO/e/cejd+6vTlhHdBhT9+fBHeyMlZqXq6om/obXCGN9/vpHXCkqdrSFzyojASLbd hwnZ2FeCvUmiHj3EMBKP/8Hq+XrWlZqpUftMC3ySvPhGAiaMaTcfTHrm7K+9QaEx64vQ mycnYd5Rq4O+LSWqhfsNx4ROXCCWdFlsH7gnckP4rQhN0dcM20Si0CIgEyPkFhlWhBU6 xSeQ== X-Gm-Message-State: AJIora9k09cHxBi+RMlYp8FFvTBUKnJtZRWhAIqye395iatSz3plqC3g /Tt7KfEFhULfqIs6X/Y2zTvNJ0puD9eiGZV+MLX0uZ0jDYBj+w== X-Received: by 2002:a05:6512:e83:b0:489:c6fe:e121 with SMTP id bi3-20020a0565120e8300b00489c6fee121mr3227885lfb.100.1657749943665; Wed, 13 Jul 2022 15:05:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Nick Desaulniers Date: Wed, 13 Jul 2022 15:05:32 -0700 Message-ID: Subject: Re: objtool "'naked' return found in RETHUNK build" with clang + CONFIG_K{A,C}SAN=y To: Nathan Chancellor Cc: Josh Poimboeuf , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Peter Zijlstra Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Wed, Jul 13, 2022 at 9:42 AM Nick Desaulniers wrote: > > On Wed, Jul 13, 2022 at 9:25 AM Peter Zijlstra wrote: > > > > On Wed, Jul 13, 2022 at 09:13:29AM -0700, Nathan Chancellor wrote: > > > On Wed, Jul 13, 2022 at 09:01:58AM -0700, Nick Desaulniers wrote: > > > > On Wed, Jul 13, 2022 at 8:48 AM Nathan Chancellor wrote: > > > > > > > > > > Hi Josh and Peter, > > > > > > > > > > After commit 9bb2ec608a20 ("objtool: Update Retpoline validation") and > > > > > commit f43b9876e857 ("x86/retbleed: Add fine grained Kconfig knobs"), I > > > > > see a spew of objtool warnings when building certain configurations with > > > > > clang. Examples below, they appear to trigger in every single file. > > > > > > > > > > With x86_64_defconfig + CONFIG_KASAN=y: > > > > > > > > > > arch/x86/ia32/audit.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build > > > > > arch/x86/ia32/audit.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build > > > > > init/version.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build > > > > > init/version.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build > > > > > arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build > > > > > arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build > > > > > arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build > > > > > arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build > > > > > arch/x86/kernel/platform-quirks.o: warning: objtool: asan.module_ctor+0x0: 'naked' return found in RETHUNK build > > > > > init/calibrate.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build > > > > > init/calibrate.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build > > > > > > > > > > With x86_64_defconfig + CONFIG_KCSAN=y: > > > > > > > > > > arch/x86/ia32/audit.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build > > > > > init/calibrate.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build > > > > > init/version.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build > > > > > arch/x86/kernel/fpu/bugs.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build > > > > > arch/x86/kernel/cpu/rdrand.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build > > > > > arch/x86/events/probe.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build > > > > > arch/x86/kernel/apic/ipi.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build It's not just the sanitizers, `CONFIG_GCOV_KERNEL=y` + `CONFIG_GCOV_PROFILE_ALL=y` also has this issue: ``` ... drivers/base/platform.o: warning: objtool: __llvm_gcov_reset+0xa94: 'naked' return found in RETHUNK build net/core/netpoll.o: warning: objtool: __llvm_gcov_reset+0xde3: 'naked' return found in RETHUNK build net/netfilter/nf_conntrack_netlink.o: warning: objtool: __llvm_gcov_reset+0x1b94: 'naked' return found in RETHUNK build fs/fs_parser.o: warning: objtool: __llvm_gcov_reset+0x344: 'naked' return found in RETHUNK build drivers/acpi/debugfs.o: warning: objtool: __llvm_gcov_reset+0xb: 'naked' return found in RETHUNK build mm/pagewalk.o: warning: objtool: __llvm_gcov_reset+0x77f: 'naked' return found in RETHUNK build drivers/tty/serial/8250/8250_pnp.o: warning: objtool: __llvm_gcov_reset+0x231: 'naked' return found in RETHUNK build fs/init.o: warning: objtool: __llvm_gcov_reset+0x2f7: 'naked' return found in RETHUNK build drivers/gpu/drm/drm_fourcc.o: warning: objtool: __llvm_gcov_reset+0x1ce: 'naked' return found in RETHUNK build ... ``` > > > > > > > > Thanks for the report. I wonder if this might be a compiler bug; it > > > > seems like the {a|t}san.module_{c|d}tor functions are being emitted > > > > with ret instructions? > > > > > > > > If you have one of these builds lying around still, can you provide: > > > > > > > > $ llvm-objdump -dr --disassemble-symbols=tsan.module_ctor > > > > arch/x86/kernel/fpu/bugs.o > > > > > > Sure thing. > > > > > > With KASAN: > > > > > > $ llvm-objdump -r --disassemble-symbols=asan.module_ctor,asan.module_dtor build/arch/x86/kernel/fpu/bugs.o > > > > > > build/arch/x86/kernel/fpu/bugs.o: file format elf64-x86-64 > > > > > > Disassembly of section .text.asan.module_ctor: > > > > > > 0000000000000000 : > > > 0: be 01 00 00 00 movl $1, %esi > > > 5: 48 c7 c7 00 00 00 00 movq $0, %rdi > > > 0000000000000008: R_X86_64_32S .data > > > c: e8 00 00 00 00 callq 0x11 > > > 000000000000000d: R_X86_64_PLT32 __asan_register_globals-0x4 > > > 11: c3 retq > > > > As Nick said; this should be: 'jmp __x86_return_thunk', on those builds. > > https://github.com/llvm/llvm-project/issues/56514 > > -- > Thanks, > ~Nick Desaulniers -- Thanks, ~Nick Desaulniers