This is a discussion on Change file mounted via loop device within the Linux Security forums, part of the System Security and Security Related category; I have the following problem: due to the security reasons I'd like to make a partition unreadable for other ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have the following problem: due to the security reasons I'd like to
make a partition unreadable for other persons even if they will switch off the power, take my hard disk and install on their workplace. I did not want to use crypto apis cause they could be slow. My idea was to create a file, bind it to the loop device, mount and then change first X bytes with the random data. And replace them with the correct ones before mounting and umounting and then change back to random. I got the stange (but probably correct) behaviour: if I change the file after mounting, all the changes could be discarded under unknown rules - they could be new random now and when I view the file in 1 second, it contains the old correct data. So it stores somewhere the correct beginning? My question is: how I can reach my goal, probably using other ways. But it would be also very interesting why it behaves so and where I can read what actually is done when mounting files using loop devices and why it restores them. Thanks A. |
|
|||
|
In comp.os.linux.security, you wrote:
> I have the following problem: due to the security reasons I'd like to > make a partition unreadable for other persons even if they will switch > off the power, take my hard disk and install on their workplace. This is a classic application of encryption. > I did > not want to use crypto apis cause they could be slow. My idea was to > create a file, bind it to the loop device, mount and then change first > X bytes with the random data. And replace them with the correct ones > before mounting and umounting and then change back to random. This is not secure. Anyone with minimal ability to directly read the (loop image) file would have access to everything. Changing the first X bytes with random data is analagous to removing the address numbers from your home. Legitimate visitors will be inconvenienced as they search for your missing address. Intruders will be aided since they need fear few interruptions by legitimate users. > I got the stange (but probably correct) behaviour: if I change the > file after mounting, all the changes could be discarded under unknown > rules - they could be new random now and when I view the file in 1 > second, it contains the old correct data. > So it stores somewhere the correct beginning? I suspect that you are using a 'journaling' or fault-tolerant filesystem like ext3 or reiserfs. This filesystem feature saves "forward error correction" data in order to recover from disk corruption. The system presumably thought the hard disk block was corrupt, copied and corrected your data to an unused block and marked the old block 'bad'. As your disk ages, you normally accumulate 'bad blocks'. Your deliberate corruption will rapidly 'age' the disk without giving you security. > My question is: how I can reach my goal, probably using other ways. > But it would be also very interesting why it behaves so and where I > can read what actually is done when mounting files using loop devices > and why it restores them. You have many choices. The simplest is to use gpg(1). Starting with: # image.loop - original clear image of data # non-structured filesystem - not ext3 nor reiserfs nor ... To setup: # Provide your choice of passphrase bash> gpg --openpgp --symmetric -o image.loop.gpg image.loop # Remove clear image bash> shred image.loop To use: bash> gpg -o image.loop < image.loop.gpg bash> mount -t ... -o loop==/dev/loop... image.loop /mnt # Use /mnt as desired bash> umount /mnt bash> gpg --openpgp --symmetric -o image.loop.gpg image.loop bash> shred image.loop Be advised that shred will wear out your disk ~20x faster than normal file access. For small files, I happily use emacs + crypt++. Hopefully helpful, -- Dr. Robert J. Meier Server Vantage Agent Infrastructure |