* [PATCH 0/2] smb/server: fix some refcount leaks
@ 2025-12-29 2:13 chenxiaosong.chenxiaosong
2025-12-29 2:13 ` [PATCH 1/2] smb/server: fix refcount leak in parse_durable_handle_context() chenxiaosong.chenxiaosong
2025-12-29 2:13 ` [PATCH 2/2] smb/server: fix refcount leak in smb2_open() chenxiaosong.chenxiaosong
0 siblings, 2 replies; 5+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-29 2:13 UTC (permalink / raw)
To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
senozhatsky, dhowells
Cc: linux-cifs, ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
My dear team member, ZhangGuoDong, has caught some refcount leak issues.
Other patches pending review (including those from others) can be found at the following link:
https://chenxiaosong.com/en/smb-patch.html
ZhangGuoDong (2):
smb/server: fix refcount leak in parse_durable_handle_context()
smb/server: fix refcount leak in smb2_open()
fs/smb/server/smb2pdu.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] smb/server: fix refcount leak in parse_durable_handle_context()
2025-12-29 2:13 [PATCH 0/2] smb/server: fix some refcount leaks chenxiaosong.chenxiaosong
@ 2025-12-29 2:13 ` chenxiaosong.chenxiaosong
2025-12-29 2:57 ` Namjae Jeon
2025-12-29 2:13 ` [PATCH 2/2] smb/server: fix refcount leak in smb2_open() chenxiaosong.chenxiaosong
1 sibling, 1 reply; 5+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-29 2:13 UTC (permalink / raw)
To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
senozhatsky, dhowells
Cc: linux-cifs, ZhangGuoDong, ChenXiaoSong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
When the command is a replay operation and -ENOEXEC is returned,
the refcount of ksmbd_file must be released.
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/server/smb2pdu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 469b70757dba..6a966c696f7d 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -2809,6 +2809,7 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
SMB2_CLIENT_GUID_SIZE)) {
if (!(req->hdr.Flags & SMB2_FLAGS_REPLAY_OPERATION)) {
err = -ENOEXEC;
+ ksmbd_put_durable_fd(dh_info->fp);
goto out;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] smb/server: fix refcount leak in smb2_open()
2025-12-29 2:13 [PATCH 0/2] smb/server: fix some refcount leaks chenxiaosong.chenxiaosong
2025-12-29 2:13 ` [PATCH 1/2] smb/server: fix refcount leak in parse_durable_handle_context() chenxiaosong.chenxiaosong
@ 2025-12-29 2:13 ` chenxiaosong.chenxiaosong
2025-12-29 2:56 ` Namjae Jeon
1 sibling, 1 reply; 5+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-29 2:13 UTC (permalink / raw)
To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
senozhatsky, dhowells
Cc: linux-cifs, ZhangGuoDong, ChenXiaoSong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
When ksmbd_vfs_getattr() fails, the reference count of ksmbd_file
must be released.
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/server/smb2pdu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 6a966c696f7d..ed9352753d83 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3007,8 +3007,10 @@ int smb2_open(struct ksmbd_work *work)
file_info = FILE_OPENED;
rc = ksmbd_vfs_getattr(&fp->filp->f_path, &stat);
- if (rc)
+ if (rc) {
+ ksmbd_put_durable_fd(fp);
goto err_out2;
+ }
ksmbd_put_durable_fd(fp);
goto reconnected_fp;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] smb/server: fix refcount leak in smb2_open()
2025-12-29 2:13 ` [PATCH 2/2] smb/server: fix refcount leak in smb2_open() chenxiaosong.chenxiaosong
@ 2025-12-29 2:56 ` Namjae Jeon
0 siblings, 0 replies; 5+ messages in thread
From: Namjae Jeon @ 2025-12-29 2:56 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong
Cc: smfrench, pc, ronniesahlberg, sprasad, tom, bharathsm,
senozhatsky, dhowells, linux-cifs, ZhangGuoDong, ChenXiaoSong
On Mon, Dec 29, 2025 at 11:15 AM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>
> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>
> When ksmbd_vfs_getattr() fails, the reference count of ksmbd_file
> must be released.
>
> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> ---
> fs/smb/server/smb2pdu.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
> index 6a966c696f7d..ed9352753d83 100644
> --- a/fs/smb/server/smb2pdu.c
> +++ b/fs/smb/server/smb2pdu.c
> @@ -3007,8 +3007,10 @@ int smb2_open(struct ksmbd_work *work)
> file_info = FILE_OPENED;
>
> rc = ksmbd_vfs_getattr(&fp->filp->f_path, &stat);
> - if (rc)
> + if (rc) {
> + ksmbd_put_durable_fd(fp);
> goto err_out2;
> + }
I think that It is simpler to do it like this:
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 8a7c48adb87e..41626cb7d2f5 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3009,10 +3009,9 @@ int smb2_open(struct ksmbd_work *work)
file_info = FILE_OPENED;
rc = ksmbd_vfs_getattr(&fp->filp->f_path, &stat);
+ ksmbd_put_durable_fd(fp);
if (rc)
goto err_out2;
-
- ksmbd_put_durable_fd(fp);
goto reconnected_fp;
}
} else if (req_op_level == SMB2_OPLOCK_LEVEL_LEASE)
>
> ksmbd_put_durable_fd(fp);
> goto reconnected_fp;
> --
> 2.43.0
>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] smb/server: fix refcount leak in parse_durable_handle_context()
2025-12-29 2:13 ` [PATCH 1/2] smb/server: fix refcount leak in parse_durable_handle_context() chenxiaosong.chenxiaosong
@ 2025-12-29 2:57 ` Namjae Jeon
0 siblings, 0 replies; 5+ messages in thread
From: Namjae Jeon @ 2025-12-29 2:57 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong
Cc: smfrench, pc, ronniesahlberg, sprasad, tom, bharathsm,
senozhatsky, dhowells, linux-cifs, ZhangGuoDong, ChenXiaoSong
On Mon, Dec 29, 2025 at 11:15 AM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>
> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>
> When the command is a replay operation and -ENOEXEC is returned,
> the refcount of ksmbd_file must be released.
>
> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Applied it to #ksmbd-for-next-next.
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-12-29 2:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-29 2:13 [PATCH 0/2] smb/server: fix some refcount leaks chenxiaosong.chenxiaosong
2025-12-29 2:13 ` [PATCH 1/2] smb/server: fix refcount leak in parse_durable_handle_context() chenxiaosong.chenxiaosong
2025-12-29 2:57 ` Namjae Jeon
2025-12-29 2:13 ` [PATCH 2/2] smb/server: fix refcount leak in smb2_open() chenxiaosong.chenxiaosong
2025-12-29 2:56 ` Namjae Jeon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox