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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5D728C433F5 for ; Mon, 16 May 2022 09:55:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+FtE6i/xAQ1TIpy+sFdOjwbictqMgD0yJxadp1jYVU8=; b=PuVX4g8rWqaez5 iz/pliHuc71ck/pJciYmYTwe0vWM9Or8iQ154g5+aXhfoZMd40CZ49hQXjUHT4+NlTKTM6ceS3zHp +TC8DG/Ljbycbf2nK167I7CdxA+Gu41a4aTXZ2zPH7xPPYF3Tn43ZdwoxkdTJzG+ORNKIvYNjtjB4 SIJRQ+hD3n2BMTivKA0gcMwqhU2vXtYKVFMMI5Bisy4z4hmjTh/Yy+BiCIxhhiWyT5OkWnuWVbZUL TXEkWVb/p3R4gVP/9GgAWU3Zc7ISjDG0iYb1yLMMLyiuyw/Lw9bzLDsE/CQF6fxe9dHQVzPYNvq9z ZvlaiEIzoD4hjVfCezcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqXR4-006zAM-Ok; Mon, 16 May 2022 09:54:42 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqXR3-006z9n-2Y for linux-arm-kernel@bombadil.infradead.org; Mon, 16 May 2022 09:54:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=/az5ZlpJQ8aDNMLY9MCE8GkO4AGEyZkSzsELYwgNYj4=; b=lA153z4CORR8RVuipFycT+rfic VYFl4X19X2lFe4YCoQJqFTuj7YCFRxXTqHr/oLOJbHFxTWSK+uXWEdITDp5bgfRotRTOaZfRRckec Sj+G268CI945tzUUXnEZksYhmTrG6Sy3FURbkbca+MHHJMoitg/2oU4DZEQkWfSD3i1+wCizpmJUc dlg2eHo4m+ztUEhgMipVS5WpYEzcnPTHeW3BBkO49KLG/FfilI+bVdxrG52y/BTmPwqePK4s2GDO3 ZlqKClu94dUuJ8N8lzKak0iRlavTD1c72uGDJqj63oKFd7WRXFmCM5iFfxiE2e4LQUKJiXWSWQRSR +LLHIwbA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqXQy-009mOl-1R; Mon, 16 May 2022 09:54:36 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 242EE30018E; Mon, 16 May 2022 11:54:33 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 041C020225E5F; Mon, 16 May 2022 11:54:32 +0200 (CEST) Date: Mon, 16 May 2022 11:54:32 +0200 From: Peter Zijlstra To: Sami Tolvanen Cc: linux-kernel@vger.kernel.org, Kees Cook , Josh Poimboeuf , x86@kernel.org, Catalin Marinas , Will Deacon , Mark Rutland , Nathan Chancellor , Nick Desaulniers , Joao Moreira , Sedat Dilek , Steven Rostedt , linux-hardening@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev Subject: Re: [RFC PATCH v2 20/21] x86: Add support for CONFIG_CFI_CLANG Message-ID: References: <20220513202159.1550547-1-samitolvanen@google.com> <20220513202159.1550547-21-samitolvanen@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220513202159.1550547-21-samitolvanen@google.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, May 13, 2022 at 01:21:58PM -0700, Sami Tolvanen wrote: > With CONFIG_CFI_CLANG, the compiler injects a type preamble > immediately before each function and a check to validate the target > function type before indirect calls: > = > ; type preamble > __cfi_function: > int3 > int3 > mov , %eax > int3 > int3 > function: > ... When I enable CFI_CLANG and X86_KERNEL_IBT I get: 0000000000000c80 <__cfi_io_schedule_timeout>: c80: cc int3 c81: cc int3 c82: b8 b5 b1 39 b3 mov $0xb339b1b5,%eax c87: cc int3 c88: cc int3 0000000000000c89 : c89: f3 0f 1e fa endbr64 That seems unfortunate. Would it be possible to get an additional compiler option to suppress the endbr for all symbols that get a __cfi_ preaamble? Also, perhaps s/CFI_CLANG/KERNEL_CFI/ or somesuch, so that GCC might also implement this same scheme (in time)? > ; indirect call check > cmpl=A0 =A0 , -6(%r11) > je .Ltmp1 > ud2 > .Ltmp1: > call __x86_indirect_thunk_r11 The first one I try and find looks like: 26: 41 81 7b fa a6 96 9e 38 cmpl $0x389e96a6,-0x6(%r11) 2e: 74 02 je 32 <__traceiter_sched_kthread_stop= +0x29> 30: 0f 0b ud2 32: 4c 89 f6 mov %r14,%rsi 35: e8 00 00 00 00 call 3a <__traceiter_sched_kthread_stop= +0x31> 36: R_X86_64_PLT32 __x86_indirect_thunk_r11-0x4 This must not be. If I'm to rewrite that lot to: movl $\hash, %r10d sub $9, %r11 call *%r11 .nop 4 Then there must not be spurious instruction in between the ud2 and the indirect call/retpoline thing. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel