Skip to contentSkip to conversation

Patch "lib: Fix strnlen_user() to not touch memory after specified maximum" has been added to the 3.14-stable tree

PATCH [email protected] 1 participant 1 message Jun 3, 2015

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

lib: Fix strnlen_user() to not touch memory after specified maximum

to the 3.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
lib-fix-strnlen_user-to-not-touch-memory-after-specified-maximum.patch
and it can be found in the queue-3.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From f18c34e483ff6b1d9866472221e4015b3a4698e4 Mon Sep 17 00:00:00 2001

From: Jan Kara <[email protected]>
Date: Tue, 2 Jun 2015 17:10:28 +0200
Subject: lib: Fix strnlen_user() to not touch memory after specified maximum

From: Jan Kara <[email protected]>

commit f18c34e483ff6b1d9866472221e4015b3a4698e4 upstream.

If the specified maximum length of the string is a multiple of unsigned long, we would load one long behind the specified maximum. If that happens to be in a next page, we can hit a page fault although we were not expected to.

Fix the off-by-one bug in the test whether we are at the end of the specified range.

---
 lib/strnlen_user.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/strnlen_user.c +2 -1
@@ -57,7 +57,8 @@ static inline long do_strnlen_user(const
 			return res + find_zero(data) + 1 - align;
 		}
 		res += sizeof(unsigned long);
-		if (unlikely(max < sizeof(unsigned long)))
+		/* We already handled 'unsigned long' bytes. Did we do it all ? */
+		if (unlikely(max <= sizeof(unsigned long)))
 			break;
 		max -= sizeof(unsigned long);
 		if (unlikely(__get_user(c,(unsigned long __user *)(src+res))))

Patches currently in stable-queue which might be from [email protected] are

queue-3.14/lib-fix-strnlen_user-to-not-touch-memory-after-specified-maximum.patch