From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54635C433EF for ; Mon, 18 Jul 2022 22:48:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235993AbiGRWso (ORCPT ); Mon, 18 Jul 2022 18:48:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234889AbiGRWsm (ORCPT ); Mon, 18 Jul 2022 18:48:42 -0400 Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8FA331376 for ; Mon, 18 Jul 2022 15:48:41 -0700 (PDT) Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-31c86fe1dddso123248037b3.1 for ; Mon, 18 Jul 2022 15:48:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=edZahbrQ/Oxqhwn8MhPjck0l3I5PeJIs16FI5e85ufw=; b=dNQwlBY9kDu8bojaiObuXmrW7zmzTtAlMLCkw80R/UgOHQ+l77VyyE7i9lHDgtEaI3 SNr13LlwaKbRUNBKfmUGD2uYhkWztkB4m5zDcJaOPGRrjDpQagz6ff+NODi5U5uHxTLO tozFZxyRcxkgO/um/F8eMmUJZxTat1zMugfp8tq75DQjFoSG2LUyEQKNGYt2FVkUla1L wWQvGVVWIF7wTAN/Lp+jt/1kpDscYgdcmI2ETdnf3jIWHvxnfg/m21OsUxBRe150iFSl 5Qh4EdG8fTE/SU/YPyQ6ViCOuv1sCUd01BHAi6Vme9UagqeOj5cwdGvLxeA0HYxolVIZ WVPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=edZahbrQ/Oxqhwn8MhPjck0l3I5PeJIs16FI5e85ufw=; b=cGW8CFIzThFCoKQdcwG6+r+HfgwWupOd/FshQAXizxItcBjxKOIz+SrWd7F1C+okGE Ai7g5NlkjBtS4H7B905QZk8H3sX/ZYReyyVjalXvUc55bQ63NmNIIr84CiNJhgqHNjtO PkZGnCYvGffFy/nHZ0za0myKzfjbW/B1a0iHfaTnon2bHNuulnL3XG+cpiHc4N3YSxSZ Jo7rY8VmFJc6s0dBu6M1MtE0EXtEHXijgVUPahCGvMOWtXaY4ocIuic6M5ammecD8+E8 ihC5IBvKiYF/sKyc4vh9g2iTMCJyErNxkkg2kXHhH5r9DodJ6wc9HgpmFmkvH5mq9af+ Zxsg== X-Gm-Message-State: AJIora8Vd+gNYDbmRp7dDJ0ejFkhtNjUquAJJpXvopK0u3qkPbEQ0XLw z/2iTYM3Q5N+YMXzRztPM1bEDik1tHSEZ9QukpN0o0lrCPc= X-Google-Smtp-Source: AGRyM1s74Z5E2Q1njOl4+AD4+vxACogqzvfB3qjspqjJHRyQVVB11gu7TWnm6W1oRniOtASVK//Gsko951vVkmhmda8= X-Received: by 2002:a0d:fe82:0:b0:31e:3ff9:7e0 with SMTP id o124-20020a0dfe82000000b0031e3ff907e0mr4601529ywf.284.1658184521073; Mon, 18 Jul 2022 15:48:41 -0700 (PDT) MIME-Version: 1.0 References: <20220716230344.239749011@linutronix.de> <87wncauslw.ffs@tglx> <87tu7euska.ffs@tglx> <87o7xmup5t.ffs@tglx> In-Reply-To: From: Sami Tolvanen Date: Mon, 18 Jul 2022 15:48:04 -0700 Message-ID: Subject: Re: [patch 00/38] x86/retbleed: Call depth tracking mitigation To: Peter Zijlstra Cc: Thomas Gleixner , Linus Torvalds , LKML , "the arch/x86 maintainers" , Tim Chen , Josh Poimboeuf , Andrew Cooper , Pawan Gupta , Johannes Wikner , Alyssa Milburn , Jann Horn , "H.J. Lu" , Joao Moreira , Joseph Nuzman , Steven Rostedt , Juergen Gross , Masami Hiramatsu , Alexei Starovoitov , Daniel Borkmann Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 18, 2022 at 2:18 PM Peter Zijlstra wrote: > > On Mon, Jul 18, 2022 at 10:44:14PM +0200, Thomas Gleixner wrote: > > And we need input from the Clang folks because their CFI work also puts > > stuff in front of the function entry, which nicely collides. > > Right, I need to go look at the latest kCFI patches, that sorta got > side-tracked for working on all the retbleed muck :/ > > Basically kCFI wants to preface every (indirect callable) function with: > > __cfi_\func: > int3 > movl $0x12345678, %rax > int3 > int3 > \func: Yes, and in order to avoid scattering the code with call target gadgets, the preamble should remain immediately before the function. > Ofc, we can still put the whole: > > sarq $5, PER_CPU_VAR(__x86_call_depth); > jmp \func_direct > > thing in front of that. Sure, that would work. > But it does somewhat destroy the version I had that only needs the > 10 bytes padding for the sarq. There's also the question of how function alignment should work in the KCFI case. Currently, the __cfi_ preamble is 16-byte aligned, which obviously means the function itself isn't. Sami