Btrfs: fix crash on fsync when using overlayfs v4
Orabug:
25512309
If the lower or upper directory of an overlayfs mount belongs to a btrfs
file system and we fsync the file through the overlayfs' merged directory
we ended up accessing an inode that didn't belong to btrfs as if it were a
btrfs inode at btrfs_sync_file() resulting in a crash.
This fixes the problem by getting the inode from file_inode() and getting
the real dentry for recursively checking up parent directory.
Note that the upstream fix is commit
de17e793b104d690e1d007dfc5cb6b4f649598ca ("btrfs: fix crash/invalid memory
access on fsync when using overlayfs").
But we are not able to use it since it uses a new helper file_dentry() and
the commit that adds the helper would cause KABI breakage.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>