All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shuhao Fu <sfual@cse.ust.hk>
To: Henrique Carvalho <henrique.carvalho@suse.com>
Cc: Steve French <smfrench@gmail.com>, Tom Talpey <tom@talpey.com>,
	Shyam Prasad N <sprasad@microsoft.com>,
	Paulo Alcantara <pc@manguebit.org>,
	linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
	linux-kernel@vger.kernel.org, Steve French <sfrench@samba.org>,
	Bharath SM <bharathsm@microsoft.com>
Subject: Re: [PATCH] smb: client: fix refcount leak in smb2_set_path_attr
Date: Tue, 4 Nov 2025 16:56:35 +0000	[thread overview]
Message-ID: <aQowQ7gCdDruGVro@chcpu18> (raw)
In-Reply-To: <648b7b14-d285-449a-a1b3-4cd062a55b02@suse.com>

On Tue, Nov 04, 2025 at 01:23:33PM -0300, Henrique Carvalho wrote:
> 
> 
> On 11/4/25 1:12 PM, Steve French via samba-technical wrote:
> > There are multiple callers - are there callers that don't call
> > "set_writeable_path()" ?    And so could cause the reverse refcount
> > issue?
> 
> Yes... Even if it does not cause an issue today, that fix looks like it
> belongs inside smb2_rename_path?

I placed decrement in `smb2_set_path_attr` since it seems like a wrapper
of `smb2_compound_op`. I figured that this wrapper should handle the
failure cases the same way as `smb2_compound_op`.

Thanks,
Shuhao
> 
> > 
> > On Tue, Nov 4, 2025 at 9:21 AM Shuhao Fu <sfual@cse.ust.hk> wrote:
> >>
> >> Fix refcount leak in `smb2_set_path_attr` when path conversion fails.
> >>
> >> Function `cifs_get_writable_path` returns `cfile` with its reference
> >> counter `cfile->count` increased on success. Function `smb2_compound_op`
> >> would decrease the reference counter for `cfile`, as stated in its
> >> comment. By calling `smb2_rename_path`, the reference counter of `cfile`
> >> would leak if `cifs_convert_path_to_utf16` fails in `smb2_set_path_attr`.
> >>
> >> Fixes: 8de9e86c67ba ("cifs: create a helper to find a writeable handle by path name")
> >> Signed-off-by: Shuhao Fu <sfual@cse.ust.hk>
> >> ---
> >>  fs/smb/client/smb2inode.c | 2 ++
> >>  1 file changed, 2 insertions(+)
> >>
> >> diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c
> >> index 09e3fc81d..69cb81fa0 100644
> >> --- a/fs/smb/client/smb2inode.c
> >> +++ b/fs/smb/client/smb2inode.c
> >> @@ -1294,6 +1294,8 @@ static int smb2_set_path_attr(const unsigned int xid, struct cifs_tcon *tcon,
> >>         smb2_to_name = cifs_convert_path_to_utf16(to_name, cifs_sb);
> >>         if (smb2_to_name == NULL) {
> >>                 rc = -ENOMEM;
> >> +               if (cfile)
> >> +                       cifsFileInfo_put(cfile);
> >>                 goto smb2_rename_path;
> >>         }
> >>         in_iov.iov_base = smb2_to_name;
> >> --
> >> 2.39.5 (Apple Git-154)
> >>
> >>
> > 
> > 
> 
> -- 
> Henrique
> SUSE Labs

  reply	other threads:[~2025-11-04 16:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-04 15:13 [PATCH] smb: client: fix refcount leak in smb2_set_path_attr Shuhao Fu
2025-11-04 16:12 ` Steve French
2025-11-04 16:23   ` Henrique Carvalho
2025-11-04 16:56     ` Shuhao Fu [this message]
2025-11-04 18:34       ` Henrique Carvalho
2025-11-04 16:54   ` Shuhao Fu

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=aQowQ7gCdDruGVro@chcpu18 \
    --to=sfual@cse.ust.hk \
    --cc=bharathsm@microsoft.com \
    --cc=henrique.carvalho@suse.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pc@manguebit.org \
    --cc=samba-technical@lists.samba.org \
    --cc=sfrench@samba.org \
    --cc=smfrench@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.