Re: [PATCH] ksmbd: preserve STATUS_ACCESS_DENIED for copychunk errors
ChenXiaoSong <[email protected]> Fri, 31 Jul 2026 16:10:30 +0800
| Newsgroups | org.kernel.vger.linux-cifs,org.kernel.vger.linux-kernel,org.kernel.vger.stable |
|---|---|
| Message-ID | <[email protected]> |
Reviewed-by: ChenXiaoSong <[email protected]> On 7/31/26 15:20, raoxu wrote: > From: Xu Rao <[email protected]> > > 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: [email protected] > Signed-off-by: Xu Rao <[email protected]> > --- > 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 > > -- ChenXiaoSong <[email protected]> Chinese Homepage: https://chenxiaosong.com English Homepage: https://chenxiaosong.com/en