Subject: bug#11100: closed (Re: bug#11074: Possible bug in cp from coreutils 6.12)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 08 May 2012 09:19:02 +0000

Your bug report

#11074: Racy code in copy.c

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
11074: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11074
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#11074: Possible bug in cp from coreutils 6.12
From: Jim Meyering <[email-masked]>
To: Philipp Thomas <[email-masked]>
Cc: [email-masked]
Date: Tue, 08 May 2012 11:16:20 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Philipp Thomas wrote:
> I copy a file from one NFS export to another NFS export and execute
> it in the new location, I get a "'Stale NFS file handle' error at the second
> line "cp submit.sh $submit_sh":

Thanks.  I'm marking this as closed,
since the fix for http://bugs.gnu.org/11100
should address this problem, too.

Subject: Racy code in copy.c
From: Philipp Thomas <[email-masked]>
To: [email-masked]
Cc: Neil F Brown <[email-masked]>
Date: Tue, 27 Mar 2012 14:58:18 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

I'd like to pass on observations from my collegue Neil Brown:

in src/copy.c, copy_reg() is passed "bool *new_dst".

This is 'false' if the file already exists, in which case it attempts to
open the file with O_WRONLY | O_TRUNC | O_BINARY.
If it is 'true', only then does it use O_CREAT (and others).

Somewhere up the call chain - I'm not sure where - new_dst is set if 'stat'
on the file succeeds.  The above mentioned code assumes that the file still
exists.  This is racy - particularly for NFS where deletions from other
clients can take a while to appear.

Philipp