Re: [PATCH] NFSD: Reject a COPY whose source and destination are the same file
From: Aurélien Couderc
Date: Fri Nov 20 2026 - 02:56:29 EST
On Thu, Nov 19, 2026 at 6:44 PM Jeff Layton <jlayton@xxxxxxxxxx> wrote:
>
> RFC 7862 Section 15.2.3 says that COPY MUST fail with NFS4ERR_INVAL
> when SAVED_FH and CURRENT_FH refer to the same file, whatever the
> ranges. NFSD never checks for this. A same-file COPY with
> non-overlapping ranges succeeds, and one with overlapping ranges fails
> only because the VFS rejects it.
>
> The overlap-only rule applies to CLONE (Section 15.13.3), so leave
> nfsd4_verify_copy() alone. Instead, check in nfsd4_setup_intra_ssc(),
> after both stateids are verified. For an inter-server copy, SAVED_FH
> names a file on another server, so that path is not affected.
>
> The Linux client never sends a same-file COPY, so this does not change
> its behaviour. Found by pynfs COPY11.
Why should COPY within the same file be blocked?
For example: Windows FSCTL_OFFLOAD_READ+FSCTL_OFFLOAD_WRITE is used
exactly like that by databases like Oracle. Even advertised as a
"database accelerator" feature...
Better tix the NFSv4.2 COPY spec at RFC level then...
Aurélien
--
Aurélien Couderc <aurelien.couderc2002@xxxxxxxxx>
Big Data/Data mining expert, chess enthusiast