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=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 D847EC433FE for ; Wed, 9 Dec 2020 18:59:21 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6EF75233F8 for ; Wed, 9 Dec 2020 18:59:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6EF75233F8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PuLJqc0HAZsEq7fTgqU7Y2ly+xxRR/zac80Ir4Ujym0=; b=eQOQujByzvbNN6MMLkt6fSZUL t1HBAHg8El7klsKuDwhqN0LcG++R1qjLRKenQ47ZwAd8ITa77s6/8dRqjYzBv+9SwgOzVRxAoe9MY nbXZJRgAYyH3egeAei95y/Y3U64LspYqQn1QS9vhpX4Wy4vX4WdpBnmPcW9q8bE7ds6ux1CW5UgF8 3lTVINCKKTI4Ttqmx9F2u8K+PZXM9c/GTLQprM+JQS27BIYZ/u+RRa4K3bxktp7+ekllhSk19mx/e TNHkvrrG+rUxLDL8kX6AXA+VWDa8VTUFhy01wB+JmnoNQJy6wh9bmhtYW+5mz8t5AFjKyJTgvJD8w e7Ou0/w8A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn4ex-0001lb-5T; Wed, 09 Dec 2020 18:57:55 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn4eu-0001kr-Dx for linux-arm-kernel@lists.infradead.org; Wed, 09 Dec 2020 18:57:53 +0000 Received: by mail-pj1-x1044.google.com with SMTP id l23so1484368pjg.1 for ; Wed, 09 Dec 2020 10:57:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=HbHFCoB8R2U+BDcqEYlrw7gF+YPMUNiEZ6niPgfo8aU=; b=cYU5nt87wRIfKVzsnNYau87fOCH5z/sRa7i126s9aDxDevOruw8u0Wun06dvfr8MB4 BZAVrqG1azlGhSARjEeNsk7FEsiRw8yHKU96+YrUTIjaq+L4gA6028Te9sIqgyK7XVFW kq1oLl8XtVSa5BunNWismJAYzWLJMoJ1YfWB8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HbHFCoB8R2U+BDcqEYlrw7gF+YPMUNiEZ6niPgfo8aU=; b=J1VgfTTArtWY6fMCFpsGcr40EwdKHTAsCAGDxTbiS7uqPcdXDNjrXFE1xhht0g0YX5 emEkcW4goDAoWECxyKqFx5gfFyZhiZGB4gNqqXil8luH5//5pzJRYeCBd3Re+0qWTNEW lvLuoA/mXbArkmzhgl0b19wW+39jEbaLPNTl+D2Xb2VCDIDc0I+arITD8tB0SWlShf39 NVS0pQpWuqrWhd78NWE5Bnep4wPl0VN3cY21m+54juo/RXHK4pUlrcirmPpifq8xbU18 tvSheay6rWpzYpoyk9f/S3tLGqraZhTIIkaRwo7khmuHeDetgKOdqwbkLLYejEsHpXSo ZI7A== X-Gm-Message-State: AOAM531RmSUf7RMxgBAQMOtovoys0VWJMJOrx4ON02Q5ptjuv9/Q0XPz 64+W/znZnODDD2Lwyi2twZjN4A== X-Google-Smtp-Source: ABdhPJw2aa8C8TQ0+dmgkCMPI+5W/moQ9A40sIYwl6R66lVUZVCsXzeGdFRGPrHB712GP6vnJfvpEQ== X-Received: by 2002:a17:902:bf44:b029:da:d0ee:cef with SMTP id u4-20020a170902bf44b02900dad0ee0cefmr283733pls.12.1607540269922; Wed, 09 Dec 2020 10:57:49 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y21sm3609122pfr.90.2020.12.09.10.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 10:57:49 -0800 (PST) Date: Wed, 9 Dec 2020 10:57:48 -0800 From: Kees Cook To: Marco Elver Subject: Re: [PATCH mm 1/2] kasan: don't use read-only static keys Message-ID: <202012091057.50DEDCC@keescook> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201209_135752_586012_2CEAE467 X-CRM114-Status: GOOD ( 23.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linux ARM , Branislav Rankov , Andrey Konovalov , Kevin Brodsky , Will Deacon , LKML , kasan-dev , Linux Memory Management List , Alexander Potapenko , Evgenii Stepanov , Catalin Marinas , Andrey Ryabinin , Andrew Morton , Vincenzo Frascino , Dmitry Vyukov Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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? -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 617DCC433FE for ; Wed, 9 Dec 2020 18:57:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 76DC422B4B for ; Wed, 9 Dec 2020 18:57:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 76DC422B4B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C038B8D0048; Wed, 9 Dec 2020 13:57:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BB4B88D0031; Wed, 9 Dec 2020 13:57:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACA758D0048; Wed, 9 Dec 2020 13:57:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0172.hostedemail.com [216.40.44.172]) by kanga.kvack.org (Postfix) with ESMTP id 96ACE8D0031 for ; Wed, 9 Dec 2020 13:57:51 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 635E0824999B for ; Wed, 9 Dec 2020 18:57:51 +0000 (UTC) X-FDA: 77574653142.29.land50_53117b0273f2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 3BE85180868F8 for ; Wed, 9 Dec 2020 18:57:51 +0000 (UTC) X-HE-Tag: land50_53117b0273f2 X-Filterd-Recvd-Size: 5253 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Wed, 9 Dec 2020 18:57:50 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id j1so1440253pld.3 for ; Wed, 09 Dec 2020 10:57:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=HbHFCoB8R2U+BDcqEYlrw7gF+YPMUNiEZ6niPgfo8aU=; b=cYU5nt87wRIfKVzsnNYau87fOCH5z/sRa7i126s9aDxDevOruw8u0Wun06dvfr8MB4 BZAVrqG1azlGhSARjEeNsk7FEsiRw8yHKU96+YrUTIjaq+L4gA6028Te9sIqgyK7XVFW kq1oLl8XtVSa5BunNWismJAYzWLJMoJ1YfWB8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HbHFCoB8R2U+BDcqEYlrw7gF+YPMUNiEZ6niPgfo8aU=; b=I0PwIeOXQX+GL5FV0nGaj3/860zYN+bmZ4fvkLNL0UXt3mykvuyL+hE6yc1WIwOTiv ii3AFoHSr4gRe4zgaO8zw1vcgQnOuIMOJD339AcTpxQFI2u46QzQAPzRu57Ai6PFR/O2 7UuJXMvMDyXa4NW21zf/vL3UDH+BOtdVh7VmpWUWA21R6C2hE+2+VQarQ/Ikp9h7q/+/ l62LSAr/+Qp1ZWcuBMgvL5CHVF1bf+x7dBZpf50PbpQncy+FfhlUG6gzGgEFhPLRphMT g5re4y59LH4yONw7TiPg/+b+KdTKijHy7U5Xsiesqyb+b/7NTzqZfXiYOnF0FdDceIBX wLMg== X-Gm-Message-State: AOAM530ovkNwc56TFLzUrR9NXRZOJXwukCbOjrP/KgyoQ2cvx75dkunX FrKkx1umUNFykQBB1dzVcv3n3A== X-Google-Smtp-Source: ABdhPJw2aa8C8TQ0+dmgkCMPI+5W/moQ9A40sIYwl6R66lVUZVCsXzeGdFRGPrHB712GP6vnJfvpEQ== X-Received: by 2002:a17:902:bf44:b029:da:d0ee:cef with SMTP id u4-20020a170902bf44b02900dad0ee0cefmr283733pls.12.1607540269922; Wed, 09 Dec 2020 10:57:49 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y21sm3609122pfr.90.2020.12.09.10.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 10:57:49 -0800 (PST) Date: Wed, 9 Dec 2020 10:57:48 -0800 From: Kees Cook To: Marco Elver 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 Subject: Re: [PATCH mm 1/2] kasan: don't use read-only static keys Message-ID: <202012091057.50DEDCC@keescook> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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, 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? -- Kees Cook