ksmbd: fix use-after-free in smb2_open during durable reconnect
authorAkif <akif.sait111@gmail.com>
Fri, 17 Apr 2026 18:27:09 +0000 (23:57 +0530)
committerSteve French <stfrench@microsoft.com>
Sat, 18 Apr 2026 17:19:59 +0000 (12:19 -0500)
commit1baff47b81f94f9231c91236aa511420d0e266b9
tree33c582c0dac9f7b2f6cab8fd14d9bed8723075bd
parent3e4e2ea2a781018ed5d75f969e3e5606beb66e48
ksmbd: fix use-after-free in smb2_open during durable reconnect

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@gmail.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/smb2pdu.c