 smb: client: fix potential cfid UAF in smb2_query_info_compound · gregkh/linux@5c76f99 · GitHub Skip to content Navigation Menu Toggle navigation Sign in Appearance settings Platform AI CODE CREATION GitHub Copilot Write better code with AI GitHub Spark Build and deploy intelligent apps GitHub Models Manage and compare prompts MCP Registry New Integrate external tools DEVELOPER WORKFLOWS Actions Automate any workflow Codespaces Instant dev environments Issues Plan and track work Code Review Manage code changes APPLICATION SECURITY GitHub Advanced Security Find and fix vulnerabilities Code security Secure your code as you build Secret protection  EXPLORE Why GitHub Documentation Blog Changelog Marketplace View all features Solutions BY COMPANY SIZE Enterprises Small and medium teams Startups Nonprofits BY USE CASE App Modernization DevSecOps DevOps CI/CD View all use cases BY INDUSTRY Healthcare Financial services Manufacturing Government View all industries View all solutions Resources EXPLORE BY TOPIC AI Software Development DevOps Security View all topics EXPLORE BY TYPE Customer stories Events &amp; webinars Ebooks &amp; reports Business insights GitHub Skills SUPPORT &amp; SERVICES Documentation Customer support Community forum Trust center Partners View all resources Open Source COMMUNITY GitHub Sponsors Fund open source developers PROGRAMS Security Lab Maintainer Community Accelerator GitHub Stars Archive Program REPOSITORIES Topics Trending Collections Enterprise ENTERPRISE SOLUTIONS Enterprise platform AI-powered developer platform AVAILABLE ADD-ONS GitHub Advanced Security Enterprise-grade security features Copilot for Business Enterprise-grade AI features Premium Support Enterprise-grade 24/7 support Pricing Search or jump to... Search code, repositories, users, issues, pull requests... --> Search Clear Search syntax tips Provide feedback --> We read every piece of feedback, and take your input very seriously.  Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly --> Name Query To see all available qualifiers, see our documentation . Cancel Create saved search Sign in Sign up Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} gregkh / linux Public Notifications You must be signed in to change notification settings Fork 686 Star 644 Code Actions Security and quality 0 Insights Additional navigation options Code Actions Security and quality Insights Commit 5c76f99 Browse files Browse files hac-v authored and smfrench committed smb: client: fix potential cfid UAF in smb2_query_info_compound When smb2_query_info_compound() retries, a previously allocated cfid may have been freed in the first attempt. Because cfid wasn't reset on replay, later cleanup could act on a stale pointer, leading to a potential use-after-free. Reinitialize cfid to NULL under the replay label. Example trace (trimmed): refcount_t: underflow; use-after-free. WARNING: CPU: 1 PID: 11224 at ../lib/refcount.c:28 refcount_warn_saturate+0x9c/0x110 [...] RIP: 0010:refcount_warn_saturate+0x9c/0x110 [...] Call Trace: &lt;TASK&gt; smb2_query_info_compound+0x29c/0x5c0 [cifs f90b72658819bd21c94769b6a652029a07a7172f] ? step_into+0x10d/0x690 ? __legitimize_path+0x28/0x60 smb2_queryfs+0x6a/0xf0 [cifs f90b72658819bd21c94769b6a652029a07a7172f] smb311_queryfs+0x12d/0x140 [cifs f90b72658819bd21c94769b6a652029a07a7172f] ? kmem_cache_alloc+0x18a/0x340 ? getname_flags+0x46/0x1e0 cifs_statfs+0x9f/0x2b0 [cifs f90b72658819bd21c94769b6a652029a07a7172f] statfs_by_dentry+0x67/0x90 vfs_statfs+0x16/0xd0 user_statfs+0x54/0xa0 __do_sys_statfs+0x20/0x50 do_syscall_64+0x58/0x80 Cc: stable@kernel.org Fixes: 4f1fffa ("cifs: commands that are retried should have replay flag set") Reviewed-by: Paulo Alcantara (Red Hat) &lt;pc@manguebit.com&gt; Acked-by: Shyam Prasad N &lt;sprasad@microsoft.com&gt; Reviewed-by: Enzo Matsumiya &lt;ematsumiya@suse.de&gt; Signed-off-by: Henrique Carvalho &lt;henrique.carvalho@suse.com&gt; Signed-off-by: Steve French &lt;stfrench@microsoft.com&gt; 1 parent f765fdf commit 5c76f99 Copy full SHA for 5c76f99 1 file changed + 2 - 1 Lines changed: 2 additions &amp; 1 deletion File tree Expand file tree Collapse file tree Open diff view settings Filter options fs/smb/client smb2ops.c Expand file tree Collapse file tree Open diff view settings Collapse file ‎ fs/smb/client/smb2ops.c ‎ Copy file name to clipboard Expand all lines: fs/smb/client/smb2ops.c + 2 - 1 Lines changed: 2 additions &amp; 1 deletion Original file line number Diff line number Diff line change @@ -2799,11 +2799,12 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon, 2799 2799 struct cifs_fid fid ; 2800 2800 int rc ; 2801 2801 __le16 * utf16_path ; 2802 - struct cached_fid * cfid = NULL ; 2802 + struct cached_fid * cfid ; 2803 2803 int retries = 0 , cur_sleep = 1 ; 2804 2804 2805 2805 replay_again : 2806 2806 /* reinitialize for possible replay */ 2807 + cfid = NULL ; 2807 2808 flags = CIFS_CP_CREATE_CLOSE_OP ; 2808 2809 oplock = SMB2_OPLOCK_LEVEL_NONE ; 2809 2810 server = cifs_pick_channel ( ses ); 0 commit comments Comments 0 ( 0 ) Footer &copy; 2026 GitHub,&nbsp;Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. 