Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp879990pxb; Wed, 6 Apr 2022 03:03:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzfvG14v91AbXEIlUWnRdCIj/oR9+YqUcmOS2jtE9xicS14xL0rBbfELcqEX1Omv5ONo5w X-Received: by 2002:a17:902:ce8c:b0:156:c7f5:10f0 with SMTP id f12-20020a170902ce8c00b00156c7f510f0mr7763999plg.111.1649239399676; Wed, 06 Apr 2022 03:03:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649239399; cv=none; d=google.com; s=arc-20160816; b=If2pMch+jVdvutAcDf0hEZStnToVa+YXJ4Pra8rZZiQaXw3LfRiZKfHF9BDlcX3r1G 4aS7B1sX+9MX7GX38IAF8kbh5XK3Web80YFDQwtrz8OuNJxAW365hNbi3ahzPsG8yZKK SeAQgktSh8vqXR0w1rgZZAkNw4nD6OWEZR2YE3rj887SgGrsRoieJAfkDVc4aavR740a sVvJYd7Fha94qdy13BG/Y+t/J8q4uAGIMwkzsW0Uf1M84tzfzpRStiklYW3DEFnZM25O TycB5sF8rE/5aWBAtCdmCbe0umS14NTdfGxUV+8YEH1CoL17V2daslYaGNlCiwRpP27u b8Eg== 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=odjTcYZDlQIoWSkHe17VwGaSSDqsAiUMG/3xJUCUusY=; b=wIq63o5VtbF+rTrpdyi+/mofMioR5f3j69kEkyya9V8P/3G+74emj2+nwaS8jFgG6x tG/CeiR6r4+o880em0du6vwQBFBhOAX8ZuOlgHFMpZIteBbcm3VF3WgADRLFVyP1k1aA N4jALXeQmG3sWD3D1sSAK7sGvf9xVWmA7yD0YSxBQMV/1DgfbLoOmOmdBRZkc0Oxd5V2 qzNtiZlrkAZU3VlM5jnkUgPWfsbh75CU6LYgEY/oVFJ4vCLoJOwUpP/S7LSh5tHIyCsN 1MrgAHfNF9zMVtBdgRYKNrA0RdZC1m0/7KThFY/6DXeFpmY4zIK6b09MO9xhmXOzTrcg t4Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BIrJnLaJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z4-20020a170902834400b00153b2d1641bsi15011091pln.35.2022.04.06.03.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 03:03:19 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BIrJnLaJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0B82755CFDB; Wed, 6 Apr 2022 01:25:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1841586AbiDFBYY (ORCPT + 99 others); Tue, 5 Apr 2022 21:24:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1455105AbiDEP7h (ORCPT ); Tue, 5 Apr 2022 11:59:37 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80CF51ED05F for ; Tue, 5 Apr 2022 08:10:05 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id r2so15462451iod.9 for ; Tue, 05 Apr 2022 08:10:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=odjTcYZDlQIoWSkHe17VwGaSSDqsAiUMG/3xJUCUusY=; b=BIrJnLaJlobJRELofbUGfFGoIys4VbYWUyOHKM6yPYsEcaU68cPexoPGB+FF75wT0l nTLBpmNWQH9/4qlaY0IAqmQ99mQpeHL5s+1WZFh0J7WoAX7+equKRVWQIefnQJGxuh/d 12Uk/NDYJwyFUL3HMR+IHHm9e1DqLhSp1oAk5dW6A9KBz/M3GH2qfDskfkemdyJNjOfZ zklDlMXUPCraZit01xyTMy4mXPhfA6rQp9D9ILWlKYTlfAySHdHSrPXE36e/9K358+yp 2FY/pAh3O3L/Cdc9+eHFv8jK5bnXsezX/to0L2uZ8nOAf+9AnR8YjKHodr+zV3g6F846 Wspw== 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=odjTcYZDlQIoWSkHe17VwGaSSDqsAiUMG/3xJUCUusY=; b=AcWoWsVKzma/ACKsNdaYHVZ/VcsqlUeCsOCHccPU9Te7MI4L9koX5fwOcr5gUQxdv4 YIq2/F3p8pOVaB7BsYtIwDNlqEO5RDVGjWlu9PKk2IQnBYwJ3aXS3jEST2g0NEEnho8d TGgFbLSUXHhIY5HnIMHWm0m7v74lfJCAkxaVIL9aKR61Dt3YohrHSNn3n5Y5mc92mEsi sQjGnOPar20LlnTpeWSh43xLxNik6YFBKK1F4K64jpXZhst6u4tbIUTQwT0pVCvDvWOF bIhVj2n30cittgqEWUP2aq0aeGGHPdO2v99oIjoW8c/et6csb+XJe5YVRI0Dcb/rpaUR MsKg== X-Gm-Message-State: AOAM5311z+ZQBsu30jc39xNU7NYxmlR4r1hmx79Z77qz5/TONAMhAhSD WInWVrOvMkNI9VoBuSlczXH4AtC2M8pvFQN+FzA= X-Received: by 2002:a02:c89a:0:b0:321:25b2:4b52 with SMTP id m26-20020a02c89a000000b0032125b24b52mr2152926jao.218.1649171404854; Tue, 05 Apr 2022 08:10:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andrey Konovalov Date: Tue, 5 Apr 2022 17:09:54 +0200 Message-ID: Subject: Re: [PATCH v2 0/4] kasan, arm64, scs, stacktrace: collect stack traces from Shadow Call Stack To: Mark Rutland Cc: andrey.konovalov@linux.dev, Marco Elver , Alexander Potapenko , Catalin Marinas , Will Deacon , Andrew Morton , Dmitry Vyukov , Andrey Ryabinin , kasan-dev , Vincenzo Frascino , Sami Tolvanen , Peter Collingbourne , Evgenii Stepanov , Florian Mayer , Linux Memory Management List , LKML , Andrey Konovalov Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Thu, Mar 31, 2022 at 11:54 AM Mark Rutland wrote: > > That is an impressive number. TBH, I'm shocked that this has *that* much of an > improvement, and I suspect this means we're doing something unnecssarily > expensive in the regular unwinder. > > I've given some specific comments on patches, but a a high-level, I don't want > to add yet another unwind mechanism. For maintenance and correctness reasons, > we've spent the last few years consolidating various unwinders, which this > unfortunately goes against. > > I see that there are number of cases this unwinder will fall afoul of (e.g. > kretprobes and ftrace graph trampolines), and making those work correctly will > require changes elsewhere (e.g. as we rely upon a snapshot of the FP to > disambiguate cases today). Do I understand correctly that kretprobes and ftrace modify frames saved on SCS? So, if either is enabled, SCS frames might contain their addresses instead of actual PCs? If so, this is good enough for our use case. Having kretprobes or ftrace enabled is an unusual setting and there's no requirement to support it. The goal is to have stack trace collection working in most cases during a normal usage of an Android device. Being not feature-complete and not covering all possible peculiar cases is fine. > I'm also very much not keen on having to stash things in the entry assembly for > this distinct unwinder. I'll drop these changes, I'll respond on that patch. > Going forward, I'm also planning on making changes to the way we unwind across > exception boundaries (e.g. to report the LR and FP), and as that depends on > finding the pt_regs based on the FP, that's not going to work with SCS. > > So at a high level, I don't want to add an SCS based unwinder. > > However, I'm very much open to how we could improve the standard unwinder to be > faster, which would be more generally beneficial. I can see that there are some > things we could reasonably do with simple refactoring. The intention of adding an SCS-based unwinder it to use in production together with MTE-based KASAN. Thus, it needs to be as fast as possible. I doubt even a very optimized FP-based unwinder will compare with a simple loop over SCS frames. It seems a pity to let the kernel maintain the current call trace via SCS and then not to use it to collect stack traces. Would it be acceptable if we keep the SCS unwinder code in mm/kasan and not integrate with the common stacktrace machanisms? Thanks!