Thread (14 messages) 14 messages, 4 authors, 2019-09-25

Re: [PATCH v3] mm/kasan: dump alloc and free stack for page allocator

From: Andrey Ryabinin <hidden>
Date: 2019-09-12 17:05:32
Also in: linux-mediatek, linux-mm, lkml


On 9/12/19 5:31 PM, Vlastimil Babka wrote:
On 9/12/19 4:08 PM, Walter Wu wrote:
quoted
quoted
  extern void __reset_page_owner(struct page *page, unsigned int order);
diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
index 6c9682ce0254..dc560c7562e8 100644
--- a/lib/Kconfig.kasan
+++ b/lib/Kconfig.kasan
@@ -41,6 +41,8 @@ config KASAN_GENERIC
      select SLUB_DEBUG if SLUB
      select CONSTRUCTORS
      select STACKDEPOT
+    select PAGE_OWNER
+    select PAGE_OWNER_FREE_STACK
      help
        Enables generic KASAN mode.
        Supported in both GCC and Clang. With GCC it requires version 4.9.2
@@ -63,6 +65,8 @@ config KASAN_SW_TAGS
      select SLUB_DEBUG if SLUB
      select CONSTRUCTORS
      select STACKDEPOT
+    select PAGE_OWNER
+    select PAGE_OWNER_FREE_STACK
      help
What is the difference between PAGE_OWNER+PAGE_OWNER_FREE_STACK and
DEBUG_PAGEALLOC?
Same memory usage, but debug_pagealloc means also extra checks and restricting memory access to freed pages to catch UAF.
quoted
If you directly enable PAGE_OWNER+PAGE_OWNER_FREE_STACK
PAGE_OWNER_FREE_STACK,don't you think low-memory device to want to use
KASAN?
OK, so it should be optional? But I think it's enough to distinguish no PAGE_OWNER at all, and PAGE_OWNER+PAGE_OWNER_FREE_STACK together - I don't see much point in PAGE_OWNER only for this kind of debugging.

So how about this? KASAN wouldn't select PAGE_OWNER* but it would be recommended in the help+docs. When PAGE_OWNER and KASAN are selected by user, PAGE_OWNER_FREE_STACK gets also selected, and both will be also runtime enabled without explicit page_owner=on.
I mostly want to avoid another boot-time option for enabling PAGE_OWNER_FREE_STACK.
Would that be enough flexibility for low-memory devices vs full-fledged debugging?
Originally I thought that with you patch users still can disable page_owner via "page_owner=off" boot param.
But now I realized that this won't work. I think it should work, we should allow users to disable it.



Or another alternative option (and actually easier one to implement), leave PAGE_OWNER as is (no "select"s in Kconfigs)
Make PAGE_OWNER_FREE_STACK like this:

+config PAGE_OWNER_FREE_STACK
+	def_bool KASAN || DEBUG_PAGEALLOC
+	depends on PAGE_OWNER
+

So, users that want alloc/free stack will have to enable CONFIG_PAGE_OWNER=y and add page_owner=on to boot cmdline.


Basically the difference between these alternative is whether we enable page_owner by default or not. But there is always a possibility to disable it.


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help