Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3315732iob; Mon, 16 May 2022 19:08:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8ODhQskkcFJ2j7FlfAGbUYcnyYtPpdIVGY4yI52Wy27B6MllombmzHK6hB1JnW+iolq/y X-Received: by 2002:a17:907:72ce:b0:6f4:d139:c2b1 with SMTP id du14-20020a17090772ce00b006f4d139c2b1mr17360946ejc.563.1652753327974; Mon, 16 May 2022 19:08:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652753327; cv=none; d=google.com; s=arc-20160816; b=eRFkucwBwFLXcWHcTt3E4bKeMFMmqpA98wKu+PfPzAwm4OveD3gWlFIPTTlgc+1vLE U9D90qO2SP6/+0V9iGThxGANE4jNMcrJ9nDpiQcCCrbFwB57WremOLqLsRwEq5pzvkEM 5H70KPyNU5fDTmC2007WOvv45tN7n/5coBOjIuZClf6NdYvDJ8sJttLggYQFB5C7iHCo /hH6PrQ7i9OOWJ+kH5e/bt4+QeMi5kMPzneeTlhqDXfQO+jejWyWWx36kVmPSYnVa3wA M1kxDBFxFFVeyet+F4SBh8Xa1d2sGpIIZhUUYySU6qjiB2WOCzZFoiFlGxyWOURj6FiZ vKZg== 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=EbBaokCH/n+lu1lhLbT43j8JHvfW0Dz6fbZSBx6scuQ=; b=xg/to3zXKa/1aerswJBagXS8mzp8q3hStQJ218ZQ+1X4+8K2CV21Ip87Rra8CJR/oF 20sOUTx3qm1f9arh7TtCORH6jJdQddoK3KloGAK12rWrwpRD3b4//cQYduqm/skrgQ5h PfFSt3p7+KvV1XejrE2yhCjCkllYJL6I6J8QYk0lW07y4Dteals3FGunYomO8Ii6E9/I EG0jKrK3teOX7iHRLqTmIoVS84TYUrnUe1qMqgroSM7FKi3U19mpi+rprMGBbZWvaU/D qvvR0bW8x+rvOTfz5nFq6CAtbD4RhwBy1JYVCT6vplq/fnszLLDv8o5cnmisXc7rlWqB S3qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cck+N1iL; 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 nc24-20020a1709071c1800b006efef30bd26si1112722ejc.47.2022.05.16.19.08.22; Mon, 16 May 2022 19:08:47 -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=cck+N1iL; 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 S1346796AbiEPVCA (ORCPT + 99 others); Mon, 16 May 2022 17:02:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349433AbiEPVBV (ORCPT ); Mon, 16 May 2022 17:01:21 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A590457BC; Mon, 16 May 2022 13:37:44 -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=EbBaokCH/n+lu1lhLbT43j8JHvfW0Dz6fbZSBx6scuQ=; b=cck+N1iLqqxU1fpBU5JRS0N1B6 eW8XgJDTLybclIC8HWUHWK+x40eUEu8VMVwSSmlyw+onOPHMk6103otDgCjr7r/gj6AxMt2JG6zUS FW4hJRDCt9gi/Y74jHnj0bbThZ+7LKrvpptAvCL55WgUl7ZD6jSPLOk/J4LOT4mrFcg6jtgO57sZt hoQHbJApaKSta71c1RKZSudOrac98MGT5V/n0coOYJFLWdl32rXWvgxWcG33eetfT5yIc3RruifoO ZrNvjqUXgCWB5KIdVFsLiQqcqKbl6b+c2YyIDFV+k68y0msMUu03cxyi6w0nAy8xLqVwa1jdYBQwI 0Zpgu9bA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqhT5-00ADs8-0T; Mon, 16 May 2022 20:37:27 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 45A20980DCC; Mon, 16 May 2022 22:37:23 +0200 (CEST) Date: Mon, 16 May 2022 22:37:23 +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: <20220516203723.GN76023@worktop.programming.kicks-ass.net> References: <20220513202159.1550547-1-samitolvanen@google.com> <20220513202159.1550547-21-samitolvanen@google.com> <20220516183047.GM76023@worktop.programming.kicks-ass.net> 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 Mon, May 16, 2022 at 12:39:19PM -0700, Sami Tolvanen wrote: > > > With the current compiler patch, LLVM sets up function arguments after > > > the CFI check. if it's a problem, we can look into changing that. > > > > Yes, please fix that. Again see that same patch for why this is a > > problem. Objtool can trivially find retpoline calls, but finding this > > kCFI gadget is going to be hard work. If you ensure they're > > unconditionally stuck together, then the problem goes away find one, > > finds the other. > > You can use .kcfi_traps to locate the check right now, but I agree, > it's not quite ideal. Oohh, indeed. Looking at that, I think .kcfi_traps would be better as relative offsets; eg. 'addr = (void*)s + *s' like. Halfs the amount of storage needed for it. Also, that code can use a few {} extra.