* [PATCH] mm/maccess.c: actually return -EFAULT from strncpy_from_unsafe
@ 2015-10-17 20:20 Rasmus Villemoes
2015-10-17 20:33 ` Alexei Starovoitov
0 siblings, 1 reply; 2+ messages in thread
From: Rasmus Villemoes @ 2015-10-17 20:20 UTC (permalink / raw)
To: Andrew Morton, Alexei Starovoitov, David S. Miller
Cc: Rasmus Villemoes, linux-mm, linux-kernel
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>
---
Probably not -stable-worthy. I can only find two callers, one of which
ignores the return value.
mm/maccess.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/maccess.c b/mm/maccess.c
index 34fe24759ed1..d318db246826 100644
--- a/mm/maccess.c
+++ b/mm/maccess.c
@@ -99,5 +99,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;
}
--
2.6.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/maccess.c: actually return -EFAULT from strncpy_from_unsafe
2015-10-17 20:20 [PATCH] mm/maccess.c: actually return -EFAULT from strncpy_from_unsafe Rasmus Villemoes
@ 2015-10-17 20:33 ` Alexei Starovoitov
0 siblings, 0 replies; 2+ messages in thread
From: Alexei Starovoitov @ 2015-10-17 20:33 UTC (permalink / raw)
To: Rasmus Villemoes, Andrew Morton, David S. Miller
Cc: linux-mm, linux-kernel, Masami Hiramatsu, Namhyung Kim
On 10/17/15 1:20 PM, Rasmus Villemoes wrote:
> 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>
> ---
> Probably not -stable-worthy. I can only find two callers, one of which
> ignores the return value.
good catch.
Acked-by: Alexei Starovoitov <ast@kernel.org>
cc-ing original authors where I copy pasted that part from.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-17 20:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-17 20:20 [PATCH] mm/maccess.c: actually return -EFAULT from strncpy_from_unsafe Rasmus Villemoes
2015-10-17 20:33 ` Alexei Starovoitov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox