linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Waiman Long <waiman.long@hp.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"Chandramouleeswaran, Aswin" <aswin@hp.com>,
	"Norton, Scott J" <scott.norton@hp.com>,
	George Spelvin <linux@horizon.com>,
	John Stoffel <john@stoffel.org>
Subject: Re: [PATCH v2 1/1] dcache: Translating dentry into pathname without taking rename_lock
Date: Thu, 05 Sep 2013 22:01:34 -0400	[thread overview]
Message-ID: <5229377E.5050805@hp.com> (raw)
In-Reply-To: <CA+55aFzx4YHY3e5AH0U5AkAQSc8pZyC35jBP4t2jpbi8NHM18g@mail.gmail.com>

On 09/05/2013 04:42 PM, Linus Torvalds wrote:
> On Thu, Sep 5, 2013 at 1:29 PM, Waiman Long<waiman.long@hp.com>  wrote:
>> It is not as simple as doing a strncpy().
> Yes it damn well is.
>
> Stop the f*cking stupid arguments, and instead listen to what I say.
>
> Here. Let me bold-face the most important part for you, so that you
> don't miss it in all the other crap:
>
>     MAKE prepend() JUST USE "strncpy()" INSTEAD OF "memcpy()".
>
> Nothing else. Seriously. Your "you can't do it because we copy
> backwards" arguments are pure and utter garbage, exactly BECAUSE YOU
> DON'T CHANGE ANY OF THAT. You can actually use the unreliable length
> variable BUT YOU MUST STILL STOP AT A ZERO.
>
> Get it?
>
> You're complicating the whole thing for no good reason. I'm telling
> you (and HAVE BEEN telling you multiple times) that you cannot use
> "memcpy()" because the length may not be reliable, so you need to
> check for zero in the middle and stop early. All your arguments have
> been totally pointless, because you don't seem to see that simple and
> fundamental issue. You don't change ANYTHING else. But you damn well
> not do a "memcpy", you do something that stops when it hits a NUL
> character.
>
> We call that function "strncpy()". I'd actually prefer to write it out
> by hand (because somebody could implement "strncpy()" as a
> questionable function that accesses past the NUL as long as it's
> within the 'n'), and because I think we might want to do that
> word-at-a-time version of it, but for a first approximation, just do
> that one-liner version.
>
> Don't do anything else. Don't do locking. Don't do memchr. Just make
> sure that you stop at a NUL character, and don't trust the length,
> because the length may not match the pointer. That's was always ALL
> you needed to do.
>
>                Linus
I am sorry that I misunderstand what you said. I will do what you and Al 
advise me to do.

-Longman

  reply	other threads:[~2013-09-06  2:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-05 18:55 [PATCH v2 0/1] dcache: Translating dentry into pathname without taking rename_lock Waiman Long
2013-09-05 18:55 ` [PATCH v2 1/1] " Waiman Long
2013-09-05 19:35   ` Linus Torvalds
2013-09-05 20:29     ` Waiman Long
2013-09-05 20:42       ` Linus Torvalds
2013-09-06  2:01         ` Waiman Long [this message]
2013-09-06  4:54           ` Linus Torvalds
2013-09-05 20:46       ` Al Viro
2013-09-05 21:27         ` Linus Torvalds
2013-09-05 20:04   ` Al Viro
2013-09-05 20:43     ` Waiman Long

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=5229377E.5050805@hp.com \
    --to=waiman.long@hp.com \
    --cc=aswin@hp.com \
    --cc=john@stoffel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@horizon.com \
    --cc=scott.norton@hp.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).