Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ovl: use is_subdir() for testing if one thing is a subdir of another

Rather than using lock_rename(), use the more obvious is_subdir() for
ensuring that neither upper nor workdir contain the other.
Also be explicit in the comment that the two directories cannot be the
same.

As this is a point-it-time sanity check and does not provide any
on-going guarantees, the removal of locking does not introduce any
interesting races.

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neil@brown.name>
Link: https://patch.msgid.link/20260224222542.3458677-14-neilb@ownmail.net
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

NeilBrown and committed by
Christian Brauner
56c8fd73 83482786

+5 -10
+5 -10
fs/overlayfs/super.c
··· 451 451 return 0; 452 452 } 453 453 454 - /* Workdir should not be subdir of upperdir and vice versa */ 454 + /* 455 + * Workdir should not be subdir of upperdir and vice versa, and 456 + * they should not be the same. 457 + */ 455 458 static bool ovl_workdir_ok(struct dentry *workdir, struct dentry *upperdir) 456 459 { 457 - bool ok = false; 458 - 459 - if (workdir != upperdir) { 460 - struct dentry *trap = lock_rename(workdir, upperdir); 461 - if (!IS_ERR(trap)) 462 - unlock_rename(workdir, upperdir); 463 - ok = (trap == NULL); 464 - } 465 - return ok; 460 + return !is_subdir(workdir, upperdir) && !is_subdir(upperdir, workdir); 466 461 } 467 462 468 463 static int ovl_setup_trap(struct super_block *sb, struct dentry *dir,