linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs: fix: second lock in function d_prune_aliases().
@ 2020-12-30  7:01 YANG LI
  2020-12-30  8:27 ` Li, Hao
  2020-12-30 20:04 ` Al Viro
  0 siblings, 2 replies; 4+ messages in thread
From: YANG LI @ 2020-12-30  7:01 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, linux-kernel, YANG LI

Goto statement jumping will cause lock to be executed again without
executing unlock, placing the lock statement in front of goto
label to fix this problem.

Signed-off-by: YANG LI <abaci-bugfix@linux.alibaba.com>
Reported-by: Abaci <abaci@linux.alibaba.com>
---
 fs/dcache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 97e81a8..bf38446 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1050,6 +1050,6 @@ void d_prune_aliases(struct inode *inode)
 {
 	struct dentry *dentry;
-restart:
 	spin_lock(&inode->i_lock);
+restart:
 	hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
 		spin_lock(&dentry->d_lock);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs: fix: second lock in function d_prune_aliases().
  2020-12-30  7:01 [PATCH] fs: fix: second lock in function d_prune_aliases() YANG LI
@ 2020-12-30  8:27 ` Li, Hao
  2020-12-30 20:04 ` Al Viro
  1 sibling, 0 replies; 4+ messages in thread
From: Li, Hao @ 2020-12-30  8:27 UTC (permalink / raw)
  To: YANG LI, viro; +Cc: linux-fsdevel, linux-kernel

On 2020/12/30 15:01, YANG LI wrote:
> Goto statement jumping will cause lock to be executed again without
> executing unlock, placing the lock statement in front of goto
> label to fix this problem.
>
> Signed-off-by: YANG LI <abaci-bugfix@linux.alibaba.com>
> Reported-by: Abaci <abaci@linux.alibaba.com>
> ---
>  fs/dcache.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/dcache.c b/fs/dcache.c
> index 97e81a8..bf38446 100644
> --- a/fs/dcache.c
> +++ b/fs/dcache.c
> @@ -1050,6 +1050,6 @@ void d_prune_aliases(struct inode *inode)
>  {
>      struct dentry *dentry;
> -restart:
>      spin_lock(&inode->i_lock);

This inode lock should be released at __dentry_kill->dentry_unlink_inode.

Regards,
Hao Lee

>
> +restart:
>      hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
>          spin_lock(&dentry->d_lock);




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs: fix: second lock in function d_prune_aliases().
  2020-12-30  7:01 [PATCH] fs: fix: second lock in function d_prune_aliases() YANG LI
  2020-12-30  8:27 ` Li, Hao
@ 2020-12-30 20:04 ` Al Viro
  2020-12-30 21:36   ` Matthew Wilcox
  1 sibling, 1 reply; 4+ messages in thread
From: Al Viro @ 2020-12-30 20:04 UTC (permalink / raw)
  To: YANG LI; +Cc: linux-fsdevel, linux-kernel

On Wed, Dec 30, 2020 at 03:01:25PM +0800, YANG LI wrote:
> Goto statement jumping will cause lock to be executed again without
> executing unlock, placing the lock statement in front of goto
> label to fix this problem.
> 
> Signed-off-by: YANG LI <abaci-bugfix@linux.alibaba.com>
> Reported-by: Abaci <abaci@linux.alibaba.com>

I am sorry, but have you even attempted to trigger that codepath?
Just to test your patch...

FWIW, the patch is completely broken.  Obviously so, since you
have dput() done just before goto restart and dput() in very
much capable of blocking.  It should never be called with spinlocks
held.  And if you look at __dentry_kill() (well, dentry_unlink_inode()
called by __dentry_kill()), you will see that it bloody well *DOES*
drop inode->i_lock.

NAK.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs: fix: second lock in function d_prune_aliases().
  2020-12-30 20:04 ` Al Viro
@ 2020-12-30 21:36   ` Matthew Wilcox
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2020-12-30 21:36 UTC (permalink / raw)
  To: Al Viro; +Cc: YANG LI, linux-fsdevel, linux-kernel

On Wed, Dec 30, 2020 at 08:04:49PM +0000, Al Viro wrote:
> On Wed, Dec 30, 2020 at 03:01:25PM +0800, YANG LI wrote:
> > Goto statement jumping will cause lock to be executed again without
> > executing unlock, placing the lock statement in front of goto
> > label to fix this problem.
> > 
> > Signed-off-by: YANG LI <abaci-bugfix@linux.alibaba.com>
> > Reported-by: Abaci <abaci@linux.alibaba.com>
> 
> I am sorry, but have you even attempted to trigger that codepath?
> Just to test your patch...
> 
> FWIW, the patch is completely broken.  Obviously so, since you
> have dput() done just before goto restart and dput() in very
> much capable of blocking.  It should never be called with spinlocks
> held.  And if you look at __dentry_kill() (well, dentry_unlink_inode()
> called by __dentry_kill()), you will see that it bloody well *DOES*
> drop inode->i_lock.

Not only that, but the function is even _annotated_ to that effect.
So this 'abaci' tool you have isn't even capable of the bare minimum.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-30 21:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-30  7:01 [PATCH] fs: fix: second lock in function d_prune_aliases() YANG LI
2020-12-30  8:27 ` Li, Hao
2020-12-30 20:04 ` Al Viro
2020-12-30 21:36   ` Matthew Wilcox

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).