From: Thomas Bogendoerfer Date: Thu, 15 Apr 2021 21:21:11 +0000 (+0200) Subject: MIPS: Fix strnlen_user access check X-Git-Tag: perf_urgent_for_v5.13_rc1~3^2~24 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2c92ef8ff8d327797c1920ae7f938bcc6f3f7421;p=users%2Fdwmw2%2Flinux.git 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") Signed-off-by: Thomas Bogendoerfer --- diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h index ab47e597656a6..783fecce65c8f 100644 --- a/arch/mips/include/asm/uaccess.h +++ b/arch/mips/include/asm/uaccess.h @@ -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__(