All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shuhao Fu <sfual@cse.ust.hk>
To: Steve French <smfrench@gmail.com>
Cc: Steve French <sfrench@samba.org>,
	Paulo Alcantara <pc@manguebit.org>,
	Ronnie Sahlberg <ronniesahlberg@gmail.com>,
	Shyam Prasad N <sprasad@microsoft.com>,
	Tom Talpey <tom@talpey.com>, Bharath SM <bharathsm@microsoft.com>,
	linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] smb: client: fix refcount leak in smb2_set_path_attr
Date: Tue, 4 Nov 2025 16:54:48 +0000	[thread overview]
Message-ID: <aQov2KFhe8Ro3CtC@chcpu18> (raw)
In-Reply-To: <CAH2r5mu7s4p88RhUbCm5mqUvEVM60OOTTJOZ+rz09nFfc+t3mQ@mail.gmail.com>

On Tue, Nov 04, 2025 at 10:12:13AM -0600, Steve French wrote:
> There are multiple callers - are there callers that don't call
> "set_writeable_path()" ?    And so could cause the reverse refcount
> issue?

I found three calls to `smb2_set_path_attr`. Two in `smb2_rename_path`
and one in `smb2_create_hardlink`. The one in `smb2_create_hardlink`
passes NULL for cfile. Therefore, it would not cause reverse refcount
issue here.

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)
> >
> >
> 
> 
> -- 
> Thanks,
> 
> Steve

      parent reply	other threads:[~2025-11-04 16:55 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
2025-11-04 18:34       ` Henrique Carvalho
2025-11-04 16:54   ` Shuhao Fu [this message]

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=aQov2KFhe8Ro3CtC@chcpu18 \
    --to=sfual@cse.ust.hk \
    --cc=bharathsm@microsoft.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pc@manguebit.org \
    --cc=ronniesahlberg@gmail.com \
    --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.