Bug 797979

Summary: don't abort upon unexpected file system contents
Product: Red Hat Enterprise Linux 6 Reporter: Jim Meyering <meyering>
Component: partedAssignee: Brian Lane <bcl>
Status: CLOSED ERRATA QA Contact: Release Test Team <release-test-team-automation>
Severity: low Docs Contact:
Priority: low    
Version: 6.2CC: atodorov, bugzilla, jstodola
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: parted-2.1-19.el6 Doc Type: Bug Fix
Doc Text:
Cause: Unexpected HFS+ filesystem contents Consequence: parted would crash Fix: Added a number of checks for unexpected values to the HFS+ code. Result: parted doesn't crash.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 10:13:31 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: 840685    
Attachments:
Description Flags
reduced image based on one from Chris Murphy
none
new 'no abort' Apple Boot partition none

Description Jim Meyering 2012-02-27 17:37:58 UTC
Created attachment 566113 [details]
reduced image based on one from Chris Murphy

Description of problem: probing (meaning any operation) could provoke failed assertion.

Version-Release number of selected component (if applicable): parted-2.1-18.el6.x86_64

How reproducible: every time

Steps to Reproduce:
1. parted -s AppleBoot.img u s p
2.
3.
  
Actual results: abort


Expected results: no abort


Additional info:
The original .img file was a 620MB monstrosity.
I found that with only the first and last 14KB of data
and with everything else zeroed out, it's still reproducible,
so created a sparse file like that which occupied only ~30KB.
GNU tar's --sparse option encodes that sensibly, so I've attached
an equivalent compressed tarball that occupies only just 4KiB.

backtrace, a little analysis and patch posted here:
http://thread.gmane.org/gmane.comp.gnu.parted.bugs/10726/focus=10778

Comment 1 Chris Murphy 2012-02-27 22:47:55 UTC
Only reproducible with the single example partition instance Jim attached. Through regression, I have been unable to produce an Apple Boot partition that causes an abort. The Apple Boot JHFS+ file system is clean per Apple's fsck_hfs utility, so I'm just not sure what's unique about this partition, but it does not seem to be common or likely to be encountered in the real world.


Further regression details here:
http://lists.gnu.org/archive/html/bug-parted/2012-02/msg00076.html

Comment 2 Chris Murphy 2012-02-28 00:16:43 UTC
Created attachment 566163 [details]
new 'no abort' Apple Boot partition

This is the resulting partition after regression steps followed, does not induce a parted crash. Unclear what the difference is between this and original.

Comment 3 Brian Lane 2012-06-05 17:48:30 UTC
patch from the list referenced in comment 1

--- ../libparted/fs/hfs/probe.c.~1~	2012-02-26 13:46:33.357842027 -0500
+++ ../libparted/fs/hfs/probe.c	2012-02-26 13:47:30.069592361 -0500
@@ -156,8 +156,9 @@
 		search = ((PedSector) PED_BE32_TO_CPU (vh->total_blocks) - 1)
 		      * ( PED_BE32_TO_CPU (vh->block_size) / PED_SECTOR_SIZE_DEFAULT )
 		      - 1;
-		if (!ped_geometry_set (geom_ret, geom_ret->start,
-					       search + 2)
+		if (search < 0
+		    || !ped_geometry_set (geom_ret, geom_ret->start,
+					  search + 2)
 		    || !ped_geometry_read (geom_ret, buf, search, 1)
 		    || vh->signature != PED_CPU_TO_BE16 (HFSP_SIGNATURE)) {
 		    	ped_geometry_destroy (geom_ret);

Comment 4 RHEL Program Management 2012-07-16 22:47:21 UTC
This request was evaluated by Red Hat Product Management for
inclusion in a Red Hat Enterprise Linux release.  Product
Management has requested further review of this request by
Red Hat Engineering, for potential inclusion in a Red Hat
Enterprise Linux release for currently deployed products.
This request is not yet committed for inclusion in a release.

Comment 6 Jan Stodola 2013-01-03 12:54:45 UTC
Reproduced with parted-2.1-18.el6:

[root@rtt7 ~]# parted -s AppleBoot.img u s p
Backtrace has 13 calls on stack:
  13: /lib64/libparted-2.1.so.0(ped_assert+0x32) [0x3fffd734316]
  12: /lib64/libparted-2.1.so.0(ped_geometry_read+0xc8) [0x3fffd73c5dc]
  11: /lib64/libparted-2.1.so.0(hfsplus_probe+0x1ae) [0x3fffd7574fa]
  10: /lib64/libparted-2.1.so.0(ped_file_system_probe_specific+0x7e) [0x3fffd735ba6]
  9: /lib64/libparted-2.1.so.0(ped_file_system_probe+0x82) [0x3fffd73611e]
  8: /lib64/libparted-2.1.so.0(+0x51614) [0x3fffd770614]
  7: /lib64/libparted-2.1.so.0(ped_disk_probe+0xbe) [0x3fffd73bb76]
  6: /lib64/libparted-2.1.so.0(ped_disk_new+0x40) [0x3fffd73bc1c]
  5: parted() [0x80007ac4]
  4: parted(non_interactive_mode+0xa2) [0x8000e02a]
  3: parted(main+0x7e) [0x8000c26e]
  2: /lib64/libc.so.6(__libc_start_main+0x120) [0x3fffd5138c4]
  1: parted() [0x80005e72]
Aborted (core dumped)
[root@rtt7 ~]#

Verified with parted-2.1-19.el6:

[root@rtt7 ~]# parted -s AppleBoot.img u s p
Error: /root/AppleBoot.img: unrecognised disk label
[root@rtt7 ~]#

Moving to VERIFIED.

Comment 8 errata-xmlrpc 2013-02-21 10:13:31 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-0407.html