Re: [PATCH] lib: introduce strdup_from_user

From: Timur Tabi
Date: Fri Jun 03 2011 - 14:41:20 EST


Alexey Dobriyan wrote:
> The point is data should cross kernelspace/userspace boundary only once.

And my new version does that. I'm just asking if you're okay with it.

Let me repost the whole function:

char *strdup_from_user(const char __user *ustr, size_t max)
{
size_t len;
char *str;

str = kzalloc(max, GFP_KERNEL);
if (!str)
return ERR_PTR(-ENOMEM);

if (copy_from_user(str, ustr, max - 1)) {
kfree(str);
return ERR_PTR(-EFAULT);
}

return krealloc(str, strlen(str) + 1, GFP_KERNEL);
}


--
Timur Tabi
Linux kernel developer at Freescale

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/