Bug 171649

Summary: cpio: checksum error on 64-bit machines
Product: Red Hat Enterprise Linux 4 Reporter: Jim Castleberry <08z0adw02>
Component: cpioAssignee: Peter Vrabec <pvrabec>
Status: CLOSED ERRATA QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.0   
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2006-0305 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-04-19 19:00:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 187538    
Attachments:
Description Flags
Patch for vanilla cpio 2.6
none
my patch fixing this bug none

Description Jim Castleberry 2005-10-24 19:01:37 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915

Description of problem:
Package: cpio
Version: 2.6-7

[ The above pseudo-headers are for the Debian email bug reporting system. ]

Vanilla cpio 2.6 sometimes writes bad crcs in the cpio header on 64-bit machines.  It seems to
show up only on some large files.  The symptom is that the crc stored in the file appears to
be shifted by one nibble, and fails the crc check on copy-out.

For example using the Openoffice 2.0 release from openoffice.org mirrors, eg
    http://mirrors.ibiblio.org/pub/mirrors/openoffice/stable/2.0.0/OOo_2.0.0_LinuxIntel_install.tar.gz

  $ uname -a Linux centos 2.6.9-11.ELsmp #1 SMP Wed Jun 8 16:59:12 CDT 2005 x86_64 x86_64 x86_64 GNU/Linux
  $ cpio --version cpio (GNU cpio) 2.6
  $ echo OOo_2.0.0_LinuxIntel_install.tar.gz |cpio -o --format=crc >test.cpio
  207906 blocks
  $ cpio -i --only-verify-crc <test.cpio
  cpio: OOo_2.0.0_LinuxIntel_install.tar.gz: checksum error (0x32bf3b47, should be 0x332bf3b4)
  207906 blocks
  $

Doing the same thing on a 32-bit i386 machine running the same software works properly.
The only differences in the output file are in the c_maj, m_min, and c_chksum fields of
the cpio header.  All the other fields and the file data are the same and correct.

The cpio-2.5 that comes with the current Redhat EL (cpio-2.5-8.RHEL4) exhibits the
identical problem.

The bug was reported to Redhat by Michael J. Donahue in 1998 in cpio 2.4.2 on Redhat 4.1
for alpha:
    http://www.redhat.com/archives/axp-list/1998-March/msg00494.html
but apparently never addressed.

It was rediscovered by Tom Vier in 2001 2.4.2 on Debian and fixed by the debian folks:
    http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=100456
Looking at their patches for 2.4.2 at
    http://ftp.debian.org/pool/main/c/cpio/cpio_2.4.2-39woody1.diff.gz
the fix was in function write_out_header():
  @@ -60,7 +61,7 @@
   	       file_hdr->c_gid, file_hdr->c_nlink, file_hdr->c_mtime,
   	     file_hdr->c_filesize, file_hdr->c_dev_maj, file_hdr->c_dev_min,
   	   file_hdr->c_rdev_maj, file_hdr->c_rdev_min, file_hdr->c_namesize,
  -	       file_hdr->c_chksum);
  +	       file_hdr->c_chksum & 0xffffffff);
         tape_buffered_write (ascii_header, out_des, 110L);
   
         /* Write file name to output.  */

I applied that same change to the vanilla 2.6 copyout.c and it fixes the problem.
Patch is attached.

Note 1: The current Redhat ships cpio 2.5 with this defect.
Note 2: Debian carried the patch over to their patches for cpio 2.5 but seems to have
        dropped it from their patches for 2.6.  So I'd guess that their 2.6 has the same problem
        too, though I haven't tried it.


Version-Release number of selected component (if applicable):
cpio-2.5-8.RHEL4

How reproducible:
Always

Steps to Reproduce:
1. echo OOo_2.0.0_LinuxIntel_install.tar.gz |cpio -o --format=crc >test.cpio
2. cpio -i --only-verify-crc <test.cpio
3.
  

Actual Results:  cpio: OOo_2.0.0_LinuxIntel_install.tar.gz: checksum error (0x32bf3b47, should be 0x332bf3b4)
207906 blocks

Expected Results:  207906 blocks

Additional info:

Comment 1 Jim Castleberry 2005-10-24 19:03:08 UTC
Created attachment 120316 [details]
Patch for vanilla cpio 2.6

Comment 2 Peter Vrabec 2005-10-26 10:55:36 UTC
Your patch did not help me. Problem still persists.

cpio: OOo_2.0.0_LinuxIntel_install.tar.gz: checksum error (0x332bf3b47, should
be 0x32bf3b47)

It's because:
copyin.c:1585  
  if (crc != file_hdr.c_chksum)
crc is unsigned long and file_hdr.c_chksum is truncated by your patch.

Comment 3 Peter Vrabec 2005-10-26 10:59:11 UTC
Created attachment 120403 [details]
my patch fixing this bug

Comment 4 Jim Castleberry 2005-10-26 15:02:41 UTC
Peter, you're right.  My patch was incomplete.  Thanks.

Comment 13 Red Hat Bugzilla 2006-04-19 19:00:08 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2006-0305.html