* [RFC PATCH next] fix unpaired rcu lock in prepend_path()
@ 2013-11-13 7:21 Li Zhong
2013-11-13 12:28 ` Al Viro
0 siblings, 1 reply; 3+ messages in thread
From: Li Zhong @ 2013-11-13 7:21 UTC (permalink / raw)
To: linux-next list; +Cc: Al Viro
The patch tries to fix following complaint(next-1112) caused by unpaired
rcu_read_lock/unlock in function prepend_path():
[ 19.611017] =====================================
[ 19.612052] [ BUG: bad unlock balance detected! ]
[ 19.612052] 3.12.0-next-20131112 #1 Tainted: G W
[ 19.612052] -------------------------------------
[ 19.612052] systemd/1 is trying to release lock (rcu_read_lock) at:
[ 19.612052] [<ffffffff811cd22e>] d_path+0x17e/0x270
[ 19.612052] but there are no more locks to release!
[ 19.612052]
other info that might help us debug this:
[ 19.612052] 2 locks held by systemd/1:
[ 19.612052] #0: (&p->lock){+.+.+.}, at: [<ffffffff811dd27d>] seq_read+0x3d/0x3c0
[ 19.612052] #1: (&mm->mmap_sem){++++++}, at: [<ffffffff81228037>] m_start+0xa7/0x190
[ 19.612052]
stack backtrace:
[ 19.612052] CPU: 0 PID: 1 Comm: systemd Tainted: G W 3.12.0-next-20131112 #1
[ 19.612052] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007
[ 19.612052] ffffffff811cd22e ffff88011b07dbf8 ffffffff8154a067 0000000000000001
[ 19.623937] ffff880119cc0000 ffff88011b07dc28 ffffffff810a91ee ffffffff811ccace
[ 19.623937] ffffffff81a38a80 ffffffff811cd22e 00000000ffffffff ffff88011b07dcc8
[ 19.623937] Call Trace:
[ 19.623937] [<ffffffff811cd22e>] ? d_path+0x17e/0x270
[ 19.629627] [<ffffffff8154a067>] dump_stack+0x4f/0x7c
[ 19.629627] [<ffffffff810a91ee>] print_unlock_imbalance_bug+0xfe/0x110
[ 19.629627] [<ffffffff811ccace>] ? prepend_path+0x25e/0x4a0
[ 19.629627] [<ffffffff811cd22e>] ? d_path+0x17e/0x270
[ 19.629627] [<ffffffff810ad70e>] lock_release_non_nested+0x1ee/0x310
[ 19.629627] [<ffffffff815519c5>] ? _raw_spin_unlock+0x35/0x60
[ 19.629627] [<ffffffff811ccace>] ? prepend_path+0x25e/0x4a0
[ 19.629627] [<ffffffff811cd219>] ? d_path+0x169/0x270
[ 19.629627] [<ffffffff811cd22e>] ? d_path+0x17e/0x270
[ 19.629627] [<ffffffff810ad8f4>] lock_release+0xc4/0x340
[ 19.629627] [<ffffffff811cd246>] d_path+0x196/0x270
[ 19.629627] [<ffffffff811dd651>] ? seq_path+0x51/0xd0
[ 19.629627] [<ffffffff811dd651>] seq_path+0x51/0xd0
[ 19.629627] [<ffffffff81228276>] show_map_vma+0x156/0x290
[ 19.629627] [<ffffffff81228037>] ? m_start+0xa7/0x190
[ 19.629627] [<ffffffff812283df>] show_map+0x2f/0x90
[ 19.629627] [<ffffffff81228473>] show_pid_map+0x13/0x20
[ 19.629627] [<ffffffff811dd486>] seq_read+0x246/0x3c0
[ 19.629627] [<ffffffff811b4030>] vfs_read+0xb0/0x180
[ 19.629627] [<ffffffff811b42a2>] SyS_read+0x52/0xa0
[ 19.629627] [<ffffffff8155a262>] tracesys+0xd0/0xd5
[ 19.645347] ------------[ cut here ]------------
Signed-off-by: Li Zhong <zhong@linux.vnet.ibm.com>
--- fs/dcache.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/dcache.c b/fs/dcache.c
index ef2f32f..555a371 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2910,6 +2910,7 @@ static int prepend_path(const struct path *path,
restart_mnt:
read_seqbegin_or_lock(&mount_lock, &m_seq);
seq = 0;
+ rcu_read_lock();
restart:
bptr = *buffer;
blen = *buflen;
@@ -2957,6 +2958,9 @@ restart:
goto restart;
}
done_seqretry(&rename_lock, seq);
+
+ if (!(m_seq & 1))
+ rcu_read_unlock();
if (need_seqretry(&mount_lock, m_seq)) {
m_seq = 1;
goto restart_mnt;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC PATCH next] fix unpaired rcu lock in prepend_path()
2013-11-13 7:21 [RFC PATCH next] fix unpaired rcu lock in prepend_path() Li Zhong
@ 2013-11-13 12:28 ` Al Viro
2013-11-14 2:17 ` Li Zhong
0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2013-11-13 12:28 UTC (permalink / raw)
To: Li Zhong; +Cc: linux-next list
On Wed, Nov 13, 2013 at 03:21:51PM +0800, Li Zhong wrote:
> The patch tries to fix following complaint(next-1112) caused by unpaired
> rcu_read_lock/unlock in function prepend_path():
Frankly, I wonder if it wouldn't be better to shift rcu_read_unlock()
past the second done_seqretry() in there...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH next] fix unpaired rcu lock in prepend_path()
2013-11-13 12:28 ` Al Viro
@ 2013-11-14 2:17 ` Li Zhong
0 siblings, 0 replies; 3+ messages in thread
From: Li Zhong @ 2013-11-14 2:17 UTC (permalink / raw)
To: Al Viro; +Cc: linux-next list
On Wed, 2013-11-13 at 12:28 +0000, Al Viro wrote:
> On Wed, Nov 13, 2013 at 03:21:51PM +0800, Li Zhong wrote:
> > The patch tries to fix following complaint(next-1112) caused by unpaired
> > rcu_read_lock/unlock in function prepend_path():
>
> Frankly, I wonder if it wouldn't be better to shift rcu_read_unlock()
> past the second done_seqretry() in there...
Do you mean we have rcu_read_lock/unlock outside of the goto loops?
It seems to me it would cause the two locks(mount,rename) potentially
acquired inside rcu read lock. Or did I misunderstand something here?
Thanks,
Zhong
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-11-14 2:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-13 7:21 [RFC PATCH next] fix unpaired rcu lock in prepend_path() Li Zhong
2013-11-13 12:28 ` Al Viro
2013-11-14 2:17 ` Li Zhong
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).