Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1292816pxu; Fri, 16 Oct 2020 08:30:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykv0IzCX21jqfwWIQzhzJXZBiyn4KYTLNAQX+E6tSXg78NvvRr3AIVwW+Ga58/h7vLbufA X-Received: by 2002:a17:906:5052:: with SMTP id e18mr4150476ejk.530.1602862236090; Fri, 16 Oct 2020 08:30:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602862235; cv=none; d=google.com; s=arc-20160816; b=XruMeRTU/Tz4syayw34bx8QQ6m3pDF7Ent+Ef+Uu9PJLC3+jBd0vrH279bt89+LOyP da8346VFUbBYyhb1z04EcS3OrjPDOirG8RzhvwH887/Iz+74jKSuCYPovB/dFMXwOL4Z xEHw1m1xqrXf6a/ZXmnFLyHxOWPFXYtZpB6C+obw67v/S9gjS8DpuCKEXT10S7StooJg zTYHc2fDiZ8v7n1qKBwb0Xx+QGTiiDSll0/JZN6/y3xpeD4s/a0S+Rfx1v/UtZ9XMway +UrbHGzTsUtWJJ9KuUKdEWzusbfZ9MNogkgg2S1lwu07lks3/P+fdd4XBO41ECiHvZon aiCw== 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=1Zj+cS5AehZpH9Xc1DCK1Rq5tdmQbPSdPgRnV6iCKcI=; b=FaryC5NlaGAcSUWEbZqkzQhyeyTrbHOIRHYpThi1eXnAg+mO6YouiXIAcVXHQLsNte 3MaSJTh8w5xfMEpbLwBVwU0LyqjlLTIEqqQt1Q+2tdZcYX3ta13i2UhFsy8Gh0lQIOqp t0wh3ELXAtscExlyX5Kgzrebf5SQPPEmnDK5kwaJqXwEfd8Z3cZJ9vcrGMGiD8kgMdLV 7ktr5H1SfGRVLlyfOKevyEP2gnAACzA655aJ+papjAlnJYcUfdc1odMUA/KQXtDrDEiY /Vvn8zwwPlKpXOZHt8Y6WHf99RR3pTw59r1o44oKkygReBeVNWAcROlNb1r6wIJbJpRQ pGIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uEOyU0Jw; 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 y21si1951155edm.83.2020.10.16.08.30.13; Fri, 16 Oct 2020 08:30:35 -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=uEOyU0Jw; 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 S2405463AbgJPNK5 (ORCPT + 99 others); Fri, 16 Oct 2020 09:10:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408294AbgJPNKz (ORCPT ); Fri, 16 Oct 2020 09:10:55 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3836BC061755 for ; Fri, 16 Oct 2020 06:10:55 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id b19so1273409pld.0 for ; Fri, 16 Oct 2020 06:10: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=1Zj+cS5AehZpH9Xc1DCK1Rq5tdmQbPSdPgRnV6iCKcI=; b=uEOyU0JwIRBRZ/kuhKTxlvRg4140bWr0tjMB6QN7KGcB9hfQBsWR1qr2pUztElTKSB Yf1uVkX1/1mIg+xuUSYp18t7D3e8rbX5cciR9ka0daIkOzFQ/r1+CfFFAYNRbMXHpLnH doSYeSuYU37EZ71hFYUSdpWyAeCQhddebkgsryt7FGrLdoKExvJO0GExVlLRJH3Ht0YX wzE3New3tYUX2x3Xfn5sVRPBSQRUpQn1XmP+/7+G4HmUYDYBjYBtA/db5zRzCce9tqIo uFZvfjXJ1Fj5uT8OX803/X35vOsuRoA26T7wxLTd10meL9b3HvBDOw86nIgpprlbAsDk OgiQ== 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=1Zj+cS5AehZpH9Xc1DCK1Rq5tdmQbPSdPgRnV6iCKcI=; b=aYEre+AZewu0w09RyaKygwyXkNFOZy+gwQM9P4MJTGDFR+IZzrmHlm7UcyQoq+idse 8Bucaes7S8MXUDjnWw1O8WWpN4x66E3qFbFQPm62n6rdafIqOa5MblZ0ADFDDIhi193H 5OYZaAWMavMXp0ON/XdU6/WVB69ZZFPuwmGbk+dOpeq4iRkE+eWJflSqEFodZXXf973B EGp6affoo0SMcnE7uB1/C7wsxNCnk9qdeBxwGESdDsfnLj0Z/rirmQRSeeII6BGL5PNz 1B5c98pTrp6oZOV2A2WNRuMHbgBxg3dLYAPd/Mof4k5cnekQ8IiFHlfBDOt/2MwylfVu E23A== X-Gm-Message-State: AOAM5330bukHM53fkmcTteUKBJungsm6WMdUrF4M5AirwCpzk3rI0Ypm nIBHUhA1FGtqIYcV/m12VH2E88Qf5J8obBAqCbdVew== X-Received: by 2002:a17:90b:807:: with SMTP id bk7mr3787953pjb.166.1602853854621; Fri, 16 Oct 2020 06:10:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andrey Konovalov Date: Fri, 16 Oct 2020 15:10:43 +0200 Message-ID: Subject: Re: [PATCH RFC 8/8] kasan: add and integrate kasan_mode boot param To: Marco Elver Cc: Catalin Marinas , Will Deacon , Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Evgenii Stepanov , Andrey Ryabinin , Elena Petrova , Branislav Rankov , Kevin Brodsky , Andrew Morton , kasan-dev , Linux ARM , Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 15, 2020 at 3:56 PM Marco Elver wrote: > > On Wed, 14 Oct 2020 at 22:45, Andrey Konovalov wrote: > > [...] > > @@ -180,6 +182,7 @@ size_t kasan_metadata_size(struct kmem_cache *cache) > > struct kasan_alloc_meta *kasan_get_alloc_meta(struct kmem_cache *cache, > > const void *object) > > { > > + WARN_ON(!static_branch_unlikely(&kasan_debug)); > > The WARN_ON condition itself should be unlikely, so that would imply > that the static branch here should be likely since you're negating it. Here I was thinking that we should optimize for the production use case, which shouldn't have kasan_debug enabled, hence the unlikely. But technically this function shouldn't be called in production anyway, so likely will do fine too. > And AFAIK, this function should only be called if kasan_debug is true. Yes, this WARN_ON is to make sure this doesn't happen. [...] > > +/* Whether to use syncronous or asynchronous tag checking. */ > > +static bool kasan_sync __ro_after_init; > > s/syncronous/synchronous/ Ack. > > > +static int __init early_kasan_mode(char *arg) > > +{ > > + if (!arg) > > + return -EINVAL; > > + > > + if (strcmp(arg, "on") == 0) > > + kasan_mode = KASAN_MODE_ON; > > + else if (strcmp(arg, "debug") == 0) > > s/strcmp(..) == 0/!strcmp(..)/ ? Sounds good. [...] > > @@ -60,6 +111,7 @@ void kasan_set_free_info(struct kmem_cache *cache, > > { > > struct kasan_alloc_meta *alloc_meta; > > > > + WARN_ON(!static_branch_unlikely(&kasan_debug)); > > What actually happens if any of these are called with !kasan_debug and > the warning triggers? Is it still valid to execute the below, or > should it bail out? Or possibly even disable KASAN entirely? It shouldn't happen, but if it happens maybe it indeed makes sense to disable KASAN here is a failsafe. It might be tricky to disable MTE though, but I'll see what we can do here. Thank you!