Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1436158

Re: [PATCH 3/3] mm/page_owner: track page free call chain

Path csiph.com!xmission!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!news.mixmin.net!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod
From Joonsoo Kim <iamjoonsoo.kim@lge.com>
Newsgroups linux.kernel
Subject Re: [PATCH 3/3] mm/page_owner: track page free call chain
Date Mon, 04 Jul 2016 09:30:02 +0200
Message-ID <rR6um-2IO-9@gated-at.bofh.it> (permalink)
References <rQvO9-5Jn-7@gated-at.bofh.it> <rQvOa-5Jn-15@gated-at.bofh.it> <rR49b-1bD-3@gated-at.bofh.it> <rR4iR-1uT-3@gated-at.bofh.it> <rR4Cd-1Br-13@gated-at.bofh.it> <rR4Vz-1HH-1@gated-at.bofh.it>
X-Original-To Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
X-Original-Senderip 156.147.1.125
X-Original-Mailfrom iamjoonsoo.kim@lge.com
X-Original-Senderip 10.177.222.138
X-Original-Mailfrom iamjoonsoo.kim@lge.com
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.5.21 (2010-09-15)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 87
Organization linux.* mail to news gateway
X-Original-Cc Sergey Senozhatsky <sergey.senozhatsky@gmail.com>, Andrew Morton <akpm@linux-foundation.org>, Vlastimil Babka <vbabka@suse.cz>, linux-mm@kvack.org, linux-kernel@vger.kernel.org
X-Original-Date Mon, 4 Jul 2016 16:29:45 +0900
X-Original-Message-ID <20160704072944.GA15729@js1304-P5Q-DELUXE>
X-Original-References <20160702161656.14071-1-sergey.senozhatsky@gmail.com> <20160702161656.14071-4-sergey.senozhatsky@gmail.com> <20160704045714.GC14840@js1304-P5Q-DELUXE> <20160704050730.GC898@swordfish> <20160704052955.GD14840@js1304-P5Q-DELUXE> <20160704054524.GD898@swordfish>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1436158

Show key headers only | View raw


On Mon, Jul 04, 2016 at 02:45:24PM +0900, Sergey Senozhatsky wrote:
> On (07/04/16 14:29), Joonsoo Kim wrote:
> > > > On Sun, Jul 03, 2016 at 01:16:56AM +0900, Sergey Senozhatsky wrote:
> > > > > Introduce PAGE_OWNER_TRACK_FREE config option to extend page owner with
> > > > > free_pages() tracking functionality. This adds to the dump_page_owner()
> > > > > output an additional backtrace, that tells us what path has freed the
> > > > > page.
> > > > 
> > > > Hmm... Do you have other ideas to use this feature? Following example is
> > > > just to detect use-after-free and we have other good tools for it
> > > > (KASAN or DEBUG_PAGEALLOC) so I'm not sure whether it's useful or not.
> > > 
> > > there is no kasan for ARM32, for example (apart from the fact that
> > > it's really hard to use kasan sometimes due to its cpu cycles and
> > > memory requirements).
> > 
> > Hmm... for debugging purpose, KASAN provides many more things so IMO it's
> > better to implement/support KASAN in ARM32 rather than expand
> > PAGE_OWNER for free.
> > 
> 
> hm, the last time I checked kasan didn't catch that extra put_page() on

Indeed. It seems that kasan only catch double-free of slab object.

> x86_64. AFAIK, kasan on ARM32 is a bit hard to do properly
> http://www.serverphorums.com/read.php?12,1206479,1281087#msg-1281087

Okay.

> I've played with kasan on arm32 (an internal custom version)... and
> extended page_owner turned out to be *incomparably* easier and faster
> to use (especially paired with stackdepot).

Okay.

> 
> > > educate me, will DEBUG_PAGEALLOC tell us what path has triggered the
> > > extra put_page()? hm... does ARM32 provide ARCH_SUPPORTS_DEBUG_PAGEALLOC?
> > 
> > Hmm... Now, I notice that PAGE_OWNER_TRACK_FREE will detect
> > double-free rather than use-after-free.
> 
> well, yes. current hits bad_page(), page_owner helps to find out who
> stole and spoiled it from under current.
> 
> CPU a							CPU b
> 
> 	alloc_page()
> 	put_page() << legitimate
> 							alloc_page()
> err:
> 	put_page() << legitimate, again.
> 	           << but is actually buggy.
> 
> 							put_page() << double free. but we need
> 								   << to report put_page() from
> 								   << CPU a.

Okay. I think that this patch make finding offending user easier
but it looks like it is a partial solution to detect double-free.
See following example.

CPU a							CPU b

	alloc_page()
	put_page() << legitimate
 							alloc_page()
err:
	put_page() << legitimate, again.
	           << but is actually buggy.

	alloc_page()

							put_page() <<
							legitimate,
							again.
	put_page() << Will report the bug and
	        page_owner have legitimate call stack.

In kasan, quarantine is used to provide some delay for real free and
it makes use-after-free detection more robust. Double-free also can be
benefit from it. Anyway, I will not object more since it looks
the simplest way to improve doublue-free detection for the page
at least for now.

Thanks.

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/3][RFC] mm/page:_owner: track page free call chain Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-07-02 18:20 +0200
  [PATCH 2/3] mm/page_owner: rename PAGE_EXT_OWNER flag Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-07-02 18:20 +0200
  [PATCH 1/3] mm/page_owner: rename page_owner functions Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-07-02 18:20 +0200
  [PATCH 3/3] mm/page_owner: track page free call chain Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-07-02 18:20 +0200
    Re: [PATCH 3/3] mm/page_owner: track page free call chain Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-07-03 08:00 +0200
    Re: [PATCH 3/3] mm/page_owner: track page free call chain Joonsoo Kim <iamjoonsoo.kim@lge.com> - 2016-07-04 09:30 +0200
      Re: [PATCH 3/3] mm/page_owner: track page free call chain Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-07-04 10:00 +0200
    Re: [PATCH 3/3] mm/page_owner: track page free call chain Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-07-04 07:50 +0200
    Re: [PATCH 3/3] mm/page_owner: track page free call chain Joonsoo Kim <iamjoonsoo.kim@lge.com> - 2016-07-04 07:00 +0200
      Re: [PATCH 3/3] mm/page_owner: track page free call chain Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-07-04 07:10 +0200
        Re: [PATCH 3/3] mm/page_owner: track page free call chain Joonsoo Kim <iamjoonsoo.kim@lge.com> - 2016-07-04 07:30 +0200

csiph-web