]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ovl: make sure that ovl_create_real() returns a hashed dentry
authorAmir Goldstein <amir73il@gmail.com>
Wed, 27 Aug 2025 17:55:26 +0000 (19:55 +0200)
committerAmir Goldstein <amir73il@gmail.com>
Tue, 23 Sep 2025 10:29:36 +0000 (12:29 +0200)
commitad1423922781e6552f18d055a5742b1cff018cdc
tree0ed9ca3e7c8b6d4e8da19a6f9d7690464631713c
parent16754d61dc69cb4550225a967a2639809226de42
ovl: make sure that ovl_create_real() returns a hashed dentry

e8bd877fb76bb9f3 ("ovl: fix possible double unlink") added a sanity
check of !d_unhashed(child) to try to verify that child dentry was not
unlinked while parent dir was unlocked.

This "was not unlink" check has a false positive result in the case of
casefolded parent dir, because in that case, ovl_create_temp() returns
an unhashed dentry after ovl_create_real() gets an unhashed dentry from
ovl_lookup_upper() and makes it positive.

To avoid returning unhashed dentry from ovl_create_temp(), let
ovl_create_real() lookup again after making the newdentry positive,
so it always returns a hashed positive dentry (or an error).

This fixes the error in ovl_parent_lock() in ovl_check_rename_whiteout()
after ovl_create_temp() and allows mount of overlayfs with casefolding
enabled layers.

Reported-by: André Almeida <andrealmeid@igalia.com>
Closes: https://lore.kernel.org/r/18704e8c-c734-43f3-bc7c-b8be345e1bf5@igalia.com/
Suggested-by: Neil Brown <neil@brown.name>
Reviewed-by: Neil Brown <neil@brown.name>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
fs/overlayfs/dir.c