Commit 94fd4464 authored by Kees Cook's avatar Kees Cook
Browse files

fortify: Fix incorrect reporting of read buffer size



When FORTIFY_SOURCE reports about a run-time buffer overread, the wrong
buffer size was being shown in the error message. (The bounds checking
was correct.)

Fixes: 3d965b33 ("fortify: Improve buffer overflow reporting")
Reviewed-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20250729231817.work.023-kees@kernel.org


Signed-off-by: default avatarKees Cook <kees@kernel.org>
parent fc525d62
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -596,7 +596,7 @@ __FORTIFY_INLINE bool fortify_memcpy_chk(__kernel_size_t size,
	if (p_size != SIZE_MAX && p_size < size)
		fortify_panic(func, FORTIFY_WRITE, p_size, size, true);
	else if (q_size != SIZE_MAX && q_size < size)
		fortify_panic(func, FORTIFY_READ, p_size, size, true);
		fortify_panic(func, FORTIFY_READ, q_size, size, true);

	/*
	 * Warn when writing beyond destination field size.