mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 09:16:33 +00:00
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 <kpsingh@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Cc: Jann Horn <jannh@google.com> Cc: Christophe Leroy <christophe.leroy@c-s.fr> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20200414225705.255711-1-kpsingh@chromium.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
9ac1757580
commit
0788735899
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user