Subject: [withdrawn] lib-stringc-strlcpy-might-read-too-far.patch removed from -mm tree To: dan.carpenter@xxxxxxxxxx,vegard.nossum@xxxxxxxxx,mm-commits@xxxxxxxxxxxxxxx From: akpm@xxxxxxxxxxxxxxxxxxxx Date: Tue, 15 Apr 2014 13:46:01 -0700 The patch titled Subject: lib/string.c: strlcpy() might read too far has been removed from the -mm tree. Its filename was lib-stringc-strlcpy-might-read-too-far.patch This patch was dropped because it was withdrawn ------------------------------------------------------ From: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Subject: lib/string.c: strlcpy() might read too far Imagine you have a user controlled variable at the end of a struct which is allocated at the end of a page. The strlen() could read beyond the mapped memory and cause an oops. Probably there are two reasons why we have never hit this condition in real life. First you would have to be really unlucky for all the variables to line up so the oops can happen. Second we don't do a lot of fuzzing with invalid strings. The strnlen() call is obviously a little bit slower than strlen() but I have tested it and I think it's probably ok. Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Reported-by: Vegard Nossum <vegard.nossum@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- lib/string.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff -puN lib/string.c~lib-stringc-strlcpy-might-read-too-far lib/string.c --- a/lib/string.c~lib-stringc-strlcpy-might-read-too-far +++ a/lib/string.c @@ -148,10 +148,10 @@ EXPORT_SYMBOL(strncpy); */ size_t strlcpy(char *dest, const char *src, size_t size) { - size_t ret = strlen(src); + size_t ret = strnlen(src, size); if (size) { - size_t len = (ret >= size) ? size - 1 : ret; + size_t len = (ret < size) ? ret : ret - 1; memcpy(dest, src, len); dest[len] = '\0'; } _ Patches currently in -mm which might be from dan.carpenter@xxxxxxxxxx are lib-stringc-use-the-name-c-string-in-comments.patch linux-next.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html