From: KP Singh Date: Thu, 4 Jun 2020 23:50:11 +0000 (-0700) Subject: lib: Add might_fault() to strncpy_from_user. X-Git-Tag: v5.10.7~2446^2~51 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=07887358993d48571f0f3a25cfce715564b35587;p=platform%2Fkernel%2Flinux-rpi.git lib: Add might_fault() to strncpy_from_user. When updating a piece of broken logic from using get_user to strncpy_from_user, we noticed that a warning which is expected when calling a function that might fault from an atomic context with pagefaults enabled disappeared. Not having this warning in place can lead to calling strncpy_from_user from an atomic context and eventually kernel crashes/stack corruption. Signed-off-by: KP Singh Signed-off-by: Andrew Morton Reviewed-by: Andrew Morton Cc: Jann Horn Cc: Christophe Leroy Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20200414225705.255711-1-kpsingh@chromium.org Signed-off-by: Linus Torvalds --- diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c index b90ec55..34696a3 100644 --- a/lib/strncpy_from_user.c +++ b/lib/strncpy_from_user.c @@ -98,6 +98,7 @@ long strncpy_from_user(char *dst, const char __user *src, long count) { unsigned long max_addr, src_addr; + might_fault(); if (unlikely(count <= 0)) return 0;