Skip to content

Commit 91842ed

Browse files
committed
ata: libata-core: Set capacity to zero for a security locked drive
For Security locked drives (drives that have Security enabled, and have not been Security unlocked by boot firmware), the automatic partition scanning will result in the user being spammed with errors such as: ata5.00: failed command: READ DMA ata5.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 7 dma 4096 in res 51/04:08:00:00:00/00:00:00:00:00/e0 Emask 0x1 (device error) ata5.00: status: { DRDY ERR } ata5.00: error: { ABRT } sd 4:0:0:0: [sda] tag#7 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s sd 4:0:0:0: [sda] tag#7 Sense Key : Aborted Command [current] sd 4:0:0:0: [sda] tag#7 Add. Sense: No additional sense information during boot, because most commands except for IDENTIFY will be aborted by a Security locked drive. For a Security locked drive, set capacity to zero, so that no automatic partition scanning will happen. If the user later unlocks the drive using e.g. hdparm, the close() by the user space application should trigger a revalidation of the drive. Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Signed-off-by: Niklas Cassel <[email protected]>
1 parent b118906 commit 91842ed

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/ata/libata-core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,6 +3006,16 @@ int ata_dev_configure(struct ata_device *dev)
30063006
}
30073007

30083008
dev->n_sectors = ata_id_n_sectors(id);
3009+
if (ata_id_is_locked(id)) {
3010+
/*
3011+
* If Security locked, set capacity to zero to prevent
3012+
* any I/O, e.g. partition scanning, as any I/O to a
3013+
* locked drive will result in user visible errors.
3014+
*/
3015+
ata_dev_info(dev,
3016+
"Security locked, setting capacity to zero\n");
3017+
dev->n_sectors = 0;
3018+
}
30093019

30103020
/* get current R/W Multiple count setting */
30113021
if ((dev->id[47] >> 8) == 0x80 && (dev->id[59] & 0x100)) {

0 commit comments

Comments
 (0)