Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp30996pxb; Tue, 12 Apr 2022 15:58:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz79J6sYhmFraYZ7exdURDwi3eBqa6XHBI+bUDzytuvAtseXriCh2uqzHfby/hyfOBr7xjd X-Received: by 2002:a17:90a:db08:b0:1c9:7cf3:6363 with SMTP id g8-20020a17090adb0800b001c97cf36363mr7518693pjv.35.1649804305418; Tue, 12 Apr 2022 15:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649804305; cv=none; d=google.com; s=arc-20160816; b=fw1+a8hNtj0HrFStrzSkKpYovXOdyflUSV97YTsD/flWmyopmdhQVlGuD5/Ps7KA4G O4YKwYrwj9jEZrJsga3e5s9u5DjlbnfmjbU1/zdLpDDq4O3soqiR3Oa2ncQ449usSK2H 3O9z4Qlnx6JuwUo6RsdBM45+HvZNro3jSveFlsUi4AGW1Az2MfECZZTRMRpuujy6nmvt pH0elg/r57fzynTRhLWavKd43UXdXPO+plVf/IRIppISAuwdHIRBJKaBjCno1H9asWBW 3/YA3HPPBpJqUuEWQew6xxojGdeifx1LGJpFeUNQE7cOxXQCIbGYmIkHiFTX0ipCr/n5 XLnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-filter; bh=rG2uaZyAEiyhXkFt52SkyeQGStuNJXxJtH9hUO9i+kA=; b=ctoDr/O9ZIZsjgUUbmZuv9AjG6p6WhgKl51/n61YEzzF81XrDc0+SCaUtCrheRvhIk NVeVAUEF83QzH6FzcK4nJZNyayPo2s/x2eb3KZhdgdbDH2vfFRfSn+WzDpgG4gt4Vvdc hDNgPmNXfPjOOkvt8oFv7sCgqQV53i/PKfEn3EU6CUeo0/tPdb630ZSdM49MDjPj4JQX oQTNP23FPBoeHE1mIuauseEF6XvpnDiJ3Sa7dhgZMerUOWDuHYcqaWeoXYcaH4XevDXW S4pkB2xbSLj3xQ8xXQ1I76UiPqfLVPvT6igKdk9cjVuv7e65me+hqhYSsG77/I0BM904 bxmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=AIn04MYT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id oc11-20020a17090b1c0b00b001cbc243aef4si3884452pjb.159.2022.04.12.15.58.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 15:58:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=AIn04MYT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E12261D7DB6; Tue, 12 Apr 2022 14:39:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344040AbiDKRiE (ORCPT + 99 others); Mon, 11 Apr 2022 13:38:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348986AbiDKRhv (ORCPT ); Mon, 11 Apr 2022 13:37:51 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CB43D2E080; Mon, 11 Apr 2022 10:35:35 -0700 (PDT) Received: from [192.168.254.32] (unknown [47.189.24.195]) by linux.microsoft.com (Postfix) with ESMTPSA id A44D7209DD7D; Mon, 11 Apr 2022 10:35:34 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A44D7209DD7D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1649698535; bh=rG2uaZyAEiyhXkFt52SkyeQGStuNJXxJtH9hUO9i+kA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=AIn04MYTzNVllTU+rmjF8YLvOR/CmtHaTesOXIlZb8pTSC2pHpvygd4qqpul/h4un 6VpXElMCG61TaXBBaCzPbpQ8ub9/ZtiD6752Jsxv7FbhDSedBYjnRUcerv9H8XlgAx PmS3DDEZrUSBgqG9dRIppJ9wRLZ7k0ijvQ1lYguU= Message-ID: <209888b9-fa98-2012-9f4c-1e37fd3283cd@linux.microsoft.com> Date: Mon, 11 Apr 2022 12:35:33 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [RFC PATCH v1 0/9] arm64: livepatch: Use DWARF Call Frame Information for frame pointer validation Content-Language: en-US To: Peter Zijlstra Cc: mark.rutland@arm.com, broonie@kernel.org, jpoimboe@redhat.com, ardb@kernel.org, nobuta.keiya@fujitsu.com, sjitindarsingh@gmail.com, catalin.marinas@arm.com, will@kernel.org, jmorris@namei.org, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org References: <95691cae4f4504f33d0fc9075541b1e7deefe96f> <20220407202518.19780-1-madvenka@linux.microsoft.com> From: "Madhavan T. Venkataraman" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 4/8/22 07:06, Peter Zijlstra wrote: > On Thu, Apr 07, 2022 at 03:25:09PM -0500, madvenka@linux.microsoft.com wrote: >> The solution >> ============ >> >> The goal here is to use the absolute minimum CFI needed to compute the FP at >> every instruction address. The unwinder can compute the FP in each frame, >> compare the actual FP with the computed one and validate the actual FP. >> >> Objtool is enhanced to parse the CFI, extract just the rules required, >> encode them in compact data structures and create special sections for >> the rules. The unwinder uses the special sections to find the rules for >> a given instruction address and compute the FP. >> >> Objtool can be invoked as follows: >> >> objtool dwarf generate >> >> The version of the DWARF standard supported in this work is version 4. The >> official documentation for this version is here: >> >> https://dwarfstd.org/doc/DWARF4.pdf >> >> Section 6.4 contains the description of the CFI. > > The problem is of course that DWARF is only available for compiler > generated code and doesn't cover assembly code, of which is there is > always lots. > Yes. But assembly functions are of two types: SYM_CODE_*() functions SYM_FUNC_*() functions SYM_CODE functions are, by definition, special functions that don't follow any ABI rules. They don't set up a frame. Based on the opinion of ARM64 experts, these need to be recognized by the unwinder and, if they are present in a stack trace, the stack trace must be considered unreliable. I have, in fact, submitted a patch to implement that. So, only SYM_FUNC*() functions are relevant for this part. I will look into these for arm64 and check if any of them can occur frequently in stack traces. If any of them is likely to occur frequently in stack traces, I must address them. If there are only a few such functions, unwind hints may be sufficient. I will get back to you on this. > I suppose you can go add DWARF annotations to all the assembly, but IIRC > those are pretty terrible. We were *REALLY* happy to delete all that > nasty from the x86 code. > DWARF annotations are a PITA to maintain. I will never recommend that! > On top of that, AFAIK compilers don't generally consider DWARF > generation to be a correctness issue. For them it's debug info and > having it be correct is nice but not required. So using it as input for > something that's required to be correct, seems unfortunate. It is only debug info. But if that info can be verified, then it is usable for livepatch purposes. I am thinking of implementing a verifier since DWARF reliability is a valid concern. I will keep you posted. Thanks! Madhavan