mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ChenXiaoSong <chenxiaosong@chenxiaosong.com>
To: Guenter Roeck <linux@roeck-us.net>, Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Tom Talpey <tom@talpey.com>,
	linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] smb/server: Fix another refcount leak in smb2_open()
Date: Fri, 27 Feb 2026 13:57:59 +0800	[thread overview]
Message-ID: <32c1704c-7c9e-4dbe-b852-0fff0124ddc4@chenxiaosong.com> (raw)
In-Reply-To: <20260227055421.1777793-1-linux@roeck-us.net>

Looks good. Feel free to add:
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>

On 2026/2/27 13:54, Guenter Roeck wrote:
> 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 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.
> 
> Move fp = dh_info.fp; ahead of the ksmbd_override_fsids() check to fix the
> problem.
> 
> Found by an experimental AI code review agent at Google.
> 
> Cc: Namjae Jeon <linkinjeon@kernel.org>
> Cc: ChenXiaoSong <chenxiaosong@chenxiaosong.com>
> Fixes: c8efcc786146a ("ksmbd: add support for durable handles v1/v2")
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>   fs/smb/server/smb2pdu.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
> index 95901a78951c..8b680c96ee44 100644
> --- a/fs/smb/server/smb2pdu.c
> +++ b/fs/smb/server/smb2pdu.c
> @@ -3011,13 +3011,14 @@ int smb2_open(struct ksmbd_work *work)
>   				goto err_out2;
>   			}
>   
> +			fp = dh_info.fp;
> +
>   			if (ksmbd_override_fsids(work)) {
>   				rc = -ENOMEM;
>   				ksmbd_put_durable_fd(dh_info.fp);
>   				goto err_out2;
>   			}
>   
> -			fp = dh_info.fp;
>   			file_info = FILE_OPENED;
>   
>   			rc = ksmbd_vfs_getattr(&fp->filp->f_path, &stat);

  reply	other threads:[~2026-02-27  5:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-27  5:54 Guenter Roeck
2026-02-27  5:57 ` ChenXiaoSong [this message]
2026-02-27  6:04 ` Namjae Jeon

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=32c1704c-7c9e-4dbe-b852-0fff0124ddc4@chenxiaosong.com \
    --to=chenxiaosong@chenxiaosong.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=senozhatsky@chromium.org \
    --cc=smfrench@gmail.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

all inboxes | Powered by JetHome®