Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Oct 2000 10:15:08 GMT
From:      James Risner <risner@install.stdio.com>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/22347: dd copies incorrect data after 2^32 bytes and I/O error
Message-ID:  <200010271015.e9RAF8n02396@install.stdio.com>

next in thread | raw e-mail | index | archive | help

>Number:         22347
>Category:       bin
>Synopsis:       dd copies incorrect data after 2^32 bytes and I/O error
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 27 07:20:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     James Risner
>Release:        FreeBSD 4.1-STABLE i386
>Organization:
OpenWorld, Inc.
>Environment:

Copyright (c) 1992-2000 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
	The Regents of the University of California. All rights reserved.
FreeBSD 4.1-STABLE #0: Sun Sep 10 10:40:36 GMT 2000
    risner@install.stdio.com:/usr/obj/usr/src/sys/AKIRA
Timecounter "i8254"  frequency 1193182 Hz
CPU: AMD-K6(tm) 3D+ Processor (399.81-MHz 586-class CPU)
  Origin = "AuthenticAMD"  Id = 0x591  Stepping = 1
  Features=0x8021bf<FPU,VME,DE,PSE,TSC,MSR,MCE,CX8,PGE,MMX>
  AMD Features=0x80000800<SYSCALL,3DNow!>
real memory  = 100663296 (98304K bytes)
avail memory = 94384128 (92172K bytes)
Preloaded elf kernel "kernel" at 0xc0339000.
ccd0-3: Concatenated disk drivers
K6-family MTRR support enabled (2 registers)
md0: Malloc disk
npx0: <math processor> on motherboard
npx0: INT 16 interface
pcib0: <Host to PCI bridge> on motherboard
pci0: <PCI bus> on pcib0
isab0: <Intel 82371SB PCI to ISA bridge> at device 7.0 on pci0
isa0: <ISA bus> on isab0
atapci0: <Intel PIIX3 ATA controller> port 0xe800-0xe80f at device 7.1 on pci0
ata0: at 0x1f0 irq 14 on atapci0
ata1: at 0x170 irq 15 on atapci0
uhci0: <Intel 82371SB (PIIX3) USB controller> port 0xe400-0xe41f irq 12 at device 7.2 on pci0
usb0: <Intel 82371SB (PIIX3) USB controller> on uhci0
usb0: USB revision 1.0
uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
pci0: <Trident model 9750 VGA-compatible display device> at 10.0 irq 10
fxp0: <Intel Pro 10/100B/100+ Ethernet> port 0xe000-0xe03f mem 0xe5000000-0xe50fffff,0xe5800000-0xe5800fff irq 11 at device 11.0 on pci0
fxp0: Ethernet address 00:90:27:94:8b:87
fdc0: <NEC 72065B or clone> at port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on isa0
fdc0: FIFO enabled, 8 bytes threshold
fd0: <1440-KB 3.5" drive> on fdc0 drive 0
atkbdc0: <Keyboard controller (i8042)> at port 0x60,0x64 on isa0
atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0
kbd0 at atkbd0
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <6 virtual consoles, flags=0x300>
sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0
sio0: type 16550A
sio1 at port 0x2f8-0x2ff irq 3 on isa0
sio1: type 16550A
ppc0: <Parallel port> at port 0x378-0x37f irq 7 on isa0
ppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode
ppc0: FIFO with 16/16/16 bytes threshold
ppi0: <Parallel I/O> on ppbus0
lpt0: <Printer> on ppbus0
lpt0: Interrupt-driven port
ad0: 32253MB <IBM-DPTA-353750> [65531/16/63] at ata0-master using WDMA2
ata0-slave: DMA limited to UDMA33, non-ATA66 compliant cable
ad1: 25965MB <Maxtor 92720U8> [52755/16/63] at ata0-slave using WDMA2
ad2: 16479MB <Maxtor 91728D8> [33483/16/63] at ata1-master using WDMA2
ata1-slave: DMA limited to UDMA33, non-ATA66 compliant cable
ad3: 25965MB <Maxtor 92720U8> [52755/16/63] at ata1-slave using WDMA2
Mounting root from ufs:/dev/ad0s1a
pid 147 (dumpfs), uid 0: exited on signal 10 (core dumped)
ad3: HARD READ ERROR blk# 44391983 status=59 error=40

"$FreeBSD: src/bin/dd/dd.c,v 1.27.2.1 2000/08/07 08:30:17 ps Exp $";

"$FreeBSD: src/bin/dd/position.c,v 1.17.2.1 2000/08/07 08:30:17 ps Exp $";

/dev/ad3:
# /dev/ad3c:
type: ESDI
disk: wd3s1
label: busted disk2
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 16
sectors/cylinder: 1008
cylinders: 52754
sectors/unit: 53176977
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0		# milliseconds
track-to-track seek: 0	# milliseconds
drivedata: 0 

8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  c: 53176977        0    unused        0     0       	# (Cyl.    0 - 52754*)
  d: 39283345 13893632    4.2BSD     1024  8192    16 	# (Cyl. 13783*- 52754*)
  e: 13885440     8192     vinum                    	# (Cyl.    8*- 13783*)

/dev/ad1:
# /dev/ad1c:
type: ESDI
disk: wd1s1
label: good disk
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 16
sectors/cylinder: 1008
cylinders: 52754
sectors/unit: 53176977
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0		# milliseconds
track-to-track seek: 0	# milliseconds
drivedata: 0 

8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  c: 53176977        0    unused        0     0       	# (Cyl.    0 - 52754*)
  d: 39283345 13893632    4.2BSD     1024  8192    16 	# (Cyl. 13783*- 52754*)
  e: 13885440     8192     vinum                    	# (Cyl.    8*- 13783*)

>Description:

When using /bin/dd with bad sectors, /bin/dd truncates the seek location to 32 bits
after errors.

>How-To-Repeat:

	When /bin/dd copies data from a disk with an I/O error and the disk has
bad sectors more than 2^32 bytes into the file, dd does lseeks to skip the bad
sectors.  This lseek is not cast to off_t which causes it to be truncated at 32 bits.
This both causes dd to copy the wrong data.

>Fix:

*** dd.c.orig	Fri Oct 27 02:58:31 2000
--- dd.c	Fri Oct 27 03:02:03 2000
***************
*** 416,422 ****
  				if (pending != 0) {
  					if (force)
  						pending--;
! 					if (lseek(out.fd, pending, SEEK_CUR) ==
  					    -1)
  						err(2, "%s: seek error creating sparse file",
  						    out.name);
--- 416,422 ----
  				if (pending != 0) {
  					if (force)
  						pending--;
! 					if (lseek(out.fd, (off_t) pending, SEEK_CUR) ==
  					    -1)
  						err(2, "%s: seek error creating sparse file",
  						    out.name);
*** position.c.orig	Fri Oct 27 02:58:45 2000
--- position.c	Fri Oct 27 03:01:49 2000
***************
*** 70,76 ****
  	/* If known to be seekable, try to seek on it. */
  	if (in.flags & ISSEEK) {
  		errno = 0;
! 		if (lseek(in.fd, in.offset * in.dbsz, SEEK_CUR) == -1 &&
  		    errno != 0)
  			err(1, "%s", in.name);
  		return;
--- 70,76 ----
  	/* If known to be seekable, try to seek on it. */
  	if (in.flags & ISSEEK) {
  		errno = 0;
! 		if (lseek(in.fd, (off_t) (in.offset * in.dbsz), SEEK_CUR) == -1 &&
  		    errno != 0)
  			err(1, "%s", in.name);
  		return;
***************
*** 132,138 ****
  	 */
  	if (out.flags & (ISSEEK | ISPIPE)) {
  		errno = 0;
! 		if (lseek(out.fd, out.offset * out.dbsz, SEEK_CUR) == -1 &&
  		    errno != 0)
  			err(1, "%s", out.name);
  		return;
--- 132,138 ----
  	 */
  	if (out.flags & (ISSEEK | ISPIPE)) {
  		errno = 0;
! 		if (lseek(out.fd, (off_t) (out.offset * out.dbsz), SEEK_CUR) == -1 &&
  		    errno != 0)
  			err(1, "%s", out.name);
  		return;

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200010271015.e9RAF8n02396>