Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp608015rwb; Fri, 13 Jan 2023 01:47:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXu3mMjW6OUsDsWQZGHONXVJRHx74RrHbsf71K3JioNHUzpalSTeoIJj30udsift173/rv4g X-Received: by 2002:a50:fc14:0:b0:498:e0be:318b with SMTP id i20-20020a50fc14000000b00498e0be318bmr19515701edr.38.1673603242636; Fri, 13 Jan 2023 01:47:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673603242; cv=none; d=google.com; s=arc-20160816; b=YsINoW1lEdzOtWgNZbrCRDLvLNvgkEM7fdwBtNjax7B1VEW1rkLq5dJKLUf+QzcEZN sWenF1FaxXSxFQb5DQyxXGM2I8JHhVDKKtf1AILuQEAcTFyKKQYH+bwH4mW0Lax9XnZp h+lwJxzBJdF9UVpzUewka7Bmk7ch6EIl1MDBKJ3u12sJYEbaGLBr4wIdCeB+vyqmJmfw /JAkrLclxyc4RArHyQV1Nx+Mb2VizTaSecXKGgLHGhb7HMh/u+IKlO6+heUlEPBz/yg7 pnWa6C0KcV6CQcZO/YG5nGS+hXkL3GHEiPazroyGyRVwwo08gMZdj9VCBKzeBPyWuQC1 czWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OJRRczjdnZrMUyBr4WxyQN5pLb8AWpdjYYHf5LsEHfc=; b=KsS8jO4prf7ozrk1YfVGKKfmf/E2O+v3ZiR+zPwgvgygTedaMlddI6TvKM0Os2+D6n bf52RcQoSaoHKBBNoK6tDPmCQEPwzEM2NvPLFZZkqQRON+eYN5vwlivVIWahylCcWkDT aKQ3Dm8pF/8ZzEWtWI8av+pEvrkJYCXY+8HHgeV1+gWDMyiMaVRNK8p+S1EHcF4j6hzC veNJ9NKCpS+6ZyqEZO7LbIGFOOP0kjFSZsDWJdfmqST/Q80Ynr4wbWdSLTuQUGISO8+1 7WuWNiNdVYPD3N7rM68hdZSEvoCe0Eh90rjKy6KxzivXP9J0EqAv0zWRC4RAd8ZFNgh2 5lpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ptNiveke; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m6-20020a056402050600b0046cb20e358asi19111818edv.362.2023.01.13.01.47.10; Fri, 13 Jan 2023 01:47:22 -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=@infradead.org header.s=casper.20170209 header.b=ptNiveke; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240978AbjAMJeh (ORCPT + 51 others); 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> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 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)