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=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 4CC54C433E0 for ; Sat, 6 Mar 2021 01:27:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A6D66509B for ; Sat, 6 Mar 2021 01:27:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229690AbhCFB1J (ORCPT ); Fri, 5 Mar 2021 20:27:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:44500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbhCFB1J (ORCPT ); Fri, 5 Mar 2021 20:27:09 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4A5B865093; Sat, 6 Mar 2021 01:27:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1614994028; bh=NngIxxx12YXwN0ocivs/pfNKIcJ7UM43YAnjKQEOJfM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fHQ7TGXNn8U+TXweUnRRhRCStjkAEL6+HZ/4g1Gp93VqrG87B849cvT2whLYOv9Jt qXUOhCwlIVGsKO8c0Ad3RRaUeEUca137dEcxq0cB25IhxtKMpRn9xEvdU5oXT+dZm/ F6QDuJmRve5IcsJIVFk/2iaHg3lHN1A2K5suOgz4= Date: Fri, 5 Mar 2021 17:27:07 -0800 From: Andrew Morton To: Andrey Konovalov Cc: Alexander Potapenko , Catalin Marinas , Will Deacon , Vincenzo Frascino , Dmitry Vyukov , Andrey Ryabinin , Marco Elver , Peter Collingbourne , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev , Linux ARM , Linux Memory Management List , LKML , stable Subject: Re: [PATCH v2] kasan, mm: fix crash with HW_TAGS and DEBUG_PAGEALLOC Message-Id: <20210305172707.0d16383226ce5bfa87939702@linux-foundation.org> In-Reply-To: References: <24cd7db274090f0e5bc3adcdc7399243668e3171.1614987311.git.andreyknvl@google.com> <20210305154956.3bbfcedab3f549b708d5e2fa@linux-foundation.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 6 Mar 2021 00:54:32 +0100 Andrey Konovalov wrote: > On Sat, Mar 6, 2021 at 12:50 AM Andrew Morton wrote: > > > > On Sat, 6 Mar 2021 00:36:33 +0100 Andrey Konovalov wrote: > > > > > Currently, kasan_free_nondeferred_pages()->kasan_free_pages() is called > > > after debug_pagealloc_unmap_pages(). This causes a crash when > > > debug_pagealloc is enabled, as HW_TAGS KASAN can't set tags on an > > > unmapped page. > > > > > > This patch puts kasan_free_nondeferred_pages() before > > > debug_pagealloc_unmap_pages() and arch_free_page(), which can also make > > > the page unavailable. > > > > > > ... > > > > > > --- a/mm/page_alloc.c > > > +++ b/mm/page_alloc.c > > > @@ -1304,6 +1304,12 @@ static __always_inline bool free_pages_prepare(struct page *page, > > > > > > kernel_poison_pages(page, 1 << order); > > > > > > + /* > > > + * With hardware tag-based KASAN, memory tags must be set before the > > > + * page becomes unavailable via debug_pagealloc or arch_free_page. > > > + */ > > > + kasan_free_nondeferred_pages(page, order, fpi_flags); > > > + > > > /* > > > * arch_free_page() can make the page's contents inaccessible. s390 > > > * does this. So nothing which can access the page's contents should > > > @@ -1313,8 +1319,6 @@ static __always_inline bool free_pages_prepare(struct page *page, > > > > > > debug_pagealloc_unmap_pages(page, 1 << order); > > > > > > - kasan_free_nondeferred_pages(page, order, fpi_flags); > > > - > > > return true; > > > } > > > > kasan_free_nondeferred_pages() has only two args in current mainline. > > Ah, yes, forgot to mention: this goes on top of: > > kasan: initialize shadow to TAG_INVALID for SW_TAGS > mm, kasan: don't poison boot memory with tag-based modes This patch (kasan, mm: fix crash with HW_TAGS and DEBUG_PAGEALLOC) is cc:stable, so it should come head of the other two lower priority patches. > > > > I fixed that in the obvious manner... > > Thanks! > > If you changed this patch, you'll also need to change the other one though. Yup. 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=-8.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 A823DC433DB for ; Sat, 6 Mar 2021 01:29:34 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 1CFA764F65 for ; Sat, 6 Mar 2021 01:29:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CFA764F65 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Mime-Version:References:In-Reply-To:Message-Id: Subject:Cc: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=NiMNj8noAaIU9VZqdQLCk4UgmFd1Lg8abRKUEajXNJU=; b=IaT1Q2Hh1QtMnDOzA68Zgz5G0 nzwn2WDsDqA35AkecZLJgskoGqodubeWITdw6kVYwqsVCrb/IRtphqsGI6/CSihfZPtHgckRCuDOy g1ALtnAE8yhAC5GeCrA3b3AiNyq9Js9XRZrC5+yliFUOMM6h9uqgIfvpclk0atJohN+3bjFCmpqqk r01BHK9+oEkwa1fc9AS6J7J4+xw0yhyFHmzGRkvbGyEwBV09kcx30kEW+/YUUq0lsaoBoTuYVSHwf LzoSnDd5sqKRGaBnOe5KHVfo7Bud7xT2K+dmf6HOyf4XZz/vZqtGVGmilMynNpp2Alxfqex8kK4z/ +4pwvz46Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lILiw-0009kO-2Z; Sat, 06 Mar 2021 01:27:18 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lILio-0009iD-PM for linux-arm-kernel@lists.infradead.org; Sat, 06 Mar 2021 01:27:14 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4A5B865093; Sat, 6 Mar 2021 01:27:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1614994028; bh=NngIxxx12YXwN0ocivs/pfNKIcJ7UM43YAnjKQEOJfM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fHQ7TGXNn8U+TXweUnRRhRCStjkAEL6+HZ/4g1Gp93VqrG87B849cvT2whLYOv9Jt qXUOhCwlIVGsKO8c0Ad3RRaUeEUca137dEcxq0cB25IhxtKMpRn9xEvdU5oXT+dZm/ F6QDuJmRve5IcsJIVFk/2iaHg3lHN1A2K5suOgz4= Date: Fri, 5 Mar 2021 17:27:07 -0800 From: Andrew Morton To: Andrey Konovalov Cc: Alexander Potapenko , Catalin Marinas , Will Deacon , Vincenzo Frascino , Dmitry Vyukov , Andrey Ryabinin , Marco Elver , Peter Collingbourne , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev , Linux ARM , Linux Memory Management List , LKML , stable Subject: Re: [PATCH v2] kasan, mm: fix crash with HW_TAGS and DEBUG_PAGEALLOC Message-Id: <20210305172707.0d16383226ce5bfa87939702@linux-foundation.org> In-Reply-To: References: <24cd7db274090f0e5bc3adcdc7399243668e3171.1614987311.git.andreyknvl@google.com> <20210305154956.3bbfcedab3f549b708d5e2fa@linux-foundation.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210306_012712_952506_C3AE716F X-CRM114-Status: GOOD ( 21.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Sat, 6 Mar 2021 00:54:32 +0100 Andrey Konovalov wrote: > On Sat, Mar 6, 2021 at 12:50 AM Andrew Morton wrote: > > > > On Sat, 6 Mar 2021 00:36:33 +0100 Andrey Konovalov wrote: > > > > > Currently, kasan_free_nondeferred_pages()->kasan_free_pages() is called > > > after debug_pagealloc_unmap_pages(). This causes a crash when > > > debug_pagealloc is enabled, as HW_TAGS KASAN can't set tags on an > > > unmapped page. > > > > > > This patch puts kasan_free_nondeferred_pages() before > > > debug_pagealloc_unmap_pages() and arch_free_page(), which can also make > > > the page unavailable. > > > > > > ... > > > > > > --- a/mm/page_alloc.c > > > +++ b/mm/page_alloc.c > > > @@ -1304,6 +1304,12 @@ static __always_inline bool free_pages_prepare(struct page *page, > > > > > > kernel_poison_pages(page, 1 << order); > > > > > > + /* > > > + * With hardware tag-based KASAN, memory tags must be set before the > > > + * page becomes unavailable via debug_pagealloc or arch_free_page. > > > + */ > > > + kasan_free_nondeferred_pages(page, order, fpi_flags); > > > + > > > /* > > > * arch_free_page() can make the page's contents inaccessible. s390 > > > * does this. So nothing which can access the page's contents should > > > @@ -1313,8 +1319,6 @@ static __always_inline bool free_pages_prepare(struct page *page, > > > > > > debug_pagealloc_unmap_pages(page, 1 << order); > > > > > > - kasan_free_nondeferred_pages(page, order, fpi_flags); > > > - > > > return true; > > > } > > > > kasan_free_nondeferred_pages() has only two args in current mainline. > > Ah, yes, forgot to mention: this goes on top of: > > kasan: initialize shadow to TAG_INVALID for SW_TAGS > mm, kasan: don't poison boot memory with tag-based modes This patch (kasan, mm: fix crash with HW_TAGS and DEBUG_PAGEALLOC) is cc:stable, so it should come head of the other two lower priority patches. > > > > I fixed that in the obvious manner... > > Thanks! > > If you changed this patch, you'll also need to change the other one though. Yup. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel