From: Scott Wood <scottwood@freescale.com>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Timur Tabi <timur@freescale.com>, <alan@lxorguk.ukuu.org.uk>,
<linux-kernel@vger.kernel.org>, <akpm@linux-foundation.org>
Subject: Re: [PATCH] lib: introduce strdup_from_user
Date: Fri, 3 Jun 2011 14:31:27 -0500 [thread overview]
Message-ID: <20110603143127.3c25896e@schlenkerla.am.freescale.net> (raw)
In-Reply-To: <BANLkTikmVncMdJhK0Hi6uWeiE_S9TtdhTQ@mail.gmail.com>
On Fri, 3 Jun 2011 22:12:37 +0300
Alexey Dobriyan <adobriyan@gmail.com> wrote:
> On Fri, Jun 3, 2011 at 9:53 PM, Scott Wood <scottwood@freescale.com> wrote:
> > On Fri, 3 Jun 2011 21:39:28 +0300
> > Alexey Dobriyan <adobriyan@gmail.com> wrote:
> >
> >> On Fri, Jun 3, 2011 at 9:34 PM, Timur Tabi <timur@freescale.com> wrote:
> >> > Would it be better if I did this:
> >>
> >> The point is data should cross kernelspace/userspace boundary only once.
> >>
> >
> > Why does it matter, as long as it doesn't hurt the kernel if userspace
> > plays games (i.e. take care of the NUL termination), and it's not a
> > performance problem?
>
> Because now you're lucky C strings are NUL-terminated.
> If this "idiom" applies to some other case like "validate + copy",
> we have a bug.
It's not an idiom. It is a simple solution to this particular problem.
> We copy data to kernelspace THEN validate or copy or whatever.
> This is obviously correct and safe.
That doesn't mean that other things are necessarily incorrect or unsafe.
The first access is not validation in this case.
In any case, as it appears there's already a strndup_user() in the kernel,
we'll just use that. You can "fix" it to do a single userspace access, if
you'd like. :-)
-Scott
next prev parent reply other threads:[~2011-06-03 19:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-03 16:45 Timur Tabi
2011-06-03 17:45 ` Alexey Dobriyan
2011-06-03 18:22 ` Timur Tabi
2011-06-03 18:26 ` Alexey Dobriyan
2011-06-03 18:34 ` Timur Tabi
2011-06-03 18:39 ` Alexey Dobriyan
2011-06-03 18:41 ` Timur Tabi
2011-06-03 18:47 ` Alexey Dobriyan
2011-06-03 18:54 ` Timur Tabi
2011-06-03 18:53 ` Scott Wood
2011-06-03 18:57 ` Timur Tabi
2011-06-03 19:12 ` Alexey Dobriyan
2011-06-03 19:31 ` Scott Wood [this message]
2011-06-03 22:41 ` Al Viro
2011-06-03 18:37 ` Scott Wood
2011-06-03 21:58 ` 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=20110603143127.3c25896e@schlenkerla.am.freescale.net \
--to=scottwood@freescale.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=timur@freescale.com \
/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
all inboxes | Powered by JetHome®