From: Andrew Morton Subject: [patch 076/127] lib: Add might_fault() to strncpy_from_user. Date: Thu, 04 Jun 2020 16:50:11 -0700 Message-ID: <20200604235011.CzzlOlAbI%akpm@linux-foundation.org> References: <20200604164523.e15f3177f4b69dcb4f2534a1@linux-foundation.org> Reply-To: linux-kernel@vger.kernel.org Return-path: Received: from mail.kernel.org ([198.145.29.99]:47716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbgFDXuN (ORCPT ); Thu, 4 Jun 2020 19:50:13 -0400 In-Reply-To: <20200604164523.e15f3177f4b69dcb4f2534a1@linux-foundation.org> Sender: mm-commits-owner@vger.kernel.org List-Id: mm-commits@vger.kernel.org To: akpm@linux-foundation.org, christophe.leroy@c-s.fr, jannh@google.com, kpsingh@chromium.org, kpsingh@google.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, peterz@infradead.org, torvalds@linux-foundation.org From: KP Singh Subject: lib: Add might_fault() to strncpy_from_user. From: KP Singh 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. Link: http://lkml.kernel.org/r/20200414225705.255711-1-kpsingh@chromium.org Signed-off-by: KP Singh Reviewed-by: Andrew Morton Cc: Jann Horn Cc: Christophe Leroy Cc: Peter Zijlstra Signed-off-by: Andrew Morton --- lib/strncpy_from_user.c | 1 + 1 file changed, 1 insertion(+) --- a/lib/strncpy_from_user.c~lib-add-might_fault-to-strncpy_from_user +++ a/lib/strncpy_from_user.c @@ -98,6 +98,7 @@ long strncpy_from_user(char *dst, const { unsigned long max_addr, src_addr; + might_fault(); if (unlikely(count <= 0)) return 0; _