mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ChenXiaoSong <chenxiaosong@chenxiaosong.com>
To: raoxu <raoxu@uniontech.com>, linkinjeon@kernel.org
Cc: smfrench@gmail.com, senozhatsky@chromium.org, tom@talpey.com,
	linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] ksmbd: preserve STATUS_ACCESS_DENIED for copychunk errors
Date: Fri, 31 Jul 2026 16:10:30 +0800	[thread overview]
Message-ID: <45781734-3c48-46be-9505-23e4e7580a85@chenxiaosong.com> (raw)
In-Reply-To: <2DC5EE1DC892643F+20260731072020.1307022-1-raoxu@uniontech.com>

Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>

On 7/31/26 15:20, raoxu wrote:
> 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
> 
> 

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


  reply	other threads:[~2026-07-31  8:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31  7:20 raoxu
2026-07-31  8:10 ` ChenXiaoSong [this message]
2026-07-31  8:16 ` ChenXiaoSong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45781734-3c48-46be-9505-23e4e7580a85@chenxiaosong.com \
    --to=chenxiaosong@chenxiaosong.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=raoxu@uniontech.com \
    --cc=senozhatsky@chromium.org \
    --cc=smfrench@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®