Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4203685pxu; Tue, 20 Oct 2020 10:39:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXd6dN+9Hp8EsJX23VgEFesEMM13JkwhpffC06/nhonEwZp+obW7wswdP2VJG3aIumOaV/ X-Received: by 2002:a17:906:4910:: with SMTP id b16mr4376154ejq.546.1603215574693; Tue, 20 Oct 2020 10:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603215574; cv=none; d=google.com; s=arc-20160816; b=v7pvudpS939Cz+TG9i0Ah+rz5OA6r2FN25+nHfnat8hPMLRLsPdWD+rXvtWwI7fjzP /E2MeYwKIFKDW7pU6sBK25RFsYa7ND4qwYvLe4EgK+TWzwwKh76f6OuJnuc8Lhhd4lL7 gmcCWhKzSI27agLN1S9nraOOEOsMXXIqRAi7kjGMoxE/0u1EjXa/DtVJBct56q6e4AEn 57j6X4Wvw15bWU88Jj24R+ae7VPMys0jM2IqSs9Vr5pGRtkfSGOrCV3iuNfQj2oN3Z2E tL33dfTugk9MRfI9zmP8CalDIy4IdgIkk8N8FbbftQKw3DHj5laRS+dEG/pts/EW5292 fD3g== 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=s42cP9f/U3GYa0s71Z6i/ug0NaSJrPca2FKEkcjzEig=; b=MYnILfYDyNUfENSAEd6ZZzSIVE3YfbqhWFOyZfDGzL7i585fo/aeYN2S4ATns9qYjQ EauPRbL+Ez6s7l9nebi4tjewyucOS1Bc5u5vW3LJFpPSLYXiUQF9oJZgnRJy81cphULo TCNMzG3rhkRNMt0CGoSEcW4+MfYErqM2vm6sPgv8yY8WZgz7DKvSjKow1eiDtZ8hiTma vAFU4f0MrPDSOvkEPiyouuWeQMXZ51WsH4PWNJvWYbWF3APURYHFtW4r8Z/m+7oAKMak 1tmESfd1RtCvm2q9mWLvZxU9xcYN6npiO+BCowYToWgqyEawTZH7UwB7jt2/CXv8iadZ 15ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lSWQdfR8; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id uz27si1736286ejb.212.2020.10.20.10.39.12; Tue, 20 Oct 2020 10:39:34 -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=@google.com header.s=20161025 header.b=lSWQdfR8; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391694AbgJTFez (ORCPT + 99 others); Tue, 20 Oct 2020 01:34:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391612AbgJTFez (ORCPT ); Tue, 20 Oct 2020 01:34:55 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54ECDC0613CE for ; Mon, 19 Oct 2020 22:34:55 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id 188so568230qkk.12 for ; Mon, 19 Oct 2020 22:34:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=s42cP9f/U3GYa0s71Z6i/ug0NaSJrPca2FKEkcjzEig=; b=lSWQdfR8gb//jvhTXD7ptWiD8DJJy+QjL933HmhsYV5USe+0wW1O06ws9f29EgM4qL dXTXghMazo5HR5hrNNZN0QWad7fuv72ijxZHgGM4dhb94NpKt5BG+UDw9dxDPm5isHbK VzWtr8QDDpaeXy1lNNL4aUltU0UEbqzZliXwaJmphUu/0jLamQtspESFhrUD3zPkGlFk 7cKt2+0fes/lHWCcEVHjigO/OxF/2686l62/e9GcR3cjXVrMgDBwfIIVJ6uZAUeEadRg 1icRhPP7aCKcIkcd6JlHEEsxQjcpF6+wjzjTcuremLItAP6IkJOKWRwmFP8Raik0rnnU gOnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=s42cP9f/U3GYa0s71Z6i/ug0NaSJrPca2FKEkcjzEig=; b=jVRmO5u6Dvf0P0Zju1LATg0IWsqul0Jvk3KKolPieZBeKqiDyGrjD4XARU8NzPdyob Jaw14CyoNLKQHOcndTcvHLH1a/3qIWBcn3ymNApdYP898sWv2TYbRtz89+IlcJqCBMJ5 XTCPfdM7EGBoLIVgyASWpFiOFDlrMOOu+U1+NDGSFmLZqyCpNZQCZ+06dy0+J35kKg8N HHp0DfyYZ/vrgRHRy1E4/8ClnyqkkezHM3aGBxAmNagZak30x8ELibg86Qc0V/t+aeiJ 5iGihicWcZ0fKmMltZ/2/mApy9Qe9YluWWCEawpfrd+am27v7rr1GExbsKUqFdrV7ME5 C4Jg== X-Gm-Message-State: AOAM531We4d0SSrZzcwiWbJtp6eg759vz6WfMAH/OYe+yZZ/OSHjIzhm VDGfPGXTWGF9qfPbeh7koSUp34HxySjhuOd2YJYVRw== X-Received: by 2002:a05:620a:1657:: with SMTP id c23mr1269155qko.231.1603172094152; Mon, 19 Oct 2020 22:34:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Dmitry Vyukov Date: Tue, 20 Oct 2020 07:34:42 +0200 Message-ID: Subject: Re: [PATCH RFC 0/8] kasan: hardware tag-based mode for production use on arm64 To: Kostya Serebryany Cc: Andrey Konovalov , Serban Constantinescu , Catalin Marinas , Will Deacon , Vincenzo Frascino , Alexander Potapenko , Evgenii Stepanov , Andrey Ryabinin , Elena Petrova , Branislav Rankov , Kevin Brodsky , Andrew Morton , kasan-dev , Linux ARM , Linux Memory Management List , LKML , Marco Elver Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 20, 2020 at 12:51 AM Kostya Serebryany wrote: > > Hi, > I would like to hear opinions from others in CC on these choices: > * Production use of In-kernel MTE should be based on stripped-down > KASAN, or implemented independently? Andrey, what are the fundamental consequences of basing MTE on KASAN? I would assume that there are none as we can change KASAN code and special case some code paths as necessary. > * Should we aim at a single boot-time flag (with several values) or > for several independent flags (OFF/SYNC/ASYNC, Stack traces on/off) We won't be able to answer this question for several years until we have actual hardware/users... It's definitely safer to aim at multiple options. I would reuse the fs opt parsing code as we seem to have lots of potential things to configure so that we can do: kasan_options=quarantine=off,fault=panic,trap=async I am also always confused by the term "debug" when configuring the kernel. In some cases it's for debugging of the subsystem (for developers of KASAN), in some cases it adds additional checks to catch misuses of the subsystem. in some - it just adds more debugging output on console. And in this case it's actually neither of these. But I am not sure what's a better name ("full"?). Even if we split options into multiple, we still can have some kind of presents that just flip all other options into reasonable values. > Andrey, please give us some idea of the CPU and RAM overheads other > than those coming from MTE > * stack trace collection and storage > * adding redzones to every allocation - not strictly needed for MTE, > but convenient to store the stack trace IDs. > > Andrey: with production MTE we should not be using quarantine, which > means storing the stack trace IDs > in the deallocated memory doesn't provide good report quality. > We may need to consider another approach, e.g. the one used in HWASAN > (separate ring buffer, per thread or per core) > > --kcc > > > On Fri, Oct 16, 2020 at 8:52 AM Andrey Konovalov wrote: > > > > On Fri, Oct 16, 2020 at 3:31 PM Marco Elver wrote: > > > > > > On Fri, 16 Oct 2020 at 15:17, 'Andrey Konovalov' via kasan-dev > > > wrote: > > > [...] > > > > > > The intention with this kind of a high level switch is to hide the > > > > > > implementation details. Arguably, we could add multiple switches that allow > > > > > > to separately control each KASAN or MTE feature, but I'm not sure there's > > > > > > much value in that. > > > > > > > > > > > > Does this make sense? Any preference regarding the name of the parameter > > > > > > and its values? > > > > > > > > > > KASAN itself used to be a debugging tool only. So introducing an "on" > > > > > mode which no longer follows this convention may be confusing. > > > > > > > > Yeah, perhaps "on" is not the best name here. > > > > > > > > > Instead, maybe the following might be less confusing: > > > > > > > > > > "full" - current "debug", normal KASAN, all debugging help available. > > > > > "opt" - current "on", optimized mode for production. > > > > > > > > How about "prod" here? > > > > > > SGTM. > > > > > > [...] > > > > > > > > > > Should we somehow control whether to panic the kernel on a tag fault? > > > > > > Another boot time parameter perhaps? > > > > > > > > > > It already respects panic_on_warn, correct? > > > > > > > > Yes, but Android is unlikely to enable panic_on_warn as they have > > > > warnings happening all over. AFAIR Pixel 3/4 kernels actually have a > > > > custom patch that enables kernel panic for KASAN crashes specifically > > > > (even though they don't obviously use KASAN in production), and I > > > > think it's better to provide a similar facility upstream. Maybe call > > > > it panic_on_kasan or something? > > > > > > Best would be if kasan= can take another option, e.g. > > > "kasan=prod,panic". I think you can change the strcmp() to a > > > str_has_prefix() for the checks for full/prod/on/off, and then check > > > if what comes after it is ",panic". > > > > > > Thanks, > > > -- Marco > > > > CC Kostya and Serban.