public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Waiman Long <waiman.long@hp.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Chandramouleeswaran, Aswin" <aswin@hp.com>,
	"Norton, Scott J" <scott.norton@hp.com>
Subject: Re: [PATCH] dcache: Translating dentry into pathname without taking rename_lock
Date: Wed, 04 Sep 2013 15:33:00 -0400	[thread overview]
Message-ID: <52278AEC.2020307@hp.com> (raw)
In-Reply-To: <20130904191104.GK13318@ZenIV.linux.org.uk>

On 09/04/2013 03:11 PM, Al Viro wrote:
> On Wed, Sep 04, 2013 at 03:05:23PM -0400, Waiman Long wrote:
>>
>>   static int prepend_name(char **buffer, int *buflen, struct qstr *name)
>>   {
>> -	return prepend(buffer, buflen, name->name, name->len);
>> +	/*
>> +	 * With RCU path tracing, it may race with rename. Use
>> +	 * ACCESS_ONCE() to make sure that it is either the old or
>> +	 * the new name pointer. The length does not really matter as
>> +	 * the sequence number check will eventually catch any ongoing
>> +	 * rename operation.
>> +	 */
>> +	const char *dname = ACCESS_ONCE(name->name);
>> +	int   dlen = name->len;
>> +
>> +	if (unlikely(!dname || !dlen))
>> +		return -EINVAL;
>> +	return prepend(buffer, buflen, dname, dlen);
> NAK.  A race with d_move() can very well leave you with dname pointing into
> an object of length smaller than dlen.  You *can* copy it byte-by-byte
> and rely on NUL-termination, but you can't rely on length being accurate -
> not without having excluded d_move().

I have thought about that. But if a d_move() is going on, the string in 
the buffer will be discarded as the sequence number will change. So 
whether or not it have embedded null byte shouldn't matter. That is why 
I didn't add code to do byte-by-byte copy at this first patch. I can add 
code to do that if you think it is safer to do so.

Regards,
Longman

  reply	other threads:[~2013-09-04 19:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-04 19:05 [PATCH] dcache: Translating dentry into pathname without taking rename_lock Waiman Long
2013-09-04 19:11 ` Al Viro
2013-09-04 19:33   ` Waiman Long [this message]
2013-09-04 19:43     ` Al Viro
2013-09-05  1:55       ` Waiman Long
2013-09-05  2:42         ` Al Viro
     [not found]   ` <CA+55aFwW+hWwQd8+NgukSidHbf2bnd6QO0yKK9NAgX+9rt0cOQ@mail.gmail.com>
     [not found]     ` <5227E321.4090008@hp.com>
2013-09-05  2:48       ` Linus Torvalds
2013-09-05  4:20         ` Al Viro
2013-09-04 19:26 ` Waiman Long
2013-09-04 20:40   ` John Stoffel
2013-09-05  2:04     ` Waiman Long
2013-09-05 13:29       ` John Stoffel
2013-09-05 17:28         ` Waiman Long
2013-09-04 21:31 ` Linus Torvalds
2013-09-05  2:17   ` Waiman Long
  -- strict thread matches above, loose matches on Subject: below --
2013-09-05  4:30 George Spelvin
2013-09-05 17:06 ` 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=52278AEC.2020307@hp.com \
    --to=waiman.long@hp.com \
    --cc=aswin@hp.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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