Commit 55a2346c authored by Marco Elver's avatar Marco Elver Committed by Paul E. McKenney
Browse files

kcsan: Never set up watchpoints on NULL pointers



Avoid setting up watchpoints on NULL pointers, as otherwise we would
crash inside the KCSAN runtime (when checking for value changes) instead
of the instrumented code.

Because that may be confusing, skip any address less than PAGE_SIZE.

Reviewed-by: default avatarDmitry Vyukov <dvyukov@google.com>
Signed-off-by: default avatarMarco Elver <elver@google.com>
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
parent 4761612f
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -48,7 +48,11 @@

static inline bool check_encodable(unsigned long addr, size_t size)
{
	return size <= MAX_ENCODABLE_SIZE;
	/*
	 * While we can encode addrs<PAGE_SIZE, avoid crashing with a NULL
	 * pointer deref inside KCSAN.
	 */
	return addr >= PAGE_SIZE && size <= MAX_ENCODABLE_SIZE;
}

static inline long