lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 15 Jan 2021 22:03:25 -0500
From:   Michael Katzmann <vk2bea@...il.com>
To:     linux-kernel@...r.kernel.org
Subject: Changing sd device from read only to read/write fails in 5.10 (BLKROSET)

I have USB devices that have a write enable/write protect feature.
A vendor specific SCSI command write enables a write protected drive.
In kernels prior to 5.10 I have been able to write-enable the drive
(by sending the vendor specific command to the SCSI generic device)
and then change the read only state of the sd block device by clearing
the read only state with BLKROSET.

This code used to work to tell the kernel that the device is
read/write (once enabled at the SCSI level). As of kernel 5.10 it does
not.

--------------------------

// other routine opens SCSI generic device
// like /dev/sg1 and sends vendor specific commands to change
// device from read only to read/write.
// The bit in the SCSI Mode Sense is read to confirm device is R/W

int readOnly = 0;
DeviceFD = open( /dev/sdb, O_RDONLY );
// Clear the RO flag in the block device
rtn0 = ioctl( DeviceFD, BLKROSET, &readOnly );
// This re-reads the device so the OS knows that it is now write-enabled
rtn1 = ioctl( DeviceFD, BLKRRPART, 0 );
close( DeviceFD );
// not sure this is necessary
chmod( /dev/sdb, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);

if( (DeviceFD = open( /dev/sdb, O_RDWR )) == ERROR ) {
   printf("success\n"); // <== use to work (open R/W)
} else {
   printf("failure");   // <== now fails under kernel 5.10
}
close( DeviceFD );

--------------------------

Can anyone tell me if the setting of the R/W state of the block device
has changed or if the method of signaling to the system that the write
state has changed is different in 5.10?

Powered by blists - more mailing lists