From 9dd861d55b01f1d0848f82007e8665371ae18710 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 5 Nov 2015 18:50:11 -0800 Subject: mm/maccess.c: actually return -EFAULT from strncpy_from_unsafe As far as I can tell, strncpy_from_unsafe never returns -EFAULT. ret is the result of a __copy_from_user_inatomic(), which is 0 for success and positive (in this case necessarily 1) for access error - it is never negative. So we were always returning the length of the, possibly truncated, destination string. Signed-off-by: Rasmus Villemoes Acked-by: Alexei Starovoitov Cc: Masami Hiramatsu Cc: Namhyung Kim Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/maccess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mm') diff --git a/mm/maccess.c b/mm/maccess.c index 1b13638d238d..d159b1c96e48 100644 --- a/mm/maccess.c +++ b/mm/maccess.c @@ -104,5 +104,5 @@ long strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count) pagefault_enable(); set_fs(old_fs); - return ret < 0 ? ret : src - unsafe_addr; + return ret ? -EFAULT : src - unsafe_addr; } -- cgit v1.2.3-59-g8ed1b