Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: ChenXiaoSong <chenxiaosong@chenxiaosong.com>
Cc: smfrench@gmail.com, linkinjeon@kernel.org, pc@manguebit.org,
	ronniesahlberg@gmail.com, sprasad@microsoft.com, tom@talpey.com,
	bharathsm@microsoft.com, senozhatsky@chromium.org,
	dhowells@redhat.com, linux-cifs@vger.kernel.org,
	ZhangGuoDong <zhangguodong@kylinos.cn>,
	ChenXiaoSong <chenxiaosong@kylinos.cn>
Subject: Re: [PATCH v2 1/1] smb/server: fix refcount leak in smb2_open()
Date: Wed, 25 Feb 2026 21:09:53 -0800	[thread overview]
Message-ID: <59d5c1a6-7a7f-464a-aa62-e53daff8870d@roeck-us.net> (raw)
In-Reply-To: <d3d93c04-fdd1-4b96-90f2-293a2d45f647@chenxiaosong.com>

Hi,

On 2/25/26 20:12, ChenXiaoSong wrote:
> Hi Guenter,
> 
> Thank you for taking the time to look into this issue.
> 
> I reviewed the relevant code in more detail and did not find any leak.
> 
> Both `ksmbd_put_durable_fd()` and `ksmbd_fd_put()` will eventually call `__ksmbd_remove_fd()` (remove fd from file table).
> 

Sorry for bothering you again. Are you sure ?

ksmbd_put_durable_fd() calls __ksmbd_close_fd() with NULL first parameter.
__ksmbd_close_fd() only calls __ksmbd_remove_fd() if ft (the first parameter)
is not NULL.

ksmbd_fd_put() does call __ksmbd_remove_fd() with first parameter, but ...

> If my understanding is incorrect, please let me know.
> 
> Thanks,
> ChenXiaoSong <chenxiaosong@chenxiaosong.com>
> 
> 在 2026/2/26 00:49, Guenter Roeck 写道:
>> Running an experimental AI agent on this patch produced the following
>> feedback:
>>
>> This isn't a bug introduced by your patch, but it looks like there is still a
>> resource leak here. If ksmbd_override_fsids() fails, we jump to err_out2.
>> At that point, fp is NULL because it hasn't been assigned dh_info.fp yet,
>> so ksmbd_fd_put(work, fp) will not be called. However, dh_info.fp was

the AI is trying to make the point that ksmbd_fd_put() will not be called
because fp == NULL.

Thanks,
Guenter

>> already inserted into the session file table by ksmbd_reopen_durable_fd(),
>> so it will leak in the session file table until the session is closed.
>> Should fp = dh_info.fp; be moved before the ksmbd_override_fsids() check?
>>
>> PTAL and let me know if it has a point or if it is missing something.
> 


  parent reply	other threads:[~2026-02-26  5:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-29  3:15 [PATCH v2 0/1] smb/server: fix some refcount leaks chenxiaosong.chenxiaosong
2025-12-29  3:15 ` [PATCH v2 1/1] smb/server: fix refcount leak in smb2_open() chenxiaosong.chenxiaosong
2025-12-29  4:06   ` Namjae Jeon
2026-02-25 16:49   ` Guenter Roeck
2026-02-26  4:12     ` ChenXiaoSong
2026-02-26  4:27       ` Guenter Roeck
2026-02-26  5:09       ` Guenter Roeck [this message]
2026-02-27  4:07         ` ChenXiaoSong
2026-02-27  4:12           ` ChenXiaoSong
2026-02-27  4:43             ` Namjae Jeon
2026-02-27  4:42           ` Guenter Roeck
2026-02-27  4:53             ` ChenXiaoSong

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=59d5c1a6-7a7f-464a-aa62-e53daff8870d@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=bharathsm@microsoft.com \
    --cc=chenxiaosong@chenxiaosong.com \
    --cc=chenxiaosong@kylinos.cn \
    --cc=dhowells@redhat.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=pc@manguebit.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=senozhatsky@chromium.org \
    --cc=smfrench@gmail.com \
    --cc=sprasad@microsoft.com \
    --cc=tom@talpey.com \
    --cc=zhangguodong@kylinos.cn \
    /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