[Parted-maintainers] Bug#896171: parted wrongly identifies an msdos partition table as 'atari'

bouke_1 bouke_1 at zonnet.nl
Fri Apr 20 13:25:16 BST 2018


Package: parted
Version: 3.2-17


I have a valid & pretty standard Windows 10 system on a hard disk with 
three NTFS partitions: a small boot partition, a 465 GB main partition 
and a small restore partition. The structure is created by fsdisk from a 
Clonezilla live distribution. After the partitions are created, parted 
identifies my partition table as "atari" with a single partition. Any 
other tool I throw at it correctly sees an msdos partition table and I 
can boot windows 10 from the disk, so it appears there is nothing wrong 
with the disk. Also, it reproduces on 7 different PC's (albeit with 
pretty identical hardware).

I don't have a complete Debian system so my options are limited (no 
inernet access / reportbug), but this is the test I ran to reproduce the 
problem:

1.Run parted; it says I have an atari disk (even though it is a 
functional Windows 10 system) 2.Instruct parted to create a new dos 
partition table
3.Run parted; it says I have an msdos disk with no partitions (as 
expected)
4.Run sfdisk with sda-pt.sf from the Clonezilla image as input
5.sfdisk creates three NTFS partitions on the disk (as expected)
6.Run parted; it says I have an atari disk with one partition

See the full log at the end of this mail.

My understanding of the problem is that the code that makes parted 
recognize atari disks in isolated cases falsely indentifies a disk as 
Atari if the first blocks incidentally contain data that make (some) 
sense when interpreted as an Atari partition table. The chance of this 
happening is not high but also not zero (and apparently I got unlucky). 
See the parted list (Bug #31111 
http://lists.gnu.org/archive/html/bug-parted/2018-04/msg00003.html) for 
a more detailed analysis.

The chance of this happening should be zero because If I would use 
parted to change anything on this disk it would probably destroy all 
data on it (i.e., pretty critical).

FUN FACT: If I change the size of sda2 from 975028224 to (e.g.) 
975028222, the disk is no longer recognized as Atari & the problem 
vanishes.

Some info about my system:

I used the Clonezilla-live distribution alternate stable 
(clonezilla-live-2.5.2-31-i686)

> uname -a
Linux zesty 4.10.0-33-generic #37-Ubuntu SMP Fri Aug 11 10:53:59 UTC 
2017 i686 i686 i686 GNU/Linux

> dpkg --status parted
Package: parted
Status: install ok installed
Priority: optional
Section: admin
Installed-Size: 156
Maintainer: Ubuntu Developers <ubuntu-devel-discuss at lists.ubuntu.com>
Architecture: i386
Version: 3.2-17
Replaces: fsresize, parted1.6
Depends: libc6 (>= 2.11), libparted2 (= 3.2-17), libreadline7 (>= 6.0), 
libtinfo5 (>= 6)
Suggests: parted-doc
Conflicts: fsresize, parted1.6
Description: disk partition manipulator
[snip]
Original-Maintainer: Parted Maintainer Team 
<parted-maintainers at lists.alioth.debian.org>
Homepage: http://www.gnu.org/software/parted

sfdisk from util-linux 2.29

> dpkg --list util-linux
Desired=Unknown/Install/Remove/Purge/Hold
| 
Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version         Architecture Description
+++-==============-===============-============-=================================
ii  util-linux     2.29-1ubuntu2.1 i386         miscellaneous system 
utilities

NOTE:
I ran the same test from the GParted live distribution 
(gparted-live-0.31.0-1-i686), with the same results.
uname -a --> Linux Debian 4.15.0-1-686 #1 SMP Debian 4.15.4-1 
(2018-02-18) i686 GNU/Linux
/etc/debian_version: buster/sid
dpkg -- status parted: version 3.2-20.drbl1


/// LOG OF TEST PROCEDURE OUTLINED ABOVE ///
> sudo parted /dev/sda print

Model: ATA WDC WD5000AAKX-6 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: atari
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
  1      8323MB  14.8GB  6446MB  primary               boot

> sudo parted -s /dev/sda mklabel msdos
> sudo parted /dev/sda print

Model: ATA WDC WD5000AAKX-6 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start  End  Size  Type  File system  Flags

> sudo sfdisk --force /dev/sda

label: dos
label-id: 0x22a777ed
device: /dev/sda
unit: sectors

/dev/sda1 : start=        2048, size=      716800, type=17, bootable
/dev/sda2 : start=      718848, size=   975028224, type=7
/dev/sda3 : start=   975747072, size=     1024000, type=27
Checking that no-one is using this disk right now ... OK

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xcb89b023

Old situation:

Script header accepted.
Script header accepted.
Script header accepted.
Script header accepted.
Created a new DOS disklabel with disk identifier 0x22a777ed.

/dev/sda1: Created a new partition 1 of type 'Hidden HPFS/NTFS' and of 
size 350 MiB. /dev/sda2: Created a new partition 2 of type 
'HPFS/NTFS/exFAT' and of size 465 GiB. /dev/sda3: Created a new 
partition 3 of type 'Hidden NTFS WinRE' and of size 500 MiB. /dev/sda4: 
Done.

New situation:

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1  *         2048    718847    716800  350M 17 Hidden HPFS/NTFS
/dev/sda2          718848 975747071 975028224  465G  7 HPFS/NTFS/exFAT
/dev/sda3       975747072 976771071   1024000  500M 27 Hidden NTFS WinRE

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

> sudo parted /dev/sda print

Model: ATA WDC WD5000AAKX-6 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: atari
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
  1      8323MB  14.8GB  6446MB  primary               boot

// end



More information about the Parted-maintainers mailing list