devtmpfs: don't use vfs_getattr_nosec to query i_mode
authorChristoph Hellwig <hch@lst.de>
Wed, 23 Apr 2025 04:59:41 +0000 (06:59 +0200)
committerChristian Brauner <brauner@kernel.org>
Fri, 25 Apr 2025 10:11:45 +0000 (12:11 +0200)
commite079d7c4db5cba1e8a315dc93030dfb6c7b49459
treedd9671426342cc89a3b90ce31bbb584b8796dad4
parent0d039eac6e5950f9d1ecc9e410c2fd1feaeab3b6
devtmpfs: don't use vfs_getattr_nosec to query i_mode

The recent move of the bdev_statx call to the low-level vfs_getattr_nosec
helper caused it being used by devtmpfs, which leads to deadlocks in
md teardown due to the block device lookup and put interfering with the
unusual lifetime rules in md.

But as handle_remove only works on inodes created and owned by devtmpfs
itself there is no need to use vfs_getattr_nosec vs simply reading the
mode from the inode directly.  Switch to that to avoid the bdev lookup
or any other unintentional side effect.

Reported-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Reported-by: Xiao Ni <xni@redhat.com>
Fixes: 777d0961ff95 ("fs: move the bdex_statx call to vfs_getattr_nosec")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/20250423045941.1667425-1-hch@lst.de
Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Tested-by: Xiao Ni <xni@redhat.com>
Tested-by: Ayush Jain <Ayush.jain3@amd.com>
Tested-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
drivers/base/devtmpfs.c