From: Andrew Morton <akpm@linux-foundation.org>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
Andi Kleen <ak@linux.intel.com>,
Grant Likely <grant.likely@linaro.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] lib: string.c: Added a funktion function strzcpy
Date: Wed, 24 Sep 2014 14:26:32 -0700 [thread overview]
Message-ID: <20140924142632.7fe876ce1e743753581160a9@linux-foundation.org> (raw)
In-Reply-To: <CAFo99gbGoyf6GEt4ST_Q_WfYe39j+ke7t7XL6QZBYvMesMNZQg@mail.gmail.com>
On Wed, 24 Sep 2014 22:51:14 +0200 Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> wrote:
> 2014-09-24 17:41 GMT+02:00 Dan Carpenter <dan.carpenter@oracle.com>:
> > On Wed, Sep 24, 2014 at 07:35:55AM -0700, Andi Kleen wrote:
> >> On Wed, Sep 24, 2014 at 10:52:06AM +0300, Dan Carpenter wrote:
> >> > On Tue, Sep 23, 2014 at 06:17:53PM -0700, Andi Kleen wrote:
> >> > > On Wed, Sep 24, 2014 at 12:13:36AM +0200, Rickard Strandqvist wrote:
> >> > > > Added a function strzcpy which works the same as strncpy,
> >> > > > but guaranteed to produce the trailing null character.
> >> > >
> >> > > Do we really need the bizarre strncpy padding semantics for anything?
> >> > > Why not just use strlcpy?
> >> >
> >> > We do need the padding in many places to prevent information leaks.
> >>
> >> Like where?
> >>
> >
> > You're asking what would break if we switched every strncpy() to
> > strlcpy() but it's not an easy question to answer.
> >
> > I've looked a lot at information leaks, but strings are still a blind
> > spot for my Smatch. My check only looks at normal variables, arrays.
> > Eventually I hope to fix this, of course.
> >
> > I did a git search and Rickard has added some examples, but there were
> > definitely other places that rely strncpy() padding before.
> >
> > regards,
> > dan carpenter
>
>
> Hi
>
> If you want to see examples of this type of error, you can check the
> patches I've done over the past two months.
> So in linux-next
>
> git log --patch-with-stat
>
> And search for my email address.
>
> And there is also an approximately 20 more patches I waited to see if
> I will be able to use a potential strzcpy :-)
I have to say, this email thread has been a good demonstration of the
effects of incomplete changelogging :(
How's about you try again and this time include a *full* explanation of
why you believe the kernel needs strzcpy()? Describe the problem,
provide those examples, explain the proposed solution, etc.
Also... I misread the code - that implementation indeed zeroes out to
the end of the destination. I'm not sure that it does it very
efficiently though - it repeatedly dereferences `src' just to obtain a
null byte? A second nulling loop would be clearer and perhaps faster.
next prev parent reply other threads:[~2014-09-24 21:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-23 22:13 Rickard Strandqvist
2014-09-23 22:13 ` Rickard Strandqvist
2014-09-23 22:40 ` Andrew Morton
2014-09-24 1:17 ` Andi Kleen
2014-09-24 7:52 ` Dan Carpenter
2014-09-24 14:14 ` Lennart Sorensen
2014-09-24 14:35 ` Andi Kleen
[not found] ` <CAFo99gZUfFUB9xX0GYW=hJMNouiU-M9apZ8KtPg9MW3x7gxZcg@mail.gmail.com>
2014-09-24 14:58 ` Andi Kleen
2014-09-24 15:41 ` Dan Carpenter
2014-09-24 20:51 ` Rickard Strandqvist
2014-09-24 21:26 ` Andrew Morton [this message]
2014-09-24 21:49 ` Rickard Strandqvist
2014-09-24 22:55 ` Andi Kleen
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=20140924142632.7fe876ce1e743753581160a9@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=ak@linux.intel.com \
--cc=dan.carpenter@oracle.com \
--cc=grant.likely@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rickard_strandqvist@spectrumdigital.se \
/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®