Subject: linux-next: manual merge of the vfs tree with the overlayfs-fixes tree

From: Stephen Rothwell <[email-masked]>
Date: Wed, 20 Dec 2023 10:56:05 +1100

Hi all,

Today's linux-next merge of the vfs tree got a conflict in:

  fs/overlayfs/copy_up.c

between commit:

  413ba91089c7 ("ovl: fix dentry reference leak after changes to underlying layers")

from the overlayfs-fixes tree and commit:

  a8b0026847b8 ("rename(): avoid a deadlock in the case of parents having no common ancestor")

from the vfs tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc fs/overlayfs/copy_up.c
index 696478f09cc1,e44dc5f66161..000000000000
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@@ -779,13 -757,14 +779,15 @@@ static int ovl_copy_up_workdir(struct o
  	 * lock ordering with sb_writers, which shouldn't be held when calling
  	 * ovl_copy_up_data(), so lock workdir and destdir and make sure that
  	 * temp wasn't moved before copy up completion or cleanup.
 -	 * If temp was moved, abort without the cleanup.
  	 */
  	ovl_start_write(c->dentry);
- 	if (lock_rename(c->workdir, c->destdir) != NULL ||
- 	    temp->d_parent != c->workdir) {
+ 	trap = lock_rename(c->workdir, c->destdir);
+ 	if (trap || temp->d_parent != c->workdir) {
 +		/* temp or workdir moved underneath us? abort without cleanup */
 +		dput(temp);
  		err = -EIO;
+ 		if (IS_ERR(trap))
+ 			goto out;
  		goto unlock;
  	} else if (err) {
  		goto cleanup;