Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 449838

Summary: sys-apps/coreutils: multiple invocations of 'cp' may suffer a race condition creating directories
Product: Gentoo Linux Reporter: Michał Górny <mgorny>
Component: [OLD] Core systemAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED FIXED    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
URL: http://lists.gnu.org/archive/html/bug-coreutils/2013-01/msg00002.html
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 449760    

Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-01-02 22:02:09 UTC
Bug 449760 states a semi-random issue of:

  cp: cannot create directory ‘/var/tmp/portage/dev-python/pyxattr-0.5.1/image/usr’: File exists

which most likely means that copying multiple trees into the same location suffers a race condition when creating necessary directories.

AFAICS, make_dir_parents_private() does fail on every mkdir() failure:

  if (mkdir (dir, mkdir_mode) != 0)
    {
      error (0, errno, _("cannot make directory %s"),
             quote (dir));
      return false;
    }

In this case, it'd be probably enough if it checked for EEXIST and restat()-ed the directory instead. Or just ignored the error and tried to copy/mkdir more waiting for ENOTDIR.
Comment 1 SpanKY gentoo-dev 2013-01-04 01:58:19 UTC
pretty sure it's been this way forever.  not sure if it should bother with stating and forcing the mode bits to the expected if someone is doing things in parallel.  make that the user's problem.
Comment 2 SpanKY gentoo-dev 2013-01-11 06:21:30 UTC
should be all set now in the tree; thanks for the report!

Commit message: Fix parallel recursive cp errors w/mkdir
http://sources.gentoo.org/gentoo/src/patchsets/coreutils/8.20/040_all_coreutils-cp-mkdir-eexist.patch?rev=1.1
http://sources.gentoo.org/sys-apps/coreutils/coreutils-8.20-r2.ebuild?rev=1.1