Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1249447 > unrolled thread

[PATCH] mm/maccess.c: actually return -EFAULT from strncpy_from_unsafe

Started byRasmus Villemoes <linux@rasmusvillemoes.dk>
First post2015-10-17 22:30 +0200
Last post2015-10-17 22:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mm/maccess.c: actually return -EFAULT from strncpy_from_unsafe Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-10-17 22:30 +0200
    Re: [PATCH] mm/maccess.c: actually return -EFAULT from  strncpy_from_unsafe Alexei Starovoitov <ast@plumgrid.com> - 2015-10-17 22:40 +0200

#1249447 — [PATCH] mm/maccess.c: actually return -EFAULT from strncpy_from_unsafe

FromRasmus Villemoes <linux@rasmusvillemoes.dk>
Date2015-10-17 22:30 +0200
Subject[PATCH] mm/maccess.c: actually return -EFAULT from strncpy_from_unsafe
Message-ID<qkGh4-8he-9@gated-at.bofh.it>
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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1249451 — Re: [PATCH] mm/maccess.c: actually return -EFAULT from strncpy_from_unsafe

FromAlexei Starovoitov <ast@plumgrid.com>
Date2015-10-17 22:40 +0200
SubjectRe: [PATCH] mm/maccess.c: actually return -EFAULT from strncpy_from_unsafe
Message-ID<qkGqK-8ts-21@gated-at.bofh.it>
In reply to#1249447
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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web