This is a note to let you know that I've just added the patch titled 9p: fix fid refcount leak in v9fs_vfs_get_link to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: 9p-fix-fid-refcount-leak-in-v9fs_vfs_get_link.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From e5690f263208c5abce7451370b7786eb25b405eb Mon Sep 17 00:00:00 2001 From: Dominique Martinet <asmadeus@xxxxxxxxxxxxx> Date: Sun, 12 Jun 2022 17:14:55 +0900 Subject: 9p: fix fid refcount leak in v9fs_vfs_get_link From: Dominique Martinet <asmadeus@xxxxxxxxxxxxx> commit e5690f263208c5abce7451370b7786eb25b405eb upstream. we check for protocol version later than required, after a fid has been obtained. Just move the version check earlier. Link: https://lkml.kernel.org/r/20220612085330.1451496-3-asmadeus@xxxxxxxxxxxxx Fixes: 6636b6dcc3db ("9p: add refcount to p9_fid struct") Cc: stable@xxxxxxxxxxxxxxx Reviewed-by: Tyler Hicks <tyhicks@xxxxxxxxxxxxxxxxxxx> Reviewed-by: Christian Schoenebeck <linux_oss@xxxxxxxxxxxxx> Signed-off-by: Dominique Martinet <asmadeus@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/9p/vfs_inode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -1228,15 +1228,15 @@ static const char *v9fs_vfs_get_link(str return ERR_PTR(-ECHILD); v9ses = v9fs_dentry2v9ses(dentry); - fid = v9fs_fid_lookup(dentry); + if (!v9fs_proto_dotu(v9ses)) + return ERR_PTR(-EBADF); + p9_debug(P9_DEBUG_VFS, "%pd\n", dentry); + fid = v9fs_fid_lookup(dentry); if (IS_ERR(fid)) return ERR_CAST(fid); - if (!v9fs_proto_dotu(v9ses)) - return ERR_PTR(-EBADF); - st = p9_client_stat(fid); p9_client_clunk(fid); if (IS_ERR(st)) Patches currently in stable-queue which might be from asmadeus@xxxxxxxxxxxxx are queue-5.15/9p-fix-fid-refcount-leak-in-v9fs_vfs_atomic_open_dotl.patch queue-5.15/9p-fix-fid-refcount-leak-in-v9fs_vfs_get_link.patch queue-5.15/9p-fix-refcounting-during-full-path-walks-for-fid-lookups.patch