Re: [PATCH 3/3] VFS: close race between getcwd() and d_move()

From: Nikolay Borisov
Date: Thu Nov 09 2017 - 11:02:29 EST




On 9.11.2017 15:08, Matthew Wilcox wrote:
> On Thu, Nov 09, 2017 at 01:41:24PM +0200, Nikolay Borisov wrote:
>> On 9.11.2017 05:22, NeilBrown wrote:
>>> @@ -493,12 +496,18 @@ void __d_drop(struct dentry *dentry)
>>> } else
>>> hlist_bl_lock(b);
>>> __hlist_bl_del(&dentry->d_hash);
>>> - dentry->d_hash.pprev = NULL;
>>> + if (likely(!moving))
>>> + dentry->d_hash.pprev = NULL;
>>
>> nit: isn't a bit more explicit if (unlikely(moving)). I suspect the end
>> result is the same, however it's easy to miss the !. It's not a big deal
>> but just wondering.
>
> umm ... you just suggested the exact opposite of what the patch is
> intended to do. likely()/unlikely() only hint to the compiler the
> probabilities of the branch; they don't change the meaning of the
> condition.

brainfart, disregard my comment doh....

>
>