[lkml]   [2018]   [Nov]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 4.18 049/171] ovl: fix recursive oi->lock in ovl_link()
4.18-stable review patch.  If anyone has any objections, please let me know.


From: Amir Goldstein <>

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:
but task is already holding lock:
0000000026d73d5b (&ovl_i_lock_key[depth]){+.+.}, at:

[SzM: this seems to be a false positive, but doing the copy-up first is
harmless and removes the lockdep splat]

Fixes: 5f8415d6b87e ("ovl: persistent overlay inode nlink for...")
Cc: <> # v4.13
Signed-off-by: Amir Goldstein <>
Signed-off-by: Miklos Szeredi <>
[amir: backport to v4.18]
Signed-off-by: Amir Goldstein <>
Signed-off-by: Greg Kroah-Hartman <>

fs/overlayfs/dir.c | 5 +++++
1 file changed, 5 insertions(+)

--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -665,6 +665,11 @@ static int ovl_link(struct dentry *old,
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;

 \ /
  Last update: 2018-11-19 18:53    [W:0.423 / U:4.536 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site