[PATCH OLK-6.6 0/2] CVE-2025-40328
CVE-2025-40328 fixes Henrique Carvalho (2): smb: client: fix potential UAF in smb2_close_cached_fid() smb: client: fix incomplete backport in cfids_invalidation_worker() fs/smb/client/cached_dir.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) -- 2.34.3
From: Henrique Carvalho <henrique.carvalho@suse.com> stable inclusion from stable-v6.6.117 commit cb52d9c86d70298de0ab7c7953653898cbc0efd6 category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/12599 CVE: CVE-2025-40328 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=... -------------------------------- commit 734e99623c5b65bf2c03e35978a0b980ebc3c2f8 upstream. find_or_create_cached_dir() could grab a new reference after kref_put() had seen the refcount drop to zero but before cfid_list_lock is acquired in smb2_close_cached_fid(), leading to use-after-free. Switch to kref_put_lock() so cfid_release() is called with cfid_list_lock held, closing that gap. Fixes: ebe98f1447bb ("cifs: enable caching of directories for which a lease is held") Cc: stable@vger.kernel.org Reported-by: Jay Shin <jaeshin@redhat.com> Reviewed-by: Paulo Alcantara (Red Hat) <pc@manguebit.org> Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Wang Zhaolong <wangzhaolong@huaweicloud.com> --- fs/smb/client/cached_dir.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c index 9c0ef4195b58..6b42d7c2ef4a 100644 --- a/fs/smb/client/cached_dir.c +++ b/fs/smb/client/cached_dir.c @@ -366,15 +366,15 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, * We are guaranteed to have two references at this * point. One for the caller and one for a potential * lease. Release one here, and the second below. */ cfid->has_lease = false; - kref_put(&cfid->refcount, smb2_close_cached_fid); + close_cached_dir(cfid); } spin_unlock(&cfids->cfid_list_lock); - kref_put(&cfid->refcount, smb2_close_cached_fid); + close_cached_dir(cfid); } else { *ret_cfid = cfid; atomic_inc(&tcon->num_remote_opens); } kfree(utf16_path); @@ -410,16 +410,18 @@ int open_cached_dir_by_dentry(struct cifs_tcon *tcon, return -ENOENT; } static void smb2_close_cached_fid(struct kref *ref) +__releases(&cfid->cfids->cfid_list_lock) { struct cached_fid *cfid = container_of(ref, struct cached_fid, refcount); int rc; - spin_lock(&cfid->cfids->cfid_list_lock); + lockdep_assert_held(&cfid->cfids->cfid_list_lock); + if (cfid->on_list) { list_del(&cfid->entry); cfid->on_list = false; cfid->cfids->num_entries--; } @@ -450,20 +452,20 @@ void drop_cached_dir_by_name(const unsigned int xid, struct cifs_tcon *tcon, return; } spin_lock(&cfid->cfids->cfid_list_lock); if (cfid->has_lease) { cfid->has_lease = false; - kref_put(&cfid->refcount, smb2_close_cached_fid); + close_cached_dir(cfid); } spin_unlock(&cfid->cfids->cfid_list_lock); close_cached_dir(cfid); } void close_cached_dir(struct cached_fid *cfid) { - kref_put(&cfid->refcount, smb2_close_cached_fid); + kref_put_lock(&cfid->refcount, smb2_close_cached_fid, &cfid->cfids->cfid_list_lock); } /* * Called from cifs_kill_sb when we unmount a share */ @@ -560,11 +562,11 @@ cached_dir_offload_close(struct work_struct *work) struct cached_fid, close_work); struct cifs_tcon *tcon = cfid->tcon; WARN_ON(cfid->on_list); - kref_put(&cfid->refcount, smb2_close_cached_fid); + close_cached_dir(cfid); cifs_put_tcon(tcon, netfs_trace_tcon_ref_put_cached_close); } /* * Release the cached directory's dentry, and then queue work to drop cached @@ -737,11 +739,11 @@ static void cfids_laundromat_worker(struct work_struct *work) } else /* * Drop the ref-count from above, either the lease-ref (if there * was one) or the extra one acquired. */ - kref_put(&cfid->refcount, smb2_close_cached_fid); + close_cached_dir(cfid); } queue_delayed_work(cfid_put_wq, &cfids->laundromat_work, dir_cache_timeout * HZ); } -- 2.34.3
From: Henrique Carvalho <henrique.carvalho@suse.com> stable inclusion from stable-v6.6.118 commit 64332afa9f769135972021b8f2b06b089f024068 category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/12599 CVE: CVE-2025-40328 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=... -------------------------------- The previous commit bdb596ceb4b7 ("smb: client: fix potential UAF in smb2_close_cached_fid()") was an incomplete backport and missed one kref_put() call in cfids_invalidation_worker() that should have been converted to close_cached_dir(). Fixes: cb52d9c86d70 ("smb: client: fix potential UAF in smb2_close_cached_fid()")" Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Wang Zhaolong <wangzhaolong@huaweicloud.com> --- fs/smb/client/cached_dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c index 6b42d7c2ef4a..44bc04c939f7 100644 --- a/fs/smb/client/cached_dir.c +++ b/fs/smb/client/cached_dir.c @@ -686,11 +686,11 @@ static void cfids_invalidation_worker(struct work_struct *work) spin_unlock(&cfids->cfid_list_lock); list_for_each_entry_safe(cfid, q, &entry, entry) { list_del(&cfid->entry); /* Drop the ref-count acquired in invalidate_all_cached_dirs */ - kref_put(&cfid->refcount, smb2_close_cached_fid); + close_cached_dir(cfid); } } static void cfids_laundromat_worker(struct work_struct *work) { -- 2.34.3
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/20002 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/XAB... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/20002 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/XAB...
participants (2)
-
patchwork bot -
Wang Zhaolong