diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-08-18 21:16:49 -0400 |
---|---|---|
committer | Sasha Levin <alexander.levin@verizon.com> | 2016-10-05 22:40:20 -0400 |
commit | 591ca382baa0416352fd917bc33bf05491a270c6 (patch) | |
tree | 243937dbbdda3805f7a7d72854036d37299bb4cc | |
parent | a4bc5779f6e3ec3d1052d7b327aa76f26d73acaf (diff) | |
download | lwn-591ca382baa0416352fd917bc33bf05491a270c6.tar.gz lwn-591ca382baa0416352fd917bc33bf05491a270c6.zip |
hexagon: fix strncpy_from_user() error return
[ Upstream commit f35c1e0671728d1c9abc405d05ef548b5fcb2fc4 ]
It's -EFAULT, not -1 (and contrary to the comment in there,
__strnlen_user() can return 0 - on faults).
Cc: stable@vger.kernel.org
Acked-by: Richard Kuo <rkuo@codeaurora.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
-rw-r--r-- | arch/hexagon/include/asm/uaccess.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/hexagon/include/asm/uaccess.h b/arch/hexagon/include/asm/uaccess.h index e4127e4d6a5b..25fc9049db8a 100644 --- a/arch/hexagon/include/asm/uaccess.h +++ b/arch/hexagon/include/asm/uaccess.h @@ -102,7 +102,8 @@ static inline long hexagon_strncpy_from_user(char *dst, const char __user *src, { long res = __strnlen_user(src, n); - /* return from strnlen can't be zero -- that would be rubbish. */ + if (unlikely(!res)) + return -EFAULT; if (res > n) { copy_from_user(dst, src, n); |