GNU bug report logs - #12656
cp since 8.11 corrupts files

Previous Next

Package: coreutils;

Reported by: "Mike Gerth" <m.gerth <at> avm.de>

Date: Mon, 15 Oct 2012 15:56:01 UTC

Severity: normal

Tags: fixed

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Jim Meyering <jim <at> meyering.net>
To: Bernhard Voelker <mail <at> bernhard-voelker.de>
Cc: m.gerth <at> avm.de, Alan Curry <pacman-cu <at> kosh.dhis.org>, 12656 <at> debbugs.gnu.org
Subject: bug#12656: WG: Re[4]: bug#12656: cp since 8.11 corrupts files
Date: Sun, 21 Oct 2012 11:58:15 +0200
Bernhard Voelker wrote:
> On 10/17/2012 10:44 AM, Jim Meyering wrote:
...
>>  ** Bug fixes
>>
>> +  cp could read from freed memory and could even make corrupt copies.
>> +  This could happen only with a very fragmented input file and when using
>> +  its FIEMAP/extent-based copying code.  [bug introduced in coreutils-8.11]
>
> As the bug is in extent-scan.c, doesn't it also affect mv (and ginstall)?
>
> In src/local.mk:
>
>   copy_sources = \
>     src/copy.c \
>     src/cp-hash.c \
>     src/extent-scan.c \
>     src/extent-scan.h
>
>   ...
>   src_ginstall_SOURCES = src/install.c src/prog-fprintf.c $(copy_sources)
>   ...
>   src_cp_SOURCES = src/cp.c $(copy_sources)
>   ...
>   src_mv_SOURCES = src/mv.c src/remove.c $(copy_sources)

Good point.  It does, not just by virtue of linking to copy.c,
but because each also enables sparse_mode:

  $ grep sparse_mode.= src/{mv,install}.c
  src/mv.c:  x->sparse_mode = SPARSE_AUTO;  /* FIXME: maybe make this an option */
  src/install.c:  x->sparse_mode = SPARSE_AUTO;

Thanks!

From d001e65bb1f218b7208d65b38e5f854e58a11e62 Mon Sep 17 00:00:00 2001
From: Jim Meyering <jim <at> meyering.net>
Date: Sun, 21 Oct 2012 11:56:44 +0200
Subject: [PATCH] doc: NEWS: the cp bug affects mv and install, too

* NEWS (Bug fixes): Note that the copy-induced corruption affects
mv (sometimes) and install, too.  Pointed out by Bernhard Voelker.
---
 NEWS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/NEWS b/NEWS
index 0fc2a94..bbd8f59 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ GNU coreutils NEWS                                    -*- outline -*-
   cp could read from freed memory and could even make corrupt copies.
   This could happen with a very fragmented and sparse input file,
   on GNU/Linux file systems supporting fiemap extent scanning.
+  This bug also affects mv when it resorts to copying, and install.
   [bug introduced in coreutils-8.11]

   cp --no-preserve=mode now no longer preserves the original file's
--
1.8.0.rc2.11.gd25c58c




This bug report was last modified 6 years and 220 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.