]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mm/maccess.c: actually return -EFAULT from strncpy_from_unsafe
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Wed, 21 Oct 2015 22:03:19 +0000 (09:03 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 21 Oct 2015 22:03:19 +0000 (09:03 +1100)
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 <linux@rasmusvillemoes.dk>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/maccess.c

index 1b13638d238d514ad7760ca680507dc8469010be..d159b1c96e484d902f6edb34ebb5a83a3977bd57 100644 (file)
@@ -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;
 }