Skip to contentSkip to conversation

MIPS: Fix strnlen_user access check

PATCH Applied Thomas Bogendoerfer 1 participant 2 messages Apr 15, 2021 – Apr 16, 2021 MIPS

lore
Share & tools
lore

Thomas Bogendoerfer

author maintainer
#0 lore raw

PATCH 1/1 MIPS: Fix strnlen_user access check

Commit 04324f44cb69 ("MIPS: Remove get_fs/set_fs") changed the access_ok for strnlen_user to check the whole range, which broke some callers of strndup_user(). Restore the old behaviour and just check the first byte.

Fixes 04324f44cb69 ("MIPS: Remove get_fs/set_fs")
---
 arch/mips/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/include/asm/uaccess.h +2 -2
index ab47e597656a..783fecce65c8 100644
@@ -614,8 +614,8 @@ static inline long strnlen_user(const char __user *s, long n)
 {
 	long res;
 
-	if (!access_ok(s, n))
-		return -0;
+	if (!access_ok(s, 1))
+		return 0;
 
 	might_fault();
 	__asm__ __volatile__(
Signature · 1 line
2.29.2
author maintainer Applied
#1 lore raw
Quoted 9 lines · Thomas Bogendoerfer

Commit 04324f44cb69 ("MIPS: Remove get_fs/set_fs") changed the access_ok for strnlen_user to check the whole range, which broke some callers of strndup_user(). Restore the old behaviour and just check the first byte.

Fixes 04324f44cb69 ("MIPS: Remove get_fs/set_fs")
---
 arch/mips/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]