Linux-CIFS Archive mirror
 help / color / mirror / Atom feed
From: Steve French <smfrench@gmail.com>
To: Henrique Carvalho <henrique.carvalho@suse.com>
Cc: pc@manguebit.org, ronniesahlberg@gmail.com,
	sprasad@microsoft.com,  tom@talpey.com, bharathsm@microsoft.com,
	ematsumiya@suse.de,  linux-cifs@vger.kernel.org
Subject: Re: [PATCH] smb: client: fix potential cfid UAF in smb2_query_info_compound
Date: Mon, 27 Oct 2025 19:32:59 -0500	[thread overview]
Message-ID: <CAH2r5mszqYAxcvuQp+VXMqx1OA--KvqNAXzX0nQN1BeDg6hFJg@mail.gmail.com> (raw)
In-Reply-To: <20251027212919.2082212-1-henrique.carvalho@suse.com>

merged into cifs-2.6.git for-next pending testing

On Mon, Oct 27, 2025 at 4:31 PM Henrique Carvalho
<henrique.carvalho@suse.com> wrote:
>
> 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:
>  <TASK>
>  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
>
> Fixes: 4f1fffa237692 ("cifs: commands that are retried should have replay flag set")
> Reviewed-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
> Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de>
> Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
> ---
>  fs/smb/client/smb2ops.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
> index 0f9130ef2e7d..1e39f2165e42 100644
> --- a/fs/smb/client/smb2ops.c
> +++ b/fs/smb/client/smb2ops.c
> @@ -2799,11 +2799,12 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon,
>         struct cifs_fid fid;
>         int rc;
>         __le16 *utf16_path;
> -       struct cached_fid *cfid = NULL;
> +       struct cached_fid *cfid;
>         int retries = 0, cur_sleep = 1;
>
>  replay_again:
>         /* reinitialize for possible replay */
> +       cfid = NULL;
>         flags = CIFS_CP_CREATE_CLOSE_OP;
>         oplock = SMB2_OPLOCK_LEVEL_NONE;
>         server = cifs_pick_channel(ses);
> --
> 2.50.1
>
>


-- 
Thanks,

Steve

  reply	other threads:[~2025-10-28  0:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-27 21:29 [PATCH] smb: client: fix potential cfid UAF in smb2_query_info_compound Henrique Carvalho
2025-10-28  0:32 ` Steve French [this message]
2025-10-28  6:02   ` Shyam Prasad N
2025-10-28 13:43     ` Steve French

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH2r5mszqYAxcvuQp+VXMqx1OA--KvqNAXzX0nQN1BeDg6hFJg@mail.gmail.com \
    --to=smfrench@gmail.com \
    --cc=bharathsm@microsoft.com \
    --cc=ematsumiya@suse.de \
    --cc=henrique.carvalho@suse.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=pc@manguebit.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=sprasad@microsoft.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).