mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ksmbd: preserve STATUS_ACCESS_DENIED for copychunk errors
@ 2026-07-31  7:20 raoxu
  2026-07-31  8:10 ` ChenXiaoSong
  2026-07-31  8:16 ` ChenXiaoSong
  0 siblings, 2 replies; 3+ messages in thread
From: raoxu @ 2026-07-31  7:20 UTC (permalink / raw)
  To: linkinjeon
  Cc: smfrench, senozhatsky, tom, linux-cifs, linux-kernel, raoxu, stable

From: Xu Rao <raoxu@uniontech.com>

fsctl_copychunk() maps errors from ksmbd_vfs_copy_file_ranges() to SMB
status codes. For -EACCES it first sets STATUS_ACCESS_DENIED, but the
following -EAGAIN test starts a separate if/else-if chain. Because
-EACCES does not match that chain, its final else immediately overwrites
the status with STATUS_UNEXPECTED_IO_ERROR.

MS-SMB2 section 3.3.5.15.6 requires FSCTL_SRV_COPYCHUNK and
FSCTL_SRV_COPYCHUNK_WRITE to fail with STATUS_ACCESS_DENIED when the
source open lacks FILE_READ_DATA or the destination open lacks
FILE_WRITE_DATA or FILE_APPEND_DATA. ksmbd_vfs_copy_file_ranges()
returns -EACCES when its source or destination access check fails, so the
current control flow reports a protocol-visible permission failure as an
unrelated I/O error.

Make the -EAGAIN condition part of the same else-if chain so the -EACCES
mapping is preserved.

Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Rao <raoxu@uniontech.com>
---
 fs/smb/server/smb2pdu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index bec692bca1ca..416bf1e55c81 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -8524,7 +8524,7 @@ static int fsctl_copychunk(struct ksmbd_work *work,
 	if (ret < 0) {
 		if (ret == -EACCES)
 			rsp->hdr.Status = STATUS_ACCESS_DENIED;
-		if (ret == -EAGAIN)
+		else if (ret == -EAGAIN)
 			rsp->hdr.Status = STATUS_FILE_LOCK_CONFLICT;
 		else if (ret == -EBADF)
 			rsp->hdr.Status = STATUS_INVALID_HANDLE;
--
2.50.1


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

end of thread, other threads:[~2026-07-31  8:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-31  7:20 [PATCH] ksmbd: preserve STATUS_ACCESS_DENIED for copychunk errors raoxu
2026-07-31  8:10 ` ChenXiaoSong
2026-07-31  8:16 ` 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®