mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ksmbd: validate share path for batch oplock reconnects
@ 2026-10-07  7:44 Sung Byeongchan
  2026-10-07 14:51 ` Namjae Jeon
  0 siblings, 1 reply; 3+ messages in thread
From: Sung Byeongchan @ 2026-10-07  7:44 UTC (permalink / raw)
  To: Namjae Jeon, ChenXiaoSong
  Cc: Sergey Senozhatsky, Tom Talpey, linux-cifs, linux-kernel

Durable reconnects backed by a lease reach
ksmbd_validate_name_reconnect(), which rejects reconnecting an open through
a different share root.  Batch oplock reconnects return immediately after
checking the oplock level and therefore skip that validation.

An authenticated client which owns a disconnected durable batch-oplock
handle can present its valid reconnect context on another tree.  The
preserved open is then rebound to that tree even when the client can no
longer connect to the source share.

Route successful batch-oplock reconnects through the same name and
share-root validation as lease reconnects.  Keep invalid oplock levels on
the existing error path.

This was found by source review with AI assistance.  In two independent
boots, a same-owner client was denied a new tree connect to the source
share, but reconnected its durable handle on an unrelated read-only share
and read the source file.  Routing the batch-oplock path through the
validator rejected the cross-share reconnect and preserved same-share
reconnects.

Fixes: c8efcc786146 ("ksmbd: add support for durable handles v1/v2")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Sung Byeongchan <tjdqudcks0424@naver.com>
---
 fs/smb/server/oplock.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/smb/server/oplock.c b/fs/smb/server/oplock.c
index 25ff8408f0ba2..70b7b085d4fdc 100644
--- a/fs/smb/server/oplock.c
+++ b/fs/smb/server/oplock.c
@@ -2489,9 +2489,10 @@ int smb2_check_durable_oplock(struct ksmbd_conn *conn,
 		if (opinfo->level != SMB2_OPLOCK_LEVEL_BATCH) {
 			pr_err("oplock level is not equal to SMB2_OPLOCK_LEVEL_BATCH\n");
 			ret = -EBADF;
+			goto out;
 		}
 
-		goto out;
+		goto validate_name;
 	}
 
 	if (memcmp(conn->ClientGUID, fp->client_guid,
@@ -2528,6 +2529,7 @@ int smb2_check_durable_oplock(struct ksmbd_conn *conn,
 		goto out;
 	}
 
+validate_name:
 	if (!ksmbd_inode_pending_delete(fp))
 		ret = ksmbd_validate_name_reconnect(share, fp, name);
 out:
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ksmbd: validate share path for batch oplock reconnects
  2026-10-07  7:44 [PATCH] ksmbd: validate share path for batch oplock reconnects Sung Byeongchan
@ 2026-10-07 14:51 ` Namjae Jeon
  2026-10-08  3:58   ` ChenXiaoSong
  0 siblings, 1 reply; 3+ messages in thread
From: Namjae Jeon @ 2026-10-07 14:51 UTC (permalink / raw)
  To: Sung Byeongchan
  Cc: ChenXiaoSong, Sergey Senozhatsky, Tom Talpey, linux-cifs, linux-kernel

> @@ -2489,9 +2489,10 @@ int smb2_check_durable_oplock(struct ksmbd_conn *conn,
>                 if (opinfo->level != SMB2_OPLOCK_LEVEL_BATCH) {
>                         pr_err("oplock level is not equal to SMB2_OPLOCK_LEVEL_BATCH\n");
>                         ret = -EBADF;
> +                       goto out;
>                 }
>
> -               goto out;
> +               goto validate_name;
SMB specification(MS-SMB2) explicitly skip path name validation. The
filename mismatch check applies only to lease-based opens
(opinfo->is_lease in ksmbd). This violates the reconnect semantics.

>         }
>
>         if (memcmp(conn->ClientGUID, fp->client_guid,
> @@ -2528,6 +2529,7 @@ int smb2_check_durable_oplock(struct ksmbd_conn *conn,
>                 goto out;
>         }
>
> +validate_name:
>         if (!ksmbd_inode_pending_delete(fp))
>                 ret = ksmbd_validate_name_reconnect(share, fp, name);
>  out:
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ksmbd: validate share path for batch oplock reconnects
  2026-10-07 14:51 ` Namjae Jeon
@ 2026-10-08  3:58   ` ChenXiaoSong
  0 siblings, 0 replies; 3+ messages in thread
From: ChenXiaoSong @ 2026-10-08  3:58 UTC (permalink / raw)
  To: Namjae Jeon, Sung Byeongchan
  Cc: Sergey Senozhatsky, Tom Talpey, linux-cifs, linux-kernel

On 10/7/2026 10:51 PM, Namjae Jeon wrote:
>> @@ -2489,9 +2489,10 @@ int smb2_check_durable_oplock(struct ksmbd_conn *conn,
>>                  if (opinfo->level != SMB2_OPLOCK_LEVEL_BATCH) {
>>                          pr_err("oplock level is not equal to SMB2_OPLOCK_LEVEL_BATCH\n");
>>                          ret = -EBADF;
>> +                       goto out;
>>                  }
>>
>> -               goto out;
>> +               goto validate_name;
> SMB specification(MS-SMB2) explicitly skip path name validation. The
> filename mismatch check applies only to lease-based opens
> (opinfo->is_lease in ksmbd). This violates the reconnect semantics.

Yes, see MS-SMB2 3.3.5.9.7

-- 
ChenXiaoSong <chenxiaosong@chenxiaosong.com>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-08  3:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-07  7:44 [PATCH] ksmbd: validate share path for batch oplock reconnects Sung Byeongchan
2026-10-07 14:51 ` Namjae Jeon
2026-10-08  3:58   ` ChenXiaoSong

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®