]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
pstore: inode: Only d_invalidate() is needed
authorKees Cook <keescook@chromium.org>
Thu, 22 Feb 2024 17:48:46 +0000 (09:48 -0800)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:19:34 +0000 (18:19 -0400)
commit4cdf9006fc095af71da80e9b5f48a32e991b9ed3
tree53a8414aa58a8c351359c6070c229cd42139fdd2
parent952d8a8093519acd181b69ea5783b9dd86d1879b
pstore: inode: Only d_invalidate() is needed

[ Upstream commit a43e0fc5e9134a46515de2f2f8d4100b74e50de3 ]

Unloading a modular pstore backend with records in pstorefs would
trigger the dput() double-drop warning:

  WARNING: CPU: 0 PID: 2569 at fs/dcache.c:762 dput.part.0+0x3f3/0x410

Using the combo of d_drop()/dput() (as mentioned in
Documentation/filesystems/vfs.rst) isn't the right approach here, and
leads to the reference counting problem seen above. Use d_invalidate()
and update the code to not bother checking for error codes that can
never happen.

Suggested-by: Alexander Viro <viro@zeniv.linux.org.uk>
Fixes: 609e28bb139e ("pstore: Remove filesystem records when backend is unregistered")
Signed-off-by: Kees Cook <keescook@chromium.org>
fs/pstore/inode.c