[SRU][Q][PATCH 1/1] ksmbd: fix use-after-free in smb2_open during durable reconnect
Cengiz Can
cengiz.can at canonical.com
Fri Jul 17 00:59:17 UTC 2026
From: Akif <akif.sait111 at gmail.com>
In smb2_open, the call to ksmbd_put_durable_fd(fp) drops the reference
to the durable file descriptor early during the durable reconnect
process. If an error occurs subsequently (eg, ksmbd_iov_pin_rsp fails)
or a scavenger accesses the file, it leads to a use-after-free when
accessing fp properties (eg fp->create_time).
Move the single put to the end of the function below err_out2 so fp
stays valid until smb2_open returns.
Fixes: c8efcc786146 ("ksmbd: add support for durable handles v1/v2")
Signed-off-by: Akif <akif.sait111 at gmail.com>
Acked-by: Namjae Jeon <linkinjeon at kernel.org>
Signed-off-by: Steve French <stfrench at microsoft.com>
(backported from commit 1baff47b81f94f9231c91236aa511420d0e266b9)
[bot_kybele: This tree's smb2_open uses a reconnected_fp goto-label variant and
already had the terminal "if (dh_info.reconnected) ksmbd_put_durable_fd"
(upstream's 2nd hunk); its smb2_check_durable_oplock has no sess->user arg, so
I kept that signature and just removed the early puts, including the extra
ksmbd_put_durable_fd(fp) before goto reconnected_fp not present in upstream
context, to avoid a double-put.]
CVE-2026-53010
Assisted-by: kybele:claude-opus-4.8
Signed-off-by: Cengiz Can <cengiz.can at canonical.com>
---
fs/smb/server/smb2pdu.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 60a95ea7eaea..7daaa1d68211 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3000,20 +3000,15 @@ int smb2_open(struct ksmbd_work *work)
if (dh_info.reconnected == true) {
rc = smb2_check_durable_oplock(conn, share, dh_info.fp, lc, name);
- if (rc) {
- ksmbd_put_durable_fd(dh_info.fp);
+ if (rc)
goto err_out2;
- }
rc = ksmbd_reopen_durable_fd(work, dh_info.fp);
- if (rc) {
- ksmbd_put_durable_fd(dh_info.fp);
+ if (rc)
goto err_out2;
- }
if (ksmbd_override_fsids(work)) {
rc = -ENOMEM;
- ksmbd_put_durable_fd(dh_info.fp);
goto err_out2;
}
@@ -3024,7 +3019,6 @@ int smb2_open(struct ksmbd_work *work)
if (rc)
goto err_out2;
- ksmbd_put_durable_fd(fp);
goto reconnected_fp;
}
} else if (req_op_level == SMB2_OPLOCK_LEVEL_LEASE)
@@ -3787,6 +3781,9 @@ int smb2_open(struct ksmbd_work *work)
ksmbd_debug(SMB, "Error response: %x\n", rsp->hdr.Status);
}
+ if (dh_info.reconnected)
+ ksmbd_put_durable_fd(dh_info.fp);
+
kfree(name);
kfree(lc);
--
2.43.0
More information about the kernel-team
mailing list