Skip to contentSkip to conversation

kexec: ensure user memory sizes do not wrap

PATCH New [email protected] 1 participant 1 message Aug 2, 2016 kexec

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 79/111 kexec: ensure user memory sizes do not wrap

From: Russell King <[email protected]>
Subject: kexec: ensure user memory sizes do not wrap

Ensure that user memory sizes do not wrap around when validating the user input, which can lead to the following input validation working incorrectly.

[[email protected]: fix it for kexec-return-error-number-directly.patch]
Cc Keerthy <[email protected]>
Cc Vitaly Andrianov <[email protected]>
Cc Eric Biederman <[email protected]>
Cc Dave Young <[email protected]>
Cc Vivek Goyal <[email protected]>
Cc Simon Horman <[email protected]>

---

 kernel/kexec_core.c |    2 ++
 1 file changed, 2 insertions(+)
kernel/kexec_core.c renamed from kernel/kexec_core.c~kexec-ensure-user-memory-sizes-do-not-wrap +2 -0
diff -puN kernel/kexec_core.c~kexec-ensure-user-memory-sizes-do-not-wrap kernel/kexec_core.c
@@ -168,6 +168,8 @@ int sanity_check_segment_list(struct kim
 
 		mstart = image->segment[i].mem;
 		mend   = mstart + image->segment[i].memsz;
+		if (mstart > mend)
+			return -EADDRNOTAVAIL;
 		if ((mstart & ~PAGE_MASK) || (mend & ~PAGE_MASK))
 			return -EADDRNOTAVAIL;
 		if (mend >= KEXEC_DESTINATION_MEMORY_LIMIT)

_