[sane-devel] Partition table gets altered

Douglas Gilbert dgilbert@interlog.com
Wed, 28 Nov 2001 01:17:49 -0500


Jani Salonen wrote:
> 
> Hei,
> 
> I'm not sure is this problem caused by XSane or some SCSI module, but when I
> start XSane without my scanner (Epson perfection 1640) turned on or
> disconnected, the partition table of my HD messes up, and there is no any
> partitions visible anymore. although this can be fixed afterwards with fdisk,
> but is there any clue what really causes this? I've tried reproduce the
> problem with Adapted 29160 and Tekram 390F boards, and result is the same, a
> HD without a partition table. 2.4.7-10 kernel were used, with sym53??? (for
> Tekram) and aic7xxx (for Adaptec) SCSI modules.

Jani,
Ouch, the sg driver (or any pass through driver) 
could do a fair amount of damage if misdirected
(apart from to a CDROM, I guess). The PROCESSOR type 
(e.g. HP scanners) and SCANNER type (e.g. most other 
scanners) both have a SEND command whose operation 
code corresponds to a WRITE to a DIRECT ACCESS device 
(e.g. a disk). Permissions should be set so only root 
could do that sort of damage.

If SANE backends don't diligently check the device
INQUIRY details, then the core SANE scsi code may need
to do some filtering. 

OTOH there are some pathological things that can happen 
if a SANE driver caches device details, does not hold any 
sg fds thus allowing the sg driver to be unloaded, SCSI 
devices/adapters change, the sg driver is reloaded, ....

Doug Gilbert