Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4150389iob; Tue, 17 May 2022 15:23:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyk8ROX0kYkv10OAw46oON+sOJUB2G6G2REFndgs+zYbM1hKsAXgjQO/6RXtCoAtjUDTHSD X-Received: by 2002:a17:907:6da1:b0:6fa:8438:b35c with SMTP id sb33-20020a1709076da100b006fa8438b35cmr21864542ejc.583.1652826212781; Tue, 17 May 2022 15:23:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652826212; cv=none; d=google.com; s=arc-20160816; b=XT+gFj7+YYGbVRpqJepEt6KKgirMEpS64KgNETVDupyZ/6EkCzLNUTqG9u+YbSEBuB p0eG8n+/f+SXpi83u93SjiCNiEZSugNX+vO9qnHgMzoxL6tn8eT3fHhN5n5c+n+pqgR1 Gozom3OGv77xXShrNHFLH5HoXKZikRaTMNlvaKXEM8DfncbW/ws4Dh4QjaY03bvFWsH5 tlIPH6nhV1zhEXyFFTN2iANzdHR2slA1wKOyeJlRqbhzGkM4IOc7ZMT7hcSEfeVjW/mf taGchJPlgaTJ7HH71Uj3o+8dCn+EnyRwG7IeGObm45CetrZs7IWVl9ksBXQtf5k15psI z8+g== 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=jwTi2Cazog8blP0yOGLXWlJcsxSDGZ2u4uY9kxsLkfk=; b=Vbxxo39pqsyWWe+kTOw6B4c0DjbVIPg4N06fiAVadw9JDv5YuuNYgFbdMf1/xaswLs aySCw6lKXU6o4TbEndzJTExDrmy+yRLrRSa6cNPG+p0pYdn91qNuO5IX7BogUJMdnY7w C0N6Dv+gGVrEVVd4oAZ94Vxb3MxOS3J0JHlB6FjZHLemxLMsXj1nCmcPTomnRefnQQa3 9SfQrNbOrFdKuYj1TAKCTh63pUtqzdiH1+ZFoH5WYgeVhGTQtXHHLqE0BONH5jErNCRq R0kmEGX1fva2sTWy9A3N7p8TnL2HLPKtJlOg2b23VY7B1q4+i8cFk1T8RgdgmnR8IsN/ YKsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=MTdKy2r7; 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 js16-20020a17090797d000b006e1442ff695si414274ejc.590.2022.05.17.15.23.07; Tue, 17 May 2022 15:23:32 -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=@infradead.org header.s=casper.20170209 header.b=MTdKy2r7; 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 S245055AbiEQJi6 (ORCPT + 99 others); Tue, 17 May 2022 05:38:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233525AbiEQJiy (ORCPT ); Tue, 17 May 2022 05:38:54 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF7EF44746; Tue, 17 May 2022 02:38:52 -0700 (PDT) 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=jwTi2Cazog8blP0yOGLXWlJcsxSDGZ2u4uY9kxsLkfk=; b=MTdKy2r7vz9qnE0wpTp07nMDEg ljCp1Zb2NriOnwiA/uzXXdtuSEEAt+8MmHDW386odcrFLXR7ho+3sO3bDv22akTTPVfMMBXnv+sYI g6gwbLw7UoFN9kxB7jC1PnSyV0mnJYnpYuoffSyjX5HIclZnpntQBYF3T/PccfzfZB5YTQq8536iO PNACVypbg/9epOBrixidP1XzJqc62oEdrDBFOtkey9RO2PV2y4tUg/sKetgnmz/oaloCU6sVTc76I GIFxs0GQBFaxTwXsfnWWxc12azbRX8zbFTrsQm1XHYjiH/MDS52S3YLfghOmjbjQalbuvQq7Rp/3m 60MDw/MA==; 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 1nqtf5-00Aje0-Dt; Tue, 17 May 2022 09:38:39 +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 7F7A130031C; Tue, 17 May 2022 11:38:36 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 66A62202BC439; Tue, 17 May 2022 11:38:36 +0200 (CEST) Date: Tue, 17 May 2022 11:38:36 +0200 From: Peter Zijlstra To: David Laight Cc: Kees Cook , Sami Tolvanen , "linux-kernel@vger.kernel.org" , 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> <20220516183047.GM76023@worktop.programming.kicks-ass.net> <202205161531.3339CA95@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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,T_SCC_BODY_TEXT_LINE 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 Tue, May 17, 2022 at 08:48:41AM +0000, David Laight wrote: > From: Peter Zijlstra > > Sent: 17 May 2022 09:41 > ... > > > If we use %eax instead of %r10d for the hash transfer (as per Joao), and > > > use int3 instead of ud2, then we can shrink the fineibt sequence to: > > > > > > __cfi_\func: > > > endbr # 4 > > > xorl $0x12345678, %eax # 5 > > > jz 1f # 2 > > > int3 # 1 > > > \func: > > > ... > > > > > > Which is 12 bytes, and needs a larger preamble (up from 9 in the current > > > proposal). > > > > On all that; perhaps it would be good to have a compiler option to > > specify the preamble size. It can enforce the minimum at 7 to have at > > least the required: > > > > movl $0x12345678, %eax > > int3 > > int3 > > > > but any larger number will just increase the preamble with int3 padding > > at the top. > > > > That can go right along with the option to supress endbr when preamble > > :-) > > You also need a compiler option to specify the register. > While (I think) %eax is usable in kernel, it isn't in userspace. > It is used in varargs calls to pass (IIRC) the number of fp > args that are passed in registers. You're mistaken, the compiler doesn't emit the FineIBT code *at*all*. That's all patched in later. For kCFI the mov is never executed and is only there to make it a valid instruction.