Re: [PATCH] NFSD: Reject a COPY whose source and destination are the same file
From: Jeff Layton
Date: Fri Nov 20 2026 - 16:16:28 EST
On Fri, 2026-11-20 at 08:55 +0100, Aurélien Couderc wrote:
> 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...
>
It does seem a bit restrictive, but that's way the RFC is written
today. If you want to lead an effort to update the RFC, then be my
guest!
--
Jeff Layton <jlayton@xxxxxxxxxx>