]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
fix handling of nd->depth on LOOKUP_CACHED failures in try_to_unlazy*
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 15 Feb 2021 17:03:23 +0000 (12:03 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Jan 2023 10:39:17 +0000 (11:39 +0100)
commit146fe79fff13fea7b5f3a9e913689e07fd4e6432
tree545681ceca808c14abb63bc141434d13328e335f
parentc1fe7bd3e1aa85865396b464b31f28b094a4353c
fix handling of nd->depth on LOOKUP_CACHED failures in try_to_unlazy*

[ Upstream commit eacd9aa8cedeb412842c7b339adbaa0477fdd5ad ]

After switching to non-RCU mode, we want nd->depth to match the number
of entries in nd->stack[] that need eventual path_put().
legitimize_links() takes care of that on failures; unfortunately,
failure exits added for LOOKUP_CACHED do not.

We could add the logics for that into those failure exits, both in
try_to_unlazy() and in try_to_unlazy_next(), but since both checks
are immediately followed by legitimize_links() and there's no calls
of legitimize_links() other than those two...  It's easier to
move the check (and required handling of nd->depth on failure) into
legitimize_links() itself.

[caught by Jens: ... and since we are zeroing ->depth here, we need
to do drop_links() first]

Fixes: 6c6ec2b0a3e0 "fs: add support for LOOKUP_CACHED"
Tested-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/namei.c