Re: [PATCH RFC 01/10] mm: add Kernel Electric-Fence infrastructure

From
Dmitry Vyukov <dvyukov@google.com>
Date
2020-09-10 20:52:50
Also in
linux-doc, linux-mm, lkml
Reply to
Marco Elver, 2020-09-07
On Mon, Sep 7, 2020 at 3:41 PM Marco Elver [off-list ref] wrote:
quoted hunk ↗ jump to hunk
+config KFENCE_NUM_OBJECTS
+       int "Number of guarded objects available"
+       default 255
+       range 1 65535
+       help
+         The number of guarded objects available. For each KFENCE object, 2
+         pages are required; with one containing the object and two adjacent
+         ones used as guard pages.
Hi Marco,

Wonder if you tested build/boot with KFENCE_NUM_OBJECTS=65535? Can a
compiler create such a large object?

quoted hunk ↗ jump to hunk
+config KFENCE_FAULT_INJECTION
+       int "Fault injection for stress testing"
+       default 0
+       depends on EXPERT
+       help
+         The inverse probability with which to randomly protect KFENCE object
+         pages, resulting in spurious use-after-frees. The main purpose of
+         this option is to stress-test KFENCE with concurrent error reports
+         and allocations/frees. A value of 0 disables fault injection.
I would name this differently. "FAULT_INJECTION" is already taken for
a different thing, so it's a bit confusing.
KFENCE_DEBUG_SOMETHING may be a better name.
It would also be good to make it very clear in the short description
that this is for testing of KFENCE itself. When I configure syzbot I
routinely can't figure out if various DEBUG configs detect user
errors, or enable additional unit tests, or something else.
Maybe it should depend on DEBUG_KERNEL as well?
quoted hunk ↗ jump to hunk
+/*
+ * Get the canary byte pattern for @addr. Use a pattern that varies based on the
+ * lower 3 bits of the address, to detect memory corruptions with higher
+ * probability, where similar constants are used.
+ */
+#define KFENCE_CANARY_PATTERN(addr) ((u8)0xaa ^ (u8)((unsigned long)addr & 0x7))
(addr) in macro body
+       seq_con_printf(seq,
+                      "kfence-#%zd [0x" PTR_FMT "-0x" PTR_FMT
PTR_FMT is only used in this file, should it be declared in report.c?

Please post example reports somewhere. It's hard to figure out all
details of the reporting/formatting.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Thread (55 messages) 55 messages, 10 authors, last reply 2020-09-16
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help