Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp696589rwi; Thu, 20 Oct 2022 04:16:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM77TpLkQnq+dt8HVtKR/6/oxgYB5BVguHSKLFyhRbNk7iM6se1+k0ExmLwsej5jFh83bGHg X-Received: by 2002:a05:6402:1e8d:b0:454:79a9:201f with SMTP id f13-20020a0564021e8d00b0045479a9201fmr11845667edf.176.1666264597486; Thu, 20 Oct 2022 04:16:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666264597; cv=none; d=google.com; s=arc-20160816; b=qIKYBBjGwXYymFZ/9Goup9D2ih5Cu1nk4ETxyX3ZKKskvKtdEZalY4sJ/pPtULaT6d WsoMJD36ns5bK1J++C5h/GdI7agO7ejksdxe6gf3YqeY9Yn1Tfv33noyzyfEnJjhbK+F 60zuyxVyhlwVEY9IkykSER582faj/qn7MsQhOuzzhySmy7EBh47XcF7p0RRAFWif4B6b jMUV0QDMhIs0ieEdOR1Zspo+7nqz/uAdgkEb9n+7VkZ21uZwqeDkT6lK+Xp8fZVRYENk EGAUM40AtSqa7dneKE5xE7S7u8NIfcZF4DC6Ija/ZPaE4aBFx2Q8l4pUCRLxu1pn9mnY CvUg== 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=AD+e24i8Ref8qIYMEpCGeOzUC9xnTOhryaDJIjaHufg=; b=udcDpX2YPWZAM66L1FS+gY7IxJFbk+NvPrkKIkxMlpC8YjMrVafr6iQmvOWjR7rqN9 v+0q9A92uy/mhPevqoWEnrkR4qThZhV0dbLrxLZm/qMd4u0Xh302NDPu+0LV9AAWBAFE APK2WsYL+b8Nt58wtcHF+Ig2iBuTYwK1IUCbqCqQ/PjXP3wClExlce9q4P1zY84U1aU/ MyTF9OMimwbTd5kTRQhvduDNb+yzLgzuSf+vp1Ys2f0GJEft7fOg237MElRZtlq3EOMv a2muta5X8hIhTl7Gue5mYBjyeQYQaVOd3xgCzXpqGzd0A66uDdRqH/z2jfArkZb/ihaT cCDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=qL6joa2H; 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 h19-20020a056402281300b0045b5ccda164si18869472ede.596.2022.10.20.04.16.11; Thu, 20 Oct 2022 04:16:37 -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=qL6joa2H; 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 S231208AbiJTLEu (ORCPT + 99 others); Thu, 20 Oct 2022 07:04:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231153AbiJTLEs (ORCPT ); Thu, 20 Oct 2022 07:04:48 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42E5339B9D for ; Thu, 20 Oct 2022 04:04:45 -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=AD+e24i8Ref8qIYMEpCGeOzUC9xnTOhryaDJIjaHufg=; b=qL6joa2Hh7+V/6vITPUrbfQF7H SrsEFcgORMljDqKtQuhqo2Q6zZKCvrP9CMFh/3dV/We7xtRuXVubN8sJ5Dm+C9Ix7EFNKFziQAkBd hBcs1EQxxeK591VZeUotVkvPn75F3kAzEnPWY191EOjyb0jcKOdjzfyrQtB5VryCOvwOV657QF1fQ akgfpQeSEoILawZ2moP4kcHeZExD03BW56mT8EnwNj0pVDzE6RrkChJBS17wnYOvDnwNitVvhD0WI qQxoi6FmZG2i7vjKNtJu/fbyn8MWbpWeZl/jRX6cz1PXYjig2/dg5YcuPaPi5IL7umhjTn8EkjG/I QvKgEb+A==; 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 1olTLt-00CJwe-3T; Thu, 20 Oct 2022 11:04:41 +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 0F85A300110; Thu, 20 Oct 2022 13:04:35 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E70F9266F3CAF; Thu, 20 Oct 2022 13:04:34 +0200 (CEST) Date: Thu, 20 Oct 2022 13:04:34 +0200 From: Peter Zijlstra To: Sami Tolvanen Cc: Kees Cook , x86@kernel.org, Joao Moreira , linux-kernel@vger.kernel.org, Mark Rutland , Josh Poimboeuf Subject: Re: [PATCH] x86/ibt: Implement FineIBT Message-ID: References: <202210181020.79AF7F7@keescook> <202210182200.50680AE@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,URIBL_BLOCKED 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 Wed, Oct 19, 2022 at 08:22:17AM -0700, Sami Tolvanen wrote: > On Wed, Oct 19, 2022 at 5:03 AM Peter Zijlstra wrote: > > > > On Tue, Oct 18, 2022 at 10:05:26PM -0700, Kees Cook wrote: > > > > > > The one glitch here is that the resulting hash needs to not contain > > > an endbr... > > > > Oh right,.. duh. How about something like: > > > > static u32 cfi_rehash(u32 hash) > > { > > hash ^= cfi_hash; > > while (unlikely(is_endbr(hash))) { > > bool lsb = hash & 1; > > hash >>= 1; > > if (lsb) > > hash ^= 0x80200003; > > } > > return hash; > > } > > > > Which seems properly over-engineered :-) > > Also, -hash can't be endbr with KCFI since we use that in the check itself. Indeed, updated and pushed out. queue/x86/fineibt should have it momentarily.