From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EE3EC4361B for ; Wed, 9 Dec 2020 19:00:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9A2C12312E for ; Wed, 9 Dec 2020 19:00:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A2C12312E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1EF108D0049; Wed, 9 Dec 2020 14:00:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 19FBD8D0031; Wed, 9 Dec 2020 14:00:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B6188D0049; Wed, 9 Dec 2020 14:00:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0051.hostedemail.com [216.40.44.51]) by kanga.kvack.org (Postfix) with ESMTP id E3CC88D0031 for ; Wed, 9 Dec 2020 14:00:16 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A5B52181AEF21 for ; Wed, 9 Dec 2020 19:00:16 +0000 (UTC) X-FDA: 77574659232.07.love27_0d13f24273f2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 810AE1803FD61 for ; Wed, 9 Dec 2020 19:00:16 +0000 (UTC) X-HE-Tag: love27_0d13f24273f2 X-Filterd-Recvd-Size: 5362 Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com [209.85.210.66]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Wed, 9 Dec 2020 19:00:15 +0000 (UTC) Received: by mail-ot1-f66.google.com with SMTP id x13so2422672oto.8 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=eq43X7Kdua2mvtC+XQilLuw+46DQ8mEMKDbyH3rfAiDn/pRuNcnhEUCvAAs9c481cT RSCoqNByZaDb3QxZReOPPFj05JXoknZfFMcZ8nTimtbkHrG5jb29KZUVW94Ot4r6drNQ QThoDZU0rKj3UFhJKQE8JGqO9vkGdq/yZtd9OfLOklUzJXWibonOo5HL4Q4oLVQqD3A4 8MFcyVGBspIuMbuQaU/s7qdMermi+X67tDLak7FeKfiw/D1Sgledx4Ovz8YnSkBoaIxG JLdnKqfJuHR+1ow0hkDt55qlEYBkW87ZOHZR5W1FsT24iwuyVDsZ59n6wnmd3d7axq2g /eWg== X-Gm-Message-State: AOAM531IZ4EB8CuZDU+AlWzgDtYib4/WREe9qpjagx5/GF6cXMhVi+rb hMWsD4uwaCliepr4tslmvywYk5PlRnSLLIWwwwLr4A== X-Google-Smtp-Source: ABdhPJyToUKjQUeQ30m5HrXBl1dbn2qFLJY/z0NfIzE5Brxz7x13+SArwW5cZUmfFj0cqVAGkanaYzoZPB5RjNEFHeo= 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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