public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
To: gaowanlong@cn.fujitsu.com
Cc: ltp-list@lists.sourceforge.net, Savkov <asavkov@redhat.com>,
	Artem@edo.cn.fujitsu.com
Subject: Re: [LTP] [PATCH 2/2] syscalls/getcwd04.c: regression test for getcwd(2)
Date: Sun, 27 Jul 2014 16:42:03 +0800	[thread overview]
Message-ID: <53D4BB5B.5030701@cn.fujitsu.com> (raw)
In-Reply-To: <53CCDBFA.4060209@cn.fujitsu.com>

Hi,

On 07/21/2014 05:23 PM, Xiaoguang Wang wrote:
> Hi Jan, Wanlong,
> 
> On 07/21/2014 05:09 PM, Wanlong Gao wrote:
>> On 07/21/2014 05:04 PM, Jan Stancek wrote:
>>>
>>> looks good to me.
>>>
>>>>> I have run this test case in RHEL7.0GA, Fedora19, v3.11-7758-g232d2d6 and 3.16.0-rc4+.
>>>>> RHEL7.0GA has this kernel bug, so this test case fails.
>>> I can confirm this, with note that I've seen it happen only on systems with 2+ CPUs.
>>
>> If this note is truth, we should judge the nr_cpus in this case to make sure it always
>> gives the right result.
> 
> Thanks Jan for pointing this.
> I'll have a look at these three related kernel patches again. If needed, I'll sent a 
> v2 version including the judgment about number of cpus, thanks!

I'm not that familiar with kernel VFS layer code and spent time to look into the code, sorry for the delay.

Now I think it is impossible to reproduce this bug in only one cpu machine, below is the possible reason,
please check it(The kernel source code I used is RHEL7.0GA).
First let me explain why this bug is triggered. Look at the getcwd(2)'s implementation,

SYSCALL_DEFINE2(getcwd, ...)
----prepend_path(...)

In prepend_path(), it will use a kernel sequence lock named rename_lock to check whether the corresponding
operation in prepend_path() is valid. If it's valid, everything is OK. But if it's not(for example, some
other kernel code flow call a write_seqlock() on the rename_lock), then prepend_path() need to restart the entire 
operation, but kernel commit 232d2d6 patch forgot to reinitialize dentry/vfsmount/mnt, in this time, the dentry
is already the root dentry, so gewcwd(2) will return a "/", bug is triggered.

But when we only have one cpu, when we are in  prepend_path(),  If I understand
right, I think there is no operation in prepend_path() that will cause the current kernel code flow to sleep or give up
the cpu voluntarily and kernel is preempt disabled, only when the getcwd(2) operation completes, can a
process switch happen when returning to user space, that says we can ensure there is no other kernel code flow
have a chance to  operate rename_lock in kernel when a getcwd(2) is in progress.

So I'll send a V2 patch including the judgment about number of cpus. If system only has one cpu, it will
print a TCONF, thanks!


Regards,
Xiaoguang Wang
> 
> Regards,
> Xiaoguang Wang
>>
>> Thanks,
>> Wanlong Gao
>>  
>>
>> .
>>
> 
> 
> ------------------------------------------------------------------------------
> Want fast and easy access to all the code in your enterprise? Index and
> search up to 200,000 lines of code with a free copy of Black Duck
> Code Sight - the same software that powers the world's largest code
> search on Ohloh, the Black Duck Open Hub! Try it now.
> http://p.sf.net/sfu/bds
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2014-07-27  8:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-15 10:13 [LTP] [PATCH 1/2] lib: add SAFE_RENAME() Xiaoguang Wang
2014-07-15 10:13 ` [LTP] [PATCH 2/2] syscalls/getcwd04.c: regression test for getcwd(2) Xiaoguang Wang
2014-07-15 10:21   ` Xiaoguang Wang
2014-07-21  9:04   ` Jan Stancek
2014-07-21  9:09     ` Wanlong Gao
2014-07-21  9:23       ` Xiaoguang Wang
2014-07-27  8:42         ` Xiaoguang Wang [this message]
2014-07-27  9:00           ` [LTP] [PATCH v2 1/2] lib: add SAFE_RENAME() Xiaoguang Wang
2014-07-27  9:00             ` [LTP] [PATCH v2 2/2] syscalls/getcwd04.c: regression test for getcwd(2) Xiaoguang Wang
2014-08-01  1:51             ` [LTP] [PATCH v2 1/2] lib: add SAFE_RENAME() Wanlong Gao
2014-07-21  9:33       ` [LTP] [PATCH 2/2] syscalls/getcwd04.c: regression test for getcwd(2) Jan Stancek
2014-07-21  9:40         ` Wanlong Gao
2014-07-21  9:58           ` Jan Stancek

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=53D4BB5B.5030701@cn.fujitsu.com \
    --to=wangxg.fnst@cn.fujitsu.com \
    --cc=Artem@edo.cn.fujitsu.com \
    --cc=asavkov@redhat.com \
    --cc=gaowanlong@cn.fujitsu.com \
    --cc=ltp-list@lists.sourceforge.net \
    /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