Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4212948pxu; Wed, 9 Dec 2020 11:04:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMi6lj2sB+KPbdz9v3UC0HdIDcuu4h9EPRO2ym/RcOz2exT0Loofb51qfVHEYOBrjUB1Gm X-Received: by 2002:a17:906:924a:: with SMTP id c10mr3254111ejx.113.1607540657540; Wed, 09 Dec 2020 11:04:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607540657; cv=none; d=google.com; s=arc-20160816; b=RmvouG31vRSAcIg06wkkrTqkeScpWGTHC71DM86gtYF3NvFJ3HQm6/Avgnt3Dnzacs aDlQzTy6HUSN8MNVtls+jx28GpwIbCfuU1XQtKIlQ0QuynCMho3eOhKntYB9CRKKfJa+ f1rXxdr8I/r3UkmAqDjmG71vgcqKBkbuttBahfNBsa0Tddn+qRFlbvp+r2mHDlXo1BAD LkiGPxaTewAkVBduhI9NKhBILC3MniqC/VzhFmq93ybqwSCnA/6o6Ta6ErplyUaedjmq C2DJ6jPLI9lH+8rB4+uvDzEBCKiLKpRBVhfPR8QHKW/DRa81A/feNS6JtN258CIPwJWI WtSg== 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=pG0gcuo9xEY2L/FAHV4bggSQ0KrdHynw2Uo10jca5Xk=; b=JPFrX/TuhObMeqnl+e17p6q9hxX+8Tvg58VVkRDO1U4S4ukLFPqI9VuXderFlqArK7 RkAlahBBAt0Fv427mx2iXAAFvLZCQYURGcR4YBbYOIwtI81QEAyx2dhOSisa9ejKw47J +1DfGbLi0dT4m4Q0BhILNpvUwVnVxG7XN1udFfW2f/BDmzqYRGahdE4flHhms4eDPvKW hgNeHZnX6UbYrrM1W/nVKfBVRioeYUNK9ZRXjpFn1vrPcQU2Lmr1+7sIDTebnCBkzenN 49UREiKikhbt6Y+npyWOHRJUS1A5NLqHFNzKZFlmWCMZoIWiRiZEJ8k09SixcG2o7PZC H5nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qVYCs76S; 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 f1si1216439eja.8.2020.12.09.11.03.48; Wed, 09 Dec 2020 11:04:17 -0800 (PST) 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=qVYCs76S; 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 S1733155AbgLITA4 (ORCPT + 99 others); Wed, 9 Dec 2020 14:00:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732900AbgLITA4 (ORCPT ); Wed, 9 Dec 2020 14:00:56 -0500 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4173C0613CF for ; Wed, 9 Dec 2020 11:00:15 -0800 (PST) Received: by mail-ot1-x341.google.com with SMTP id b18so2437565ots.0 for ; Wed, 09 Dec 2020 11:00:15 -0800 (PST) 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=pG0gcuo9xEY2L/FAHV4bggSQ0KrdHynw2Uo10jca5Xk=; b=qVYCs76SZZySaqRu0eNDle3ruqCzKVJEySpCcfl+Xwx2/SMimVGrxw7+JaB0VpzxEU iztcoAGD//PQN+ZUh1tuc3isQJ905LHmgYeiH6Bzc0mTUeYtxGreKEk8uehYrKl5KasG a0mrVH8PKdm2VSTYHM1PWlV5vQxMBE86fpI/RUWW2hAOZm1eaQ4lLQTx+Q2dI9w5zHiM JA3mb20kisiJLsXbqwmOCS5Q50o+aSR13cS8olNJD1LGHYW9PJA01fcu58xYhrHE26YU bCTrts9SQHnB1ZGWRd2JRNBajtb75ygIVfpC86MELEKjahChUQrnfg+V+6xxbuCJ7VRo hgLA== 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=pG0gcuo9xEY2L/FAHV4bggSQ0KrdHynw2Uo10jca5Xk=; b=jXukOOcKLcyA4tAjjtno11D9gwdj0EBZcinTMN56VaUw8w/sLNeqs1tXaDTGW17r9m z1ZARMUzZpOS0v1QkZyps5uQrAucVtdnTKJ75foxNSWMzrI89OczE+uKAiLE7xUMU9H0 QMU/3ClVujOC3wvpOBccDYIZexp3X1spwGloF9wqJERrS3dIqJOU24fCX/upmQlmbDuN JmXuUQdGgvEmv/lfzQxJyyTP93v7ec4qOXg9+8o3fKOghcw0UqAwxPPXjCxol2YmfM36 //vUjV26wRd4mt1DH3oxcgzYQxiJwd5V4+PG9PE8MuO06IPMFOHjw1O7OQ6bqT5eazfk X9tA== X-Gm-Message-State: AOAM531G11kBJQnNqnTHtUghY2VAeygyhdR3EIS7fBTWycAg+DCp36yT 3gJZ/c8s5kfqhh12Q63N+F+ZblYNTQpZKOj2Jq5Qdg== X-Received: by 2002:a9d:6317:: with SMTP id q23mr3046880otk.251.1607540414777; Wed, 09 Dec 2020 11:00:14 -0800 (PST) MIME-Version: 1.0 References: <202012091057.50DEDCC@keescook> In-Reply-To: <202012091057.50DEDCC@keescook> From: Marco Elver Date: Wed, 9 Dec 2020 20:00:03 +0100 Message-ID: Subject: Re: [PATCH mm 1/2] kasan: don't use read-only static keys To: Kees Cook Cc: Andrey Konovalov , Andrew Morton , Catalin Marinas , Will Deacon , Vincenzo Frascino , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , 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 Wed, 9 Dec 2020 at 19:57, Kees Cook wrote: > > On Wed, Dec 09, 2020 at 07:49:36PM +0100, Marco Elver wrote: > > On Wed, 9 Dec 2020 at 19:24, Andrey Konovalov wrote: > > > __ro_after_init static keys are incompatible with usage in loadable kernel > > > modules and cause crashes. Don't use those, use normal static keys. > > > > > > Signed-off-by: Andrey Konovalov > > > > Reviewed-by: Marco Elver > > > > > --- > > > > > > This fix can be squashed into > > > "kasan: add and integrate kasan boot parameters". > > > > > > --- > > > mm/kasan/hw_tags.c | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c > > > index c91f2c06ecb5..55bd6f09c70f 100644 > > > --- a/mm/kasan/hw_tags.c > > > +++ b/mm/kasan/hw_tags.c > > > @@ -43,11 +43,11 @@ static enum kasan_arg_stacktrace kasan_arg_stacktrace __ro_after_init; > > > static enum kasan_arg_fault kasan_arg_fault __ro_after_init; > > > > > > /* Whether KASAN is enabled at all. */ > > > -DEFINE_STATIC_KEY_FALSE_RO(kasan_flag_enabled); > > > +DEFINE_STATIC_KEY_FALSE(kasan_flag_enabled); > > > > Side-node: This appears to be just a bad interface; I think the macro > > DEFINE_STATIC_KEY_FALSE_RO() is error-prone, if it can't be guaranteed > > that this is always safe, since the presence of the macro encourages > > its use and we'll inevitably run into this problem again. > > > > > EXPORT_SYMBOL(kasan_flag_enabled); > > > > DEFINE_STATIC_KEY_FALSE_RO() + EXPORT_SYMBOL() is an immediate bug. > > Given its use has not increased substantially since its introduction, > > it may be safer to consider its removal. > > Right -- it seems the export is the problem, not the RO-ness. What is > actually trying to change the flag after __init? It seems to want to add it to a list on module loads: https://lore.kernel.org/lkml/20201208125129.GY2414@hirez.programming.kicks-ass.net/ -- Marco