Re: [Tails-dev] Write protection Re: DVD vs. USB: doc needs …

Delete this message

Reply to this message
Author: flapflap
Date:  
To: tails-dev
Subject: Re: [Tails-dev] Write protection Re: DVD vs. USB: doc needs adjustments? [Fwd: [tor-talk] USB Sticks for Tails -> CCCamp]
spriver:
> Hi,
>
> [snip]
>> Suggestion: It would be great if it were possible to automatically
>> test if a USB storage device is *really* write protected. That
>> test could be executed while booting Tails and the user could be
>> informed about the result.
>
> How can this be performed? I'm interested in the technical procedure
> to achieve this.


Test procedure (Debian Jessie):
- Put SD Card *with Lock Switch enabled/locked* into computer
- $ sudo mount
  ...
  /dev/mmcblk0p1 on /media/myusr/disk type vfat
    (ro,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,...)
- $ cd /media/myusr/disk
- $ touch hello
  touch: cannot touch ‘hello’: Read-only file system
- $ sudo mount -o remount,rw /media/myusr/disk
  mount: cannot remount /dev/mmcblk0p1 read-write, is write-protected


So in this specific case it seems to work correctly (remains
write-protected). However, I believe to remember that some years ago I
was successful in getting a write-protected SD Card remounted
read-writeable. Maybe the driver has been fixed in the meantime or I
had a strange/uncommon system/setup.

The problem is that the "lock switch" on the SD Card is not an
electrical write-protect switch and is not connected to the
write-inhibit pin on the flash chip. It's merely a mechanical indicator
that the SD Card reader has to evaluate and that can be overriden in
software at any time (e.g., at the driver level).

Here's an open SD Card connector for reference:
https://www.reichelt.de/Connectoren-fuer-Speicherkarten/CONNECTOR-SD-21/3/index.html?ACTION=3&GROUPID=3768&ARTICLE=56476&OFFSET=16&

and the datasheet:
https://cdn-reichelt.de/documents/datenblatt/C130/CONNECTOR-SD21%23YAMAI.pdf

On the other hand, many (all?) NAND flash ICs actually offer an
electrical write-protect pin, so it's definetly possible to have a
working/effective switch on a USB stick. Example (not accessible via
Tor, because blocked by Farnell):
http://de.farnell.com/micron/nand01gw3b2cn6e/flash-nand-1gb-tsop48/dp/2065607

datasheet (works via Tor):
http://www.farnell.com/datasheets/1508775.pdf

"3.8 Write Protect (/WP)

The Write Protect pin is an input that gives a hardware protection
against unwanted program or erase operations. When Write Protect is Low,
VIL, the device does not accept any program or erase operations.

It is recommended to keep the Write Protect pin Low, VIL, during
power-up and power-down."

But of course we don't know for sure whether there is no other way to
override the write-protect pin. It would be easy for the manufacturers
to add a register to query and set the /WP pin/bit in software...

~flapflap