linuxkm/linuxkm_wc_port.h: in my_memmove(), early-return when n == 0 to avoid size_t underflow

The backward-copy branches compute (n - 1) as size_t, which wraps to SIZE_MAX for n == 0 and, with src below dest, drives the loop backward through kernel memory until it oopses; matches glibc / musl / kernel memmove().

Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
This commit is contained in:
Sameeh Jubran
2026-04-27 11:15:23 +03:00
parent 7ca42d1e55
commit 2f660a3f7b
+2
View File
@@ -450,6 +450,8 @@
#define memset my_memset
static inline void *my_memmove(void *dest, const void *src, size_t n) {
if (n == 0)
return dest;
if (! (((uintptr_t)dest | (uintptr_t)src | (uintptr_t)n)
& (uintptr_t)(sizeof(uintptr_t) - 1)))
{