macsat.com OpenWrt and ASUS WL Forum
January 08, 2009, 14:48:50 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?
Login with username, password and session length
News: Back to macsat.com
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Horrendous BUG in firmware deletes ext3 partition  (Read 1402 times)
0 Members and 1 Guest are viewing this topic.
sanecyclist
Newbie
*
Offline Offline

Posts: 45


View Profile
« on: April 21, 2007, 16:44:33 PM »

When connecting a partition formatted with ext3, and possibly other formats that aren't ext2, vfat, or ntfs, the firmware might end up deleting the entire contents of the partition!

I experienced this after I disabled the 'autoinit' on my Debian partition and rebooted into the firmware. I telnetted in, and a little while later noticed that the hard disk was rather busy, so I did a 'ps x', and to my horror saw a 'rm -rf /mnt/USB/USB_D'. I killed it as quickly as I could, but it had already deleted the copy of my music collection I had on that ext3-formatted data partition.

It looks like the bug is in /bin/hotplug.sh. It first tries to mount a partition as ext2, then as vfat, then as ntfs, and if it fails it just 'rm -rf's the whole directory it tried to mount it to! Presumably the ext3 partition actually was mounted as ext2, but for some reason it still fell through the test for that.

I also noticed that both partitions on the disk were mounted multiple times. Could that be the problem? Pagano, could the mount attempts in the init script have something to do with this?
Logged
pagano
Jr. Member
**
Offline Offline

Posts: 61


View Profile
« Reply #1 on: April 22, 2007, 01:51:31 AM »

rm -rf $DIR/$DEV$Disk in hotplug.sh Shocked  Shocked # commented #

partitions on the disk were mounted multiple times
Partitions can be mounted multiple times with a bad autoexec/autoinit or rc.d/* scripts making a recursive loop.
The init script "mount, test and unmount" partitions and it start the new root with only ram0 and the new root mounted.

In V4 autoexec is called after rc.bridge (last lines) like in V1 version and i have not tested with V3 filesystem.
Autoexec is executed twoice if founded at sda1 and hda1 with devices already mounted. ¿How many times are mounted?
Logged
sanecyclist
Newbie
*
Offline Offline

Posts: 45


View Profile
« Reply #2 on: April 22, 2007, 06:47:08 AM »

Unfortunately I'm not sure how many times the partitions were mounted, but I think it was three. I'm rather reluctant now to try it again, so I reactivated 'autoinit' to bypass the firmware and boot into Debian at the earliest possibility. (This works a treat btw, thanks again!)

Also converted the ext3 partition back to ext2, in case that was the problem. Then again, ext3 is fully backwards compatible with ext2, isn't it? Which could mean that ext2 partitions are at risk too.

The setup was no internal disk, a USB hard disk with an ext2, a swap, and an ext3 partition, and a Topfield PVR. No autoexec or autoinit on the disk. Perhaps the problem occurred when hotplug.sh was invoked for the PVR?

Could the bug be fixed by replacing 'rm -rf' with 'rmdir', since that doesn't recurse into non-empty directories?
Logged
tcc1000
Newbie
*
Offline Offline

Posts: 20


View Profile
« Reply #3 on: April 22, 2007, 15:21:54 PM »

I've had problems with ext3 as well. I thought ext3 was only (optional) extensions to ext2 - but often found filesystem errors when I checked it on another system. I think hotplug comes from the original firmware - it mounts the drives twice to put them in places to share - different for samba and ftp - not particularly well thought out. I guess the rm is an attempt to clean the mount point up, in which case rmdir would do fine. I often get left over mount points from reboots - the orignal firmware wouldn't have had this problem as the filesystem would not be stored between reboots.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

English Steel 1.6 © Saxon North Technologies
Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
Joomla Bridge by JoomlaHacks.com
Valid XHTML 1.0! Valid CSS!
Page created in 0.261 seconds with 24 queries.