From 2f660a3f7b88885d06519677e72e62bf1999bb4c Mon Sep 17 00:00:00 2001 From: Sameeh Jubran Date: Mon, 27 Apr 2026 11:15:23 +0300 Subject: [PATCH] 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 --- linuxkm/linuxkm_wc_port.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linuxkm/linuxkm_wc_port.h b/linuxkm/linuxkm_wc_port.h index 22255af456..50f7a1f050 100644 --- a/linuxkm/linuxkm_wc_port.h +++ b/linuxkm/linuxkm_wc_port.h @@ -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))) {