Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1378703pxb; Sat, 30 Oct 2021 12:02:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylw+ImyYIh5OrbD0EYJRSrmWQIcXFVXLx3pu6VnqWHGQHoW0ZXfaB407/b0PE9g+YIf9Oy X-Received: by 2002:a05:6638:24d6:: with SMTP id y22mr14163722jat.39.1635620556144; Sat, 30 Oct 2021 12:02:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635620556; cv=none; d=google.com; s=arc-20160816; b=Zer3Iz3CjrNTOZ0IuRzQC26jEdHvZvbmUoDY0KbikktmB+gW85WkobDTMzI7Yy9JbC KQZiBbwC06JWeVzW9QlPHjhRAZxetrk69lKqQZ2ZNiIlwMYI3jpQ5BkzkHgCsF/nCnzZ 9sfnUxwqkdiD8w2AOTq7/n4ZdprZgnmb/5nnMeHw3Ou7qIp1rZewUX7qSW5APZTP1bnJ Fk0V7jivexfS52y5kpwfDpGobQimZ+zJqlci8xpuhWPldjBVptzin6BZaObXU2djO81f BEGSGvw2jhiPmaUFLOOXVDTbql5FZrq1/xJlspmsBvVfDSutOS6i1QFSeQy4xJQ0HQQh K3Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=qtn9JW4jhxyuPAJNQ5NoqqWfwKbfafsp+GixB38x3i8=; b=KHFGEo4BDtO4CliKQmk/YY+P/oXjmIet6kwENGupV+KOlPU1n55R9RsE9RHCQjjfH7 XScSW/ZhL6ZsilG1ibkJr+zFRSi4XTNHHlhHg8yhLA+8VbUvudicZ0Nh3jWMLMbEkPhq G/4lv1bLPBR+Sc8CkJqS8iwTwKk+BjDTkv/MIA2pool6rGFDkRPfOFq6sRVVz/F+ctdI vBjUUPsHKFKJf+stiEchftjENIHMH6HeXXCkU+16YmeSrmagC8pGo4LSSNbS0lADuc/H 3894sHC9r2iks0q0ZFU0aT6FMF6oOEhSe7UBZK+uMmHjv5wB9NhYPNkJgvxbnIk6jl/s ctCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O8FagHUZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j14si15095663ila.151.2021.10.30.12.02.24; Sat, 30 Oct 2021 12:02:36 -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=@kernel.org header.s=k20201202 header.b=O8FagHUZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230375AbhJ3S6D (ORCPT + 99 others); Sat, 30 Oct 2021 14:58:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:55164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbhJ3S6D (ORCPT ); Sat, 30 Oct 2021 14:58:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A7D2F60F0F; Sat, 30 Oct 2021 18:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635620132; bh=qtn9JW4jhxyuPAJNQ5NoqqWfwKbfafsp+GixB38x3i8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=O8FagHUZakbiUhExqOFAUdpYLah6tRqRSfskqQ7q4TCiiVaEiz6s9ZpTnQ3Jva8ks HACyto+ICAZMPH682d2LtBrv9oajQjoQ3LfF+MRiHpg+1tpxG5RtN4+/hP5KOx+Aq2 zo0kIkSxXy9K910s3dU22MWz3/wnzos1Dllyc3dApI1Qcn+sbNQLtbBQp0oBvBOk0O 2PSJBFuatdFtMmIUZoLvrcZC7p5fpJ1asidJT693OAHgHJwjui4Y7sIr067k64/EVt bVfzMXB9Scm8u7jSmFzExn+qpF1c5IefGcSEzxa6c7HqTmGp/al9FXWC3Xn1eX90yL Ik9RJl8vXbxgw== Received: by mail-oi1-f181.google.com with SMTP id g125so18482199oif.9; Sat, 30 Oct 2021 11:55:32 -0700 (PDT) X-Gm-Message-State: AOAM532AQ548+SMeRSWrLH9VTueytwrijSpiJuvZkOxLLJUXaW/OW2yX QB1lE/ocIxpfDZUfYDJWDZ8W77Vq/IJfYIRo0e4= X-Received: by 2002:a05:6808:1805:: with SMTP id bh5mr18863439oib.47.1635620131981; Sat, 30 Oct 2021 11:55:31 -0700 (PDT) MIME-Version: 1.0 References: <20211027124852.GK174703@worktop.programming.kicks-ass.net> <20211029200324.GR174703@worktop.programming.kicks-ass.net> <20211030074758.GT174703@worktop.programming.kicks-ass.net> <20211030180249.GU174703@worktop.programming.kicks-ass.net> In-Reply-To: <20211030180249.GU174703@worktop.programming.kicks-ass.net> From: Ard Biesheuvel Date: Sat, 30 Oct 2021 20:55:20 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] static_call,x86: Robustify trampoline patching To: Peter Zijlstra 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.