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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 242B9C54EBD for ; Fri, 13 Jan 2023 09:34:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241046AbjAMJeh (ORCPT ); Fri, 13 Jan 2023 04:34:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241279AbjAMJcF (ORCPT ); Fri, 13 Jan 2023 04:32:05 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18D17F0C; Fri, 13 Jan 2023 01:27:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=OJRRczjdnZrMUyBr4WxyQN5pLb8AWpdjYYHf5LsEHfc=; b=ptNivekeyqVdwUJ+qf34fN61lQ KFdIvGx7iIPl2rNxqBZSqMyVFbVTdtjuwwlALl3ZxMVjaQeuQ3pVst3safTQ+t2UzdC4dVFnND/Ow udWRTiBl4/EwdK8CMWTj09c1JZkK3kOND4SY9VEwEDVc8OgEWFfYeunlBvAcxSzzSxtfLLwV8NSxe 84ZoVn+tw/Q1GsdjTbGTfziKq4HQk+dOtgOtVNDLamRbHI8QhACs2laWjHSpit42cCQAw7gWazvnv O02OxcOxZFwrnlB4eCyeoATiRTXc+4cXfncuPT11dTs7xg28OeUiX7E16afFLJ2+eHOk0QWxLx2ze XOo9w2Yg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGGLi-005xom-HO; Fri, 13 Jan 2023 09:27:46 +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)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id D3B99300642; Fri, 13 Jan 2023 10:27:32 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id B94052013A2A1; Fri, 13 Jan 2023 10:27:32 +0100 (CET) Date: Fri, 13 Jan 2023 10:27:32 +0100 From: Peter Zijlstra To: Sami Tolvanen Cc: Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Kees Cook , linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] kbuild: Fix CFI hash randomization with KASAN Message-ID: References: <20230112224948.1479453-1-samitolvanen@google.com> <20230112224948.1479453-2-samitolvanen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230112224948.1479453-2-samitolvanen@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 12, 2023 at 10:49:48PM +0000, Sami Tolvanen wrote: > Clang emits a asan.module_ctor constructor to each object file > when KASAN is enabled, and these functions are indirectly called > in do_ctors. With CONFIG_CFI_CLANG, the compiler also emits a CFI > type hash before each address-taken global function so they can > pass indirect call checks. > > However, in commit 0c3e806ec0f9 ("x86/cfi: Add boot time hash > randomization"), x86 implemented boot time hash randomization, > which relies on the .cfi_sites section generated by objtool. As > objtool is run against vmlinux.o instead of individual object > files with X86_KERNEL_IBT (enabled by default), CFI types in > object files that are not part of vmlinux.o end up not being > included in .cfi_sites, and thus won't get randomized and trip > CFI when called. > > Only .vmlinux.export.o and init/version-timestamp.o are linked > into vmlinux separately from vmlinux.o. As these files don't > contain any functions, disable KASAN for both of them to avoid > breaking hash randomization. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1742 > Signed-off-by: Sami Tolvanen Must've been 'fun' to figure out, Thanks! Acked-by: Peter Zijlstra (Intel)