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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_2 autolearn=no 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 747F5C3A5A7 for ; Wed, 4 Sep 2019 14:24:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F2DB22CED for ; Wed, 4 Sep 2019 14:24:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730783AbfIDOYc (ORCPT ); Wed, 4 Sep 2019 10:24:32 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:42220 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729809AbfIDOYc (ORCPT ); Wed, 4 Sep 2019 10:24:32 -0400 X-UUID: fe267de637764d1c8c1e2ed01f75eca6-20190904 X-UUID: fe267de637764d1c8c1e2ed01f75eca6-20190904 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1751036984; Wed, 04 Sep 2019 22:24:26 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 4 Sep 2019 22:24:23 +0800 Received: from [172.21.84.99] (172.21.84.99) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 4 Sep 2019 22:24:22 +0800 Message-ID: <1567607063.32522.24.camel@mtksdccf07> Subject: Re: [PATCH 1/2] mm/kasan: dump alloc/free stack for page allocator From: Walter Wu To: Vlastimil Babka CC: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Matthias Brugger , Andrew Morton , "Martin Schwidefsky" , Arnd Bergmann , , , , , , Date: Wed, 4 Sep 2019 22:24:23 +0800 In-Reply-To: <7998e8f1-e5e2-da84-ea1f-33e696015dce@suse.cz> References: <20190904065133.20268-1-walter-zh.wu@mediatek.com> <401064ae-279d-bef3-a8d5-0fe155d0886d@suse.cz> <1567605965.32522.14.camel@mtksdccf07> <7998e8f1-e5e2-da84-ea1f-33e696015dce@suse.cz> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2019-09-04 at 16:13 +0200, Vlastimil Babka wrote: > On 9/4/19 4:06 PM, Walter Wu wrote: > > On Wed, 2019-09-04 at 14:49 +0200, Vlastimil Babka wrote: > >> On 9/4/19 8:51 AM, Walter Wu wrote: > >> > This patch is KASAN report adds the alloc/free stacks for page allocator > >> > in order to help programmer to see memory corruption caused by page. > >> > > >> > By default, KASAN doesn't record alloc/free stack for page allocator. > >> > It is difficult to fix up page use-after-free issue. > >> > > >> > This feature depends on page owner to record the last stack of pages. > >> > It is very helpful for solving the page use-after-free or out-of-bound. > >> > > >> > KASAN report will show the last stack of page, it may be: > >> > a) If page is in-use state, then it prints alloc stack. > >> > It is useful to fix up page out-of-bound issue. > >> > >> I expect this will conflict both in syntax and semantics with my series [1] that > >> adds the freeing stack to page_owner when used together with debug_pagealloc, > >> and it's now in mmotm. Glad others see the need as well :) Perhaps you could > >> review the series, see if it fulfils your usecase (AFAICS the series should be a > >> superset, by storing both stacks at once), and perhaps either make KASAN enable > >> debug_pagealloc, or turn KASAN into an alternative enabler of the functionality > >> there? > >> > >> Thanks, Vlastimil > >> > >> [1] https://lore.kernel.org/linux-mm/20190820131828.22684-1-vbabka@suse.cz/t/#u > >> > > Thanks your information. > > We focus on the smartphone, so it doesn't enable > > CONFIG_TRANSPARENT_HUGEPAGE, Is it invalid for our usecase? > > The THP fix is not required for the rest of the series, it was even merged to > mainline separately. > > > And It looks like something is different, because we only need last > > stack of page, so it can decrease memory overhead. > > That would save you depot_stack_handle_t (which is u32) per page. I guess that's > nothing compared to KASAN overhead? > If we can use less memory, we can achieve what we want. Why not? Thanks. Walter From mboxrd@z Thu Jan 1 00:00:00 1970 From: Walter Wu Subject: Re: [PATCH 1/2] mm/kasan: dump alloc/free stack for page allocator Date: Wed, 4 Sep 2019 22:24:23 +0800 Message-ID: <1567607063.32522.24.camel@mtksdccf07> References: <20190904065133.20268-1-walter-zh.wu@mediatek.com> <401064ae-279d-bef3-a8d5-0fe155d0886d@suse.cz> <1567605965.32522.14.camel@mtksdccf07> <7998e8f1-e5e2-da84-ea1f-33e696015dce@suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <7998e8f1-e5e2-da84-ea1f-33e696015dce@suse.cz> Sender: linux-kernel-owner@vger.kernel.org To: Vlastimil Babka Cc: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Matthias Brugger , Andrew Morton , Martin Schwidefsky , Arnd Bergmann , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, wsd_upstream@mediatek.com List-Id: linux-mediatek@lists.infradead.org On Wed, 2019-09-04 at 16:13 +0200, Vlastimil Babka wrote: > On 9/4/19 4:06 PM, Walter Wu wrote: > > On Wed, 2019-09-04 at 14:49 +0200, Vlastimil Babka wrote: > >> On 9/4/19 8:51 AM, Walter Wu wrote: > >> > This patch is KASAN report adds the alloc/free stacks for page allocator > >> > in order to help programmer to see memory corruption caused by page. > >> > > >> > By default, KASAN doesn't record alloc/free stack for page allocator. > >> > It is difficult to fix up page use-after-free issue. > >> > > >> > This feature depends on page owner to record the last stack of pages. > >> > It is very helpful for solving the page use-after-free or out-of-bound. > >> > > >> > KASAN report will show the last stack of page, it may be: > >> > a) If page is in-use state, then it prints alloc stack. > >> > It is useful to fix up page out-of-bound issue. > >> > >> I expect this will conflict both in syntax and semantics with my series [1] that > >> adds the freeing stack to page_owner when used together with debug_pagealloc, > >> and it's now in mmotm. Glad others see the need as well :) Perhaps you could > >> review the series, see if it fulfils your usecase (AFAICS the series should be a > >> superset, by storing both stacks at once), and perhaps either make KASAN enable > >> debug_pagealloc, or turn KASAN into an alternative enabler of the functionality > >> there? > >> > >> Thanks, Vlastimil > >> > >> [1] https://lore.kernel.org/linux-mm/20190820131828.22684-1-vbabka@suse.cz/t/#u > >> > > Thanks your information. > > We focus on the smartphone, so it doesn't enable > > CONFIG_TRANSPARENT_HUGEPAGE, Is it invalid for our usecase? > > The THP fix is not required for the rest of the series, it was even merged to > mainline separately. > > > And It looks like something is different, because we only need last > > stack of page, so it can decrease memory overhead. > > That would save you depot_stack_handle_t (which is u32) per page. I guess that's > nothing compared to KASAN overhead? > If we can use less memory, we can achieve what we want. Why not? Thanks. Walter 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=-2.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=no 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 46952C3A5A7 for ; Wed, 4 Sep 2019 14:24:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 1AF6922CED for ; Wed, 4 Sep 2019 14:24:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="lXjnddLI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1AF6922CED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-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=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JGHStdJRamo2r6sLZWcn7dEGf+h8oAv1viv8fwxRFwU=; b=lXjnddLIzL0AYB jcIvsAROZTk+g0GmMAg12K59+huW3dCyiisuMEYaHvKfK2sAyK007a6uv0X365uIfISwc1z14lF9K /ROsPY0q8p1ZqglPxxhoJfvQmqLvk8u3q52xEyEN9UjI7vVWDMUnk1s1wc5AQAF8HWAgEissNQZ76 3giohsuVtnqmRmS24SQEKC3rBA6N3HUkbBo59vMaZ48FKoRdR8M9cN3SVftX3L4P0D8bj5tQ0ennC HlfspHwB+cdLcqTgymWg9bCpC3+8Ki3UKgCo2FGtRTnwhw7AoDsYit7QiYg3EQ0IWDjXnMWASueqw QtwvpWoxRBtawP9VrQoA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i5WD5-0003eT-SH; Wed, 04 Sep 2019 14:24:35 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i5WD0-0003cn-Uh; Wed, 04 Sep 2019 14:24:32 +0000 X-UUID: 07d89c2481bf4c63b03f0dfd00cbe4a4-20190904 X-UUID: 07d89c2481bf4c63b03f0dfd00cbe4a4-20190904 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 444790332; Wed, 04 Sep 2019 06:24:26 -0800 Received: from MTKMBS07N2.mediatek.inc (172.21.101.141) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 4 Sep 2019 07:24:25 -0700 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 4 Sep 2019 22:24:23 +0800 Received: from [172.21.84.99] (172.21.84.99) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 4 Sep 2019 22:24:22 +0800 Message-ID: <1567607063.32522.24.camel@mtksdccf07> Subject: Re: [PATCH 1/2] mm/kasan: dump alloc/free stack for page allocator From: Walter Wu To: Vlastimil Babka Date: Wed, 4 Sep 2019 22:24:23 +0800 In-Reply-To: <7998e8f1-e5e2-da84-ea1f-33e696015dce@suse.cz> References: <20190904065133.20268-1-walter-zh.wu@mediatek.com> <401064ae-279d-bef3-a8d5-0fe155d0886d@suse.cz> <1567605965.32522.14.camel@mtksdccf07> <7998e8f1-e5e2-da84-ea1f-33e696015dce@suse.cz> X-Mailer: Evolution 3.2.3-0ubuntu6 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190904_072430_994110_93A4BFF7 X-CRM114-Status: GOOD ( 19.81 ) 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: wsd_upstream@mediatek.com, Arnd Bergmann , linux-mm@kvack.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, Martin Schwidefsky , Alexander Potapenko , linux-arm-kernel@lists.infradead.org, Matthias Brugger , Andrey Ryabinin , Andrew Morton , Dmitry Vyukov Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 2019-09-04 at 16:13 +0200, Vlastimil Babka wrote: > On 9/4/19 4:06 PM, Walter Wu wrote: > > On Wed, 2019-09-04 at 14:49 +0200, Vlastimil Babka wrote: > >> On 9/4/19 8:51 AM, Walter Wu wrote: > >> > This patch is KASAN report adds the alloc/free stacks for page allocator > >> > in order to help programmer to see memory corruption caused by page. > >> > > >> > By default, KASAN doesn't record alloc/free stack for page allocator. > >> > It is difficult to fix up page use-after-free issue. > >> > > >> > This feature depends on page owner to record the last stack of pages. > >> > It is very helpful for solving the page use-after-free or out-of-bound. > >> > > >> > KASAN report will show the last stack of page, it may be: > >> > a) If page is in-use state, then it prints alloc stack. > >> > It is useful to fix up page out-of-bound issue. > >> > >> I expect this will conflict both in syntax and semantics with my series [1] that > >> adds the freeing stack to page_owner when used together with debug_pagealloc, > >> and it's now in mmotm. Glad others see the need as well :) Perhaps you could > >> review the series, see if it fulfils your usecase (AFAICS the series should be a > >> superset, by storing both stacks at once), and perhaps either make KASAN enable > >> debug_pagealloc, or turn KASAN into an alternative enabler of the functionality > >> there? > >> > >> Thanks, Vlastimil > >> > >> [1] https://lore.kernel.org/linux-mm/20190820131828.22684-1-vbabka@suse.cz/t/#u > >> > > Thanks your information. > > We focus on the smartphone, so it doesn't enable > > CONFIG_TRANSPARENT_HUGEPAGE, Is it invalid for our usecase? > > The THP fix is not required for the rest of the series, it was even merged to > mainline separately. > > > And It looks like something is different, because we only need last > > stack of page, so it can decrease memory overhead. > > That would save you depot_stack_handle_t (which is u32) per page. I guess that's > nothing compared to KASAN overhead? > If we can use less memory, we can achieve what we want. Why not? Thanks. Walter _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel