Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2185911pxb; Sun, 31 Oct 2021 09:42:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpoutSExoFzz2WGXgL/UiYAzXjHkyEht76XKVPGiVWw/PmMZpve/utUaFmIbb5Cy+EYWlP X-Received: by 2002:a05:6e02:2143:: with SMTP id d3mr11144558ilv.124.1635698522648; Sun, 31 Oct 2021 09:42:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635698522; cv=none; d=google.com; s=arc-20160816; b=t6FpzAxXUUDoeumLKxM4aYOW621aq7PhWTTZ393CyPBLTdQDmZC7klccLuWWet3e9E fD6UJGnTbwrFp5MsIJA/pGOYteTnkUntwh6mruWsLe5izeDRlf/3ReMsKhfkFDKCTlRQ /jirsqGWSRmIJ+VPWsn3xVvVs8gDUfuVnXIv39wFkgUUulCkw5j5aM3DiGBP6N06zdir yU0f+3XUjtoLDc6vE0zvHnp/hgxkNze8R5ukmXsH1yPWvbgs9rrQil1PV88pLatuxMN5 1RE/eQaOa/0gy4yOk5J1NOreIyqXzy44XDYfPXJhrLFg8Uk8rnI1jbsUuZuQ8Sv3d8Mk jrWQ== 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=Rp8yNDT9JB3LRMzfJfNEleH+RHkEoWlw4lzlXDzKQ2Q=; b=muBq3azQqdmrNqQKW+v1ERozSNNi/s2WgYHoGwTvNe5PPUn3gp1zmddO5R5BrNPJAK 949ZgvMl6cH17YxSdBtqWjr/cEZeoPQME2sX+I2xbIYYT/pgaflxXafUUmKyeikbj/JY mOl9zr5Kkn5Z4PL2b99AZP0G5a2Ugg04DeBFfhL5YnSr3C+wNEwJeV311SGciEaCTi9J YRftlZS9scdUta5INF+QzqDKekqKsgdjlXC6W/OSawvxbQqUuQFf+wQUlSY05n8mZp4s wTOUQTyJYVu8XCuM11R3l9fYINnLdS23fenuskc//yhyto91MegX0ZDqzLc3iuVFK/at UUrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=UNp+S5lm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b11si7270829ilv.42.2021.10.31.09.41.50; Sun, 31 Oct 2021 09:42:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=UNp+S5lm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229951AbhJaQmT (ORCPT + 99 others); Sun, 31 Oct 2021 12:42:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229579AbhJaQmS (ORCPT ); Sun, 31 Oct 2021 12:42:18 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 168B7C061570; Sun, 31 Oct 2021 09:39:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=Rp8yNDT9JB3LRMzfJfNEleH+RHkEoWlw4lzlXDzKQ2Q=; b=UNp+S5lm+9UO/WwnKsquJL5VaW o1wjfKIigJwTbq/CJO1kPGEPcQq7Xr0g78T8w2aRUazqhwlewYudyFJRQiZRBRsnCD7Ff5YtQA0fH LmMXzNjOq0Erd2Fon1jLSDE0y+J8Vh1c/xwFsI1dKIQeBCRNcieZfM/hqH+OwoE6uv3Pt8ASQGlpt UwAkeHrXcpydWkCB4CQr3MN9uQX70AhHfNqM2nWJjck7DfndNX/LfLg/4heeY1phv/k6vSiskfpni QAIfQydKMvg5+E3b1rqEKrIs7/J0OT0gEUNa2znRPqFIPhrFE+VSHp7P6wbFw9OclAE6unWdwaT3W motZbuxQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhDre-00DQF6-8i; Sun, 31 Oct 2021 16:39:22 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id F1476984CD2; Sun, 31 Oct 2021 17:39:20 +0100 (CET) Date: Sun, 31 Oct 2021 17:39:20 +0100 From: Peter Zijlstra To: Ard Biesheuvel Cc: Sami Tolvanen , Mark Rutland , X86 ML , Kees Cook , Josh Poimboeuf , Nathan Chancellor , Nick Desaulniers , Sedat Dilek , Steven Rostedt , linux-hardening@vger.kernel.org, Linux Kernel Mailing List , llvm@lists.linux.dev Subject: Re: [PATCH] static_call,x86: Robustify trampoline patching Message-ID: <20211031163920.GV174703@worktop.programming.kicks-ass.net> References: <20211029200324.GR174703@worktop.programming.kicks-ass.net> <20211030074758.GT174703@worktop.programming.kicks-ass.net> <20211030180249.GU174703@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 31, 2021 at 05:24:13PM +0100, Ard Biesheuvel wrote: > On Sat, 30 Oct 2021 at 20:55, Ard Biesheuvel wrote: > > > > On Sat, 30 Oct 2021 at 20:03, Peter Zijlstra wrote: > > > > > > On Sat, Oct 30, 2021 at 07:19:53PM +0200, Ard Biesheuvel wrote: > > > > I just realized that arm64 has the exact same problem, which is not > > > > being addressed by my v5 of the static call support patch. > > > > > > Yeah, it would. > > > > > > > As it turns out, the v11 Clang that I have been testing with is broken > > > > wrt BTI landing pads, and omits them from the jump table entries. > > > > Clang 12+ adds them properly, which means that both the jump table > > > > entry and the static call trampoline may start with BTI C + direct > > > > branch, and we also need additional checks to disambiguate. > > > > > > I'm not sure, why would the static_call trampoline need a BTI C ? The > > > whole point of static_call() is to be a direct call, we should never > > > have an indirect call to the trampoline, that would defeat the whole > > > purpose. > > > > This might happen when the distance between the caller and the > > trampoline is more than 128 MB, in which case we emit a veneer that > > uses an indirect call as well. So we definitely need the landing pad > > in the trampoline. > > Something like the below seems to work to prevent getting the wrong > trampoline address into arch_static_call_transform: Is is also a terriblly gross hack. I really want the clang-cfi stuff to improve, not add layers of hacks on top of it.