ovl: fix use inode directly in rcu-walk mode
authorChen Zhongjin <chenzhongjin@huawei.com>
Mon, 28 Nov 2022 10:33:05 +0000 (11:33 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:33:11 +0000 (13:33 +0100)
commitac551b1f500b99ab05fb7ade8ba61fd61f3cfbe7
tree71bc2cb5d6d45b4ec788a6cf8816e29c6c05e660
parenta609bfc1e644a8467cb31945ed1488374ebdc013
ovl: fix use inode directly in rcu-walk mode

commit 672e4268b2863d7e4978dfed29552b31c2f9bd4e upstream.

ovl_dentry_revalidate_common() can be called in rcu-walk mode.  As document
said, "in rcu-walk mode, d_parent and d_inode should not be used without
care".

Check inode here to protect access under rcu-walk mode.

Fixes: bccece1ead36 ("ovl: allow remote upper")
Reported-and-tested-by: syzbot+a4055c78774bbf3498bb@syzkaller.appspotmail.com
Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
Cc: <stable@vger.kernel.org> # v5.7
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/overlayfs/super.c