From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Davi Arnaut <davi.arnaut@gmail.com>
Cc: torvalds@osdl.org, akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/2] strndup_user, v2
Date: Thu, 16 Feb 2006 01:25:56 +0000 [thread overview]
Message-ID: <1140053156.14831.43.camel@localhost.localdomain> (raw)
In-Reply-To: <20060215182258.03505613.davi.arnaut@gmail.com>
On Mer, 2006-02-15 at 18:22 -0300, Davi Arnaut wrote:
> +static inline char *strdup_user(const char __user *s)
> +{
> + return strndup_user(s, 4096);
> +}
Still shouldn't exist. Its just a bad idea to give people broken
function they don't yet use.
> + length = strlen_user(s);
Should use strnlen_user or this function is useless for most cases.
> +
> + if (!length)
> + return ERR_PTR(-EFAULT);
Zero isn't an -EFAULT length. Its a null string and valid
> +
> + if (length > n)
> + length = n;
> +
> + p = kmalloc(length, GFP_KERNEL);
> +
> + if (!p)
> + return ERR_PTR(-ENOMEM);
> +
> + if (strncpy_from_user(p, s, length) < 0) {
> + kfree(p);
> + return ERR_PTR(-EFAULT);
> + }
> +
> + p[length - 1] = '\0';
And still broken.
"Hello" -> length = 5 "Hello\0"[4] = 0 "Hell"
next prev parent reply other threads:[~2006-02-16 1:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-15 21:22 Davi Arnaut
2006-02-15 20:54 ` Sergey Vlasov
2006-02-16 1:25 ` Alan Cox [this message]
2006-02-16 3:56 ` Davi Arnaut
2006-02-16 14:44 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1140053156.14831.43.camel@localhost.localdomain \
--to=alan@lxorguk.ukuu.org.uk \
--cc=akpm@osdl.org \
--cc=davi.arnaut@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome