* FAILED: patch "[PATCH] ovl: fix recursive oi->lock in ovl_link()" failed to apply to 4.18-stable tree
@ 2018-11-15 0:06 gregkh
2018-11-15 3:08 ` Amir Goldstein
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2018-11-15 0:06 UTC (permalink / raw)
To: amir73il, mszeredi, stable; +Cc: stable
The patch below does not apply to the 4.18-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
>From 6cd078702f2f33cb6b19a682de3e9184112f1a46 Mon Sep 17 00:00:00 2001
From: Amir Goldstein <amir73il@gmail.com>
Date: Thu, 18 Oct 2018 09:45:49 +0300
Subject: [PATCH] ovl: fix recursive oi->lock in ovl_link()
linking a non-copied-up file into a non-copied-up parent results in a
nested call to mutex_lock_interruptible(&oi->lock). Fix this by copying up
target parent before ovl_nlink_start(), same as done in ovl_rename().
~/unionmount-testsuite$ ./run --ov -s
~/unionmount-testsuite$ ln /mnt/a/foo100 /mnt/a/dir100/
WARNING: possible recursive locking detected
--------------------------------------------
ln/1545 is trying to acquire lock:
00000000bcce7c4c (&ovl_i_lock_key[depth]){+.+.}, at:
ovl_copy_up_start+0x28/0x7d
but task is already holding lock:
0000000026d73d5b (&ovl_i_lock_key[depth]){+.+.}, at:
ovl_nlink_start+0x3c/0xc1
[SzM: this seems to be a false positive, but doing the copy-up first is
harmless and removes the lockdep splat]
Reported-by: syzbot+3ef5c0d1a5cb0b21e6be@syzkaller.appspotmail.com
Fixes: 5f8415d6b87e ("ovl: persistent overlay inode nlink for...")
Cc: <stable@vger.kernel.org> # v4.13
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 276914ae3c60..e1a55ecb7aba 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -663,6 +663,10 @@ static int ovl_link(struct dentry *old, struct inode *newdir,
if (err)
goto out_drop_write;
+ err = ovl_copy_up(new->d_parent);
+ if (err)
+ goto out_drop_write;
+
if (ovl_is_metacopy_dentry(old)) {
err = ovl_set_redirect(old, false);
if (err)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: FAILED: patch "[PATCH] ovl: fix recursive oi->lock in ovl_link()" failed to apply to 4.18-stable tree
2018-11-15 0:06 FAILED: patch "[PATCH] ovl: fix recursive oi->lock in ovl_link()" failed to apply to 4.18-stable tree gregkh
@ 2018-11-15 3:08 ` Amir Goldstein
2018-11-15 5:17 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Amir Goldstein @ 2018-11-15 3:08 UTC (permalink / raw)
To: Greg KH; +Cc: Miklos Szeredi, stable
[-- Attachment #1: Type: text/plain, Size: 369 bytes --]
On Thu, Nov 15, 2018 at 2:06 AM <gregkh@linuxfoundation.org> wrote:
>
>
> The patch below does not apply to the 4.18-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
>
Attached. Should apply to v4.14 as well.
Thanks,
Amir.
[-- Attachment #2: 0001-stable-ovl-fix-recursive-oi-lock-in-ovl_link.patch --]
[-- Type: text/x-patch, Size: 1872 bytes --]
From 23a290ac1335544c2e74562f21feb5f838e192db Mon Sep 17 00:00:00 2001
From: Amir Goldstein <amir73il@gmail.com>
Date: Thu, 18 Oct 2018 09:45:49 +0300
Subject: [PATCH] ovl: fix recursive oi->lock in ovl_link()
commit 6cd078702f2f33cb6b19a682de3e9184112f1a46 upstream.
linking a non-copied-up file into a non-copied-up parent results in a
nested call to mutex_lock_interruptible(&oi->lock). Fix this by copying up
target parent before ovl_nlink_start(), same as done in ovl_rename().
~/unionmount-testsuite$ ./run --ov -s
~/unionmount-testsuite$ ln /mnt/a/foo100 /mnt/a/dir100/
WARNING: possible recursive locking detected
--------------------------------------------
ln/1545 is trying to acquire lock:
00000000bcce7c4c (&ovl_i_lock_key[depth]){+.+.}, at:
ovl_copy_up_start+0x28/0x7d
but task is already holding lock:
0000000026d73d5b (&ovl_i_lock_key[depth]){+.+.}, at:
ovl_nlink_start+0x3c/0xc1
[SzM: this seems to be a false positive, but doing the copy-up first is
harmless and removes the lockdep splat]
Reported-by: syzbot+3ef5c0d1a5cb0b21e6be@syzkaller.appspotmail.com
Fixes: 5f8415d6b87e ("ovl: persistent overlay inode nlink for...")
Cc: <stable@vger.kernel.org> # v4.13
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
[amir: backport to v4.18]
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/overlayfs/dir.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index d00e66b2a047..36847411c118 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -661,6 +661,11 @@ static int ovl_link(struct dentry *old, struct inode *newdir,
if (err)
goto out_drop_write;
+ err = ovl_copy_up(new->d_parent);
+ if (err)
+ goto out_drop_write;
+
+
err = ovl_nlink_start(old, &locked);
if (err)
goto out_drop_write;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: FAILED: patch "[PATCH] ovl: fix recursive oi->lock in ovl_link()" failed to apply to 4.18-stable tree
2018-11-15 3:08 ` Amir Goldstein
@ 2018-11-15 5:17 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2018-11-15 5:17 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Miklos Szeredi, stable
On Thu, Nov 15, 2018 at 05:08:38AM +0200, Amir Goldstein wrote:
> On Thu, Nov 15, 2018 at 2:06 AM <gregkh@linuxfoundation.org> wrote:
> >
> >
> > The patch below does not apply to the 4.18-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
> >
>
> Attached. Should apply to v4.14 as well.
Now applied, thanks!
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-15 15:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-15 0:06 FAILED: patch "[PATCH] ovl: fix recursive oi->lock in ovl_link()" failed to apply to 4.18-stable tree gregkh
2018-11-15 3:08 ` Amir Goldstein
2018-11-15 5:17 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox