martijnvanbrummelen / nwipe

nwipe secure disk eraser
GNU General Public License v2.0
707 stars 80 forks source link

Consider increasing the assertion that HDD serial numbers are limited to 20 bytes. #547

Open rawhide-kobayashi opened 7 months ago

rawhide-kobayashi commented 7 months ago

As described in this line, HDD serial numbers may be no more than 20 bytes. If this constraint is violated, nwipe will exit with a buffer overflow. https://github.com/martijnvanbrummelen/nwipe/blob/2fae6ea5f5e5d22b3db2673c88d820dc5701676d/src/context.h#L83

I have some disks from a dodgy liquidation store that seems to have attempted to flash their own serial numbers onto the drives, resulting in a serial number appended to another serial number with a rather large whitespace gap between them, that doesn't get trimmed by the current code, that is 30 bytes long in total. Increasing this one line from 20 to 30 and recompiling fixed the issue on my machine. Probably a pretty rare problem to have, and idk if there's any performance/other reason to keep it set at 20, but this is a thing that just happened to me.

PartialVolume commented 7 months ago

Have you still got that drive available? If so any chance you can download the master again, once I've patched it this afternoon and try again. While the increase to 30 might fix it, the ata specs state 20 character string for serial number. There is a strcpy in the code which I've just replaced, maybe that was overflowing.

Can you post the nwipe log and the serial number of the drive. Seems real odd to have a load of white space in the middle. They are supposed to left justify the serial number and pad with spaces to 20 characters if they following the ata standard.

rawhide-kobayashi commented 7 months ago

Here is a log directly from nwipe and a stack trace.

nwipeint.log

nwipe_strace.log

Here are a few serial numbers.

001528PKYRHV        2EGKYRHV

001525PGKMRV        2EGGKMRV

001619PEP8RV        VKJEP8RV

Like I said, I bought them from a liquidator, so I can only assume that either they themselves, or whatever vendor originally produced the setup they liquidated are at fault for this. I've bought plenty of other drives from them that had normal serial numbers, but a particular series of drives of the same model all seem to have this odd pattern. And I can't ask them as they are now defunct.

PartialVolume commented 7 months ago

I have some disks from a dodgy liquidation store that seems to have attempted to flash their own serial numbers onto the drives, resulting in a serial number appended to another serial number with a rather large whitespace gap between them.

The strings such as model and serial number stored in a drive are not generally null terminated in the drive. So for instance the 20 characters allocated in the drive for serial number could be immediately followed by some other string, with no separator so by expanding the storage in nwipe to 30 characters you are just reading some other field. What I need to determine is why it would buffer overflow with the serial number set to 20+1 (the +1 is for the terminator.)

That strace was very useful, thanks. I've changed a couple of strcpys to strncpys that might have caused a buffer overflow, however, the nwipe log showed that you were running 0.35 and a commit #527 (0.35.1+) would have fixed a number of potential buffer overflow issues in exactly the area of code that the strace indicated.

Can you try downloading the latest master version 0.35.9 and see if it still segfaults. I'm expecting it to work fine, but we'll see. Thanks.

rawhide-kobayashi commented 7 months ago

Indeed, the current master does not overflow. However, the view of the serial number field is truncated compared to the modification I made. Certainly a much less severe issue!

image image

PartialVolume commented 7 months ago

Is there any evidence to suggest that 2EGKYRHV is part of the serial number?

The vendor has padded the first number with spaces to what looks like 20 characters, which would be consistent with how the serial is supposed to be written according to the SCSI command reference. If it doesn't occupy all 20 characters it should be right padded with spaces. If no serial number all 20 characters should be spaces.

What does smartctl -a /dev/sde recognise the serial number as?

PartialVolume commented 7 months ago

That 2EGKYRHV looks like it could be the last 8 digits of another drive you were wiping at the same time? Strange that the last 5 digits of both numbers are the same.

rawhide-kobayashi commented 7 months ago

Looks like I accidentally copied the same string twice. The first part is the same too!

Smartctl lists the entire given string in the serial number field. The people I bought them from also listed the extranous characters as the drive's serial numbers on the packaging that they were shipped in.

image

PartialVolume commented 7 months ago

Can you also post the output of hdparm -I /dev/xxx

Thanks.

PartialVolume commented 7 months ago

Sorry, correction to my previous message, can you run this command hdparm -I --verbose /dev/xxx on one of those drives and post the output. This will return the command used and raw returned data from the drive, which may help me to figure out whether smartctl is correctly returning the serial number as written by the vendor or whether there is a bug in smartctl or some other cause. The output below is the sort of thing you should expect to see with a few fields of hex data.

sudo hdparm -I --verbose /dev/sda

/dev/sda:
APT: USB ID = 0x095b:0x0305 (0x001)
APT: Unsupported device
outgoing cdb:  85 08 0e 00 00 00 01 00 00 00 00 00 00 40 ec 00
SG_IO: ATA_16 status=0x0, host_status=0x0, driver_status=0x0
SG_IO: sb[]:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
incoming_data:  5a 0c ff 3f 37 c8 10 00 00 00 00 00 3f 00 00 00 00 00 00 00 20 20 20 20 20 20 20 20 20 20 20 20 44 57 37 5a 41 48 41 50 00 00 00 00 00 00 44 53 31 4d 20 20 20 20 54 53 30 32 30 30 4d 4c 31 30 2d 35 45 32 31 38 34 37 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 80 00 40 00 2f 00 40 00 02 00 02 07 00 ff 3f 10 00 3f 00 10 fc fb 00 10 01 ff ff ff 0f 00 00 07 00 03 00 78 00 78 00 78 00 78 00 00 01 00 00 00 00 00 00 00 00 00 00 1f 00 0e 8f 06 00 6c 00 44 00 f0 07 1f 00 6b 74 69 7d 63 61 69 74 49 bc 63 61 7f 40 a2 00 a2 00 80 80 fe ff 00 00 d0 d0 00 00 00 00 00 00 00 00 00 00 b0 88 e0 e8 00 00 00 00 00 00 00 00 03 60 00 00 00 50 00 c5 f2 aa c8 ca 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1e 40 1c 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 21 00 b0 88 e0 e8 b0 88 e0 e8 20 20 02 00 40 01 00 01 00 50 06 3c 0a 3c 00 00 3c 00 00 00 08 00 00 00 00 00 ff bd 80 02 00 00 00 00 08 00 00 00 00 00 27 00 28 10 00 80 00 40 00 01 00 a5 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 30 00 00 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 15 00 00 00 00 00 00 00 00 7f 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 a5 f1
SG_IO: desc[]:  00 00
      ATA_16 stat=00 err=00 nsect=00 lbal=00 lbam=00 lbah=00 dev=00

ATA device, with non-removable media
        Model Number:       ST2000LM015-2E8174                      
        Serial Number:      WDZ7HAPA
        Firmware Revision:  SDM1    
        Transport:          Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Standards:
        Used: unknown (minor revision code 0x001f) 
        Supported: 10 9 8 7 6 5 
        Likely used: 10
Configuration:
        Logical         max     current
        cylinders       16383   16383
        heads           16      16
        sectors/track   63      63
        --
        CHS current addressable sectors:    16514064
        LBA    user addressable sectors:   268435455
        LBA48  user addressable sectors:  3907029168
        Logical  Sector size:                   512 bytesoflags.bits.lob_all=0xfc, flags={ nsect lbal lbam lbah dev command }
oflags.bits.hob_all=0x3c, flags={ nsect lbal lbam lbah }
using LBA48 taskfile
outgoing cdb:  85 09 0e 00 00 00 01 00 00 00 00 00 00 e0 2f 00
SG_IO: ATA_16 status=0x0, host_status=0x0, driver_status=0x0
SG_IO: sb[]:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
incoming_data:  01 00 00 00 00 00 05 00 08 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 01 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 10 00 00 00 18 00 e0 1f 00 00 00 00 00 00 00 00 00 00 88 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 d8 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff ff ff ff 01 00 10 00 f0 00 08 00 18 00 00 00 00 00 00 00 00 00 01 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SG_IO: desc[]:  00 00
      ATA_16 stat=00 err=00 nsect=00 lbal=00 lbam=00 lbah=00 dev=00

        Physical Sector size:                  4096 bytes
        Logical Sector-0 offset:                  0 bytes
        device size with M = 1024*1024:     1907729 MBytes
        device size with M = 1000*1000:     2000398 MBytes (2000 GB)
        cache/buffer size  = unknown
        Form Factor: 2.5 inch
        Nominal Media Rotation Rate: 5400
Capabilities:
        LBA, IORDY(can be disabled)
        Queue depth: 32
        Standby timer values: spec'd by Standard, no device specific minimum
        R/W multiple sector transfer: Max = 16  Current = 16
        Advanced power management level: 128
        Recommended acoustic management value: 208, current value: 208
        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
             Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4 
             Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
        Enabled Supported:
           *    SMART feature set
                Security Mode feature set
           *    Power Management feature set
           *    Write cache
           *    Look-ahead
           *    Host Protected Area feature set
           *    WRITE_BUFFER command
           *    READ_BUFFER command
           *    NOP cmd
           *    DOWNLOAD_MICROCODE
           *    Advanced Power Management feature set
                Power-Up In Standby feature set
           *    SET_FEATURES required to spinup after power up
                SET_MAX security extension
           *    48-bit Address feature set
           *    Device Configuration Overlay feature set
           *    Mandatory FLUSH_CACHE
           *    FLUSH_CACHE_EXT
           *    SMART error logging
           *    SMART self-test
           *    General Purpose Logging feature set
           *    WRITE_{DMA|MULTIPLE}_FUA_EXT
           *    64-bit World wide name
           *    IDLE_IMMEDIATE with UNLOAD
                Write-Read-Verify feature set
           *    WRITE_UNCORRECTABLE_EXT command
           *    {READ,WRITE}_DMA_EXT_GPL commands
           *    Segmented DOWNLOAD_MICROCODE
           *    Gen1 signaling speed (1.5Gb/s)
           *    Gen2 signaling speed (3.0Gb/s)
           *    Gen3 signaling speed (6.0Gb/s)
           *    Native Command Queueing (NCQ)
           *    Host-initiated interface power management
           *    Phy event counters
           *    Idle-Unload when NCQ is active
           *    READ_LOG_DMA_EXT equivalent to READ_LOG_EXT
           *    DMA Setup Auto-Activate optimization
                Device-initiated interface power management
                Asynchronous notification (eg. media change)
           *    Software settings preservation
           *    SMART Command Transport (SCT) feature set
           *    SCT Write Same (AC2)
           *    SCT Features Control (AC4)
           *    SCT Data Tables (AC5)
                unknown 206[12] (vendor specific)
                unknown 206[13] (vendor specific)
           *    DOWNLOAD MICROCODE DMA command
Security: 
        Master password revision code = xxxxx
                supported
        not     enabled
        not     locked
        not     frozen
        not     expired: security count
                supported: enhanced erase
        324min for SECURITY ERASE UNIT. 324min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 5000c500aaf2cac8
        NAA             : 5
        IEEE OUI        : 000c50
        Unique ID       : 0aaf2cac8
Checksum: correct
rawhide-kobayashi commented 7 months ago

Well, with hdparm I get nothing useful. It seems hdparm doesn't work with SAS drives. However, sgdisk does return the same information as smartctl.

sginfo -A /dev/disk/by-id/scsi-35000cca254899138
INQUIRY response (cmd: 0x12)
----------------------------
Device Type                        0
Vendor:                    HGST
Product:                   H7280A520SUN8.0T
Revision level:            PD51

Serial Number '001619PENBJV        VKJENBJV'

Read-Write Error Recovery mode page (0x1)
-----------------------------------------
AWRE                               1
ARRE                               1
TB                                 0
RC                                 0
EER                                0
PER                                1
DTE                                0
DCR                                0
Read Retry Count                   1
Correction Span                    0
Head Offset Count                  0
Data Strobe Offset Count           0
Write Retry Count                  1
Recovery Time Limit (ms)           0

Disconnect-Reconnect mode page (0x2)
------------------------------------
Buffer full ratio                  0
Buffer empty ratio                 0
Bus Inactivity Limit (SAS: 100us)  0
Disconnect Time Limit              0
Connect Time Limit (SAS: 100us)    0
Maximum Burst Size                 314
EMDP                               0
Fair Arbitration (fcp:faa,fab,fac) 0
DIMM                               0
DTDC                               0
First Burst Size                   0

Format Device mode page (0x3)
-----------------------------
Tracks per Zone                    8699
Alternate sectors per zone         0
Alternate tracks per zone          0
Alternate tracks per lu            0
Sectors per track                  465
Data bytes per physical sector     4160
Interleave                         1
Track skew factor                  100
Cylinder skew factor               24
Supports Soft Sectoring            0
Supports Hard Sectoring            1
Removable Medium                   0
Surface                            0

Rigid Disk Geometry mode page (0x4)
-----------------------------------
Number of cylinders                392300
Number of heads                    14
Starting cyl. write precomp        0
Starting cyl. reduced current      0
Device step rate                   0
Landing Zone Cylinder              0
RPL                                0
Rotational Offset                  0
Rotational Rate                    7200

Verify Error Recovery mode page (0x7)
-------------------------------------
EER                                0
PER                                0
DTE                                0
DCR                                0
Verify Retry Count                 1
Verify Correction Span (bits)      0
Verify Recovery Time Limit (ms)    0

Caching mode page (0x8)
-----------------------
Initiator Control                  0
ABPF                               0
CAP                                0
DISC                               0
SIZE                               0
Write Cache Enabled                0
MF                                 0
Read Cache Disabled                0
Demand Read Retention Priority     0
Demand Write Retention Priority    0
Disable Pre-fetch Transfer Length  65535
Minimum Pre-fetch                  0
Maximum Pre-fetch                  65535
Maximum Pre-fetch Ceiling          65535
FSW                                0
LBCSS                              0
DRA                                0
NV_DIS                             0
Number of Cache Segments           8
Cache Segment size                 0
Non-Cache Segment size             0

Control mode page (0xa)
-----------------------
TST                                0
TMF_ONLY                           0
D_SENSE                            1
GLTSD                              0
RLEC                               0
Queue Algorithm Modifier           0
QErr                               0
DQue [obsolete]                    0
TAS                                0
RAC                                0
UA_INTLCK_CTRL                     0
SWP                                0
RAERP [obs.]                       0
UAAERP [obs.]                      0
EAERP [obs.]                       0
ATO                                1
TAS                                0
AUTOLOAD MODE                      0
Ready AER Holdoff Period [obs.]    0
Busy Timeout Period                0
Extended self-test completion time 65535

Control Extension mode subpage (0xa,0x1)
--------------------------------------------
TCMOS                              0
SCSIP                              0
IALUAE                             0
Initial Priority                   0

mode page: 0x0a  subpage: 0x02
------------------------------
0x04                               0x00
0x05                               0x00
0x06                               0x00
0x07                               0x00
0x08                               0x00
0x09                               0x00
0x0a                               0x00
0x0b                               0x00
0x0c                               0x00
0x0d                               0x00
0x0e                               0x00
0x0f                               0x00
0x10                               0x80
0x11                               0x00
0x12                               0x00
0x13                               0x00
0x14                               0x00
0x15                               0x00
0x16                               0xff
0x17                               0xff
0x18                               0x00
0x19                               0x00
0x1a                               0x00
0x1b                               0x00
0x1c                               0x00
0x1d                               0x00
0x1e                               0x00
0x1f                               0x00
0x20                               0xff
0x21                               0xff
0x22                               0xff
0x23                               0xff
0x24                               0xff
0x25                               0xff
0x26                               0xff
0x27                               0xff
0x28                               0x00
0x29                               0x00
0x2a                               0x00
0x2b                               0x00
0x2c                               0x00
0x2d                               0x00
0x2e                               0x00
0x2f                               0x00
0x30                               0x00
0x31                               0x00
0x32                               0x00
0x33                               0x00
0x34                               0x00
0x35                               0x00
0x36                               0x00
0x37                               0x00
0x38                               0x00
0x39                               0x00
0x3a                               0x00
0x3b                               0x00
0x3c                               0x00
0x3d                               0x00
0x3e                               0x00
0x3f                               0x00
0x40                               0x00
0x41                               0x00
0x42                               0x00
0x43                               0x00
0x44                               0x00
0x45                               0x00
0x46                               0x00
0x47                               0x00
0x48                               0x00
0x49                               0x00
0x4a                               0x00
0x4b                               0x00
0x4c                               0x00
0x4d                               0x00
0x4e                               0x00
0x4f                               0x00
0x50                               0x00
0x51                               0x00
0x52                               0x00
0x53                               0x00
0x54                               0x00
0x55                               0x00
0x56                               0x00
0x57                               0x00
0x58                               0x00
0x59                               0x00
0x5a                               0x00
0x5b                               0x00
0x5c                               0x00
0x5d                               0x00
0x5e                               0x00
0x5f                               0x00
0x60                               0x00
0x61                               0x00
0x62                               0x00
0x63                               0x00
0x64                               0x00
0x65                               0x00
0x66                               0x00
0x67                               0x00
0x68                               0x00
0x69                               0x00
0x6a                               0x00
0x6b                               0x00
0x6c                               0x00
0x6d                               0x00
0x6e                               0x00
0x6f                               0x00
0x70                               0x00
0x71                               0x00
0x72                               0x00
0x73                               0x00
0x74                               0x00
0x75                               0x00
0x76                               0x00
0x77                               0x00
0x78                               0x00
0x79                               0x00
0x7a                               0x00
0x7b                               0x00
0x7c                               0x00
0x7d                               0x00
0x7e                               0x00
0x7f                               0x00
0x80                               0x00
0x81                               0x00
0x82                               0x00
0x83                               0x00
0x84                               0x00
0x85                               0x00
0x86                               0x00
0x87                               0x00
0x88                               0x00
0x89                               0x00
0x8a                               0x00
0x8b                               0x00
0x8c                               0x00
0x8d                               0x00
0x8e                               0x00
0x8f                               0x00
0x90                               0x00
0x91                               0x00
0x92                               0x00
0x93                               0x00
0x94                               0x00
0x95                               0x00
0x96                               0x00
0x97                               0x00
0x98                               0x00
0x99                               0x00
0x9a                               0x00
0x9b                               0x00
0x9c                               0x00
0x9d                               0x00
0x9e                               0x00
0x9f                               0x00
0xa0                               0x00
0xa1                               0x00
0xa2                               0x00
0xa3                               0x00
0xa4                               0x00
0xa5                               0x00
0xa6                               0x00
0xa7                               0x00
0xa8                               0x00
0xa9                               0x00
0xaa                               0x00
0xab                               0x00
0xac                               0x00
0xad                               0x00
0xae                               0x00
0xaf                               0x00
0xb0                               0x00
0xb1                               0x00
0xb2                               0x00
0xb3                               0x00
0xb4                               0x00
0xb5                               0x00
0xb6                               0x00
0xb7                               0x00
0xb8                               0x00
0xb9                               0x00
0xba                               0x00
0xbb                               0x00
0xbc                               0x00
0xbd                               0x00
0xbe                               0x00
0xbf                               0x00
0xc0                               0x00
0xc1                               0x00
0xc2                               0x00
0xc3                               0x00
0xc4                               0x00
0xc5                               0x00
0xc6                               0x00
0xc7                               0x00
0xc8                               0x00
0xc9                               0x00
0xca                               0x00
0xcb                               0x00
0xcc                               0x00
0xcd                               0x00
0xce                               0x00
0xcf                               0x00
0xd0                               0x00
0xd1                               0x00
0xd2                               0x00
0xd3                               0x00
0xd4                               0x00
0xd5                               0x00
0xd6                               0x00
0xd7                               0x00
0xd8                               0x00
0xd9                               0x00
0xda                               0x00
0xdb                               0x00
0xdc                               0x00
0xdd                               0x00
0xde                               0x00
0xdf                               0x00
0xe0                               0x00
0xe1                               0x00
0xe2                               0x00
0xe3                               0x00
0xe4                               0x00
0xe5                               0x00
0xe6                               0x00
0xe7                               0x00
0xe8                               0x00
0xe9                               0x00
0xea                               0x00
0xeb                               0x00
0xec                               0x00
0xed                               0x00
0xee                               0x00
0xef                               0x00
0xf0                               0x00
0xf1                               0x00
0xf2                               0x00
0xf3                               0x00
0xf4                               0x00
0xf5                               0x00
0xf6                               0x00
0xf7                               0x00
0xf8                               0x00
0xf9                               0x00
0xfa                               0x00
0xfb                               0x00
0xfc                               0x00
0xfd                               0x00
0xfe                               0x00
0xff                               0x00
0x100                              0x00
0x101                              0x00
0x102                              0x00
0x103                              0x00
0x104                              0x00
0x105                              0x00
0x106                              0x00
0x107                              0x00
0x108                              0x00
0x109                              0x00
0x10a                              0x00
0x10b                              0x00
0x10c                              0x00
0x10d                              0x00
0x10e                              0x00
0x10f                              0x00
0x110                              0x00
0x111                              0x00
0x112                              0x00
0x113                              0x00
0x114                              0x00
0x115                              0x00
0x116                              0x00
0x117                              0x00
0x118                              0x00
0x119                              0x00
0x11a                              0x00
0x11b                              0x00
0x11c                              0x00
0x11d                              0x00
0x11e                              0x00
0x11f                              0x00
0x120                              0x00
0x121                              0x00
0x122                              0x00
0x123                              0x00
0x124                              0x00
0x125                              0x00
0x126                              0x00
0x127                              0x00
0x128                              0x00
0x129                              0x00
0x12a                              0x00
0x12b                              0x00
0x12c                              0x00
0x12d                              0x00
0x12e                              0x00
0x12f                              0x00
0x130                              0x00
0x131                              0x00
0x132                              0x00
0x133                              0x00
0x134                              0x00
0x135                              0x00
0x136                              0x00
0x137                              0x00
0x138                              0x00
0x139                              0x00
0x13a                              0x00
0x13b                              0x00
0x13c                              0x00
0x13d                              0x00
0x13e                              0x00
0x13f                              0x00
0x140                              0x00
0x141                              0x00
0x142                              0x00
0x143                              0x00
0x144                              0x00
0x145                              0x00
0x146                              0x00
0x147                              0x00
0x148                              0x00
0x149                              0x00
0x14a                              0x00
0x14b                              0x00
0x14c                              0x00
0x14d                              0x00
0x14e                              0x00
0x14f                              0x00
0x150                              0x00
0x151                              0x00
0x152                              0x00
0x153                              0x00
0x154                              0x00
0x155                              0x00
0x156                              0x00
0x157                              0x00
0x158                              0x00
0x159                              0x00
0x15a                              0x00
0x15b                              0x00
0x15c                              0x00
0x15d                              0x00
0x15e                              0x00
0x15f                              0x00
0x160                              0x00
0x161                              0x00
0x162                              0x00
0x163                              0x00
0x164                              0x00
0x165                              0x00
0x166                              0x00
0x167                              0x00
0x168                              0x00
0x169                              0x00
0x16a                              0x00
0x16b                              0x00
0x16c                              0x00
0x16d                              0x00
0x16e                              0x00
0x16f                              0x00
0x170                              0x00
0x171                              0x00
0x172                              0x00
0x173                              0x00
0x174                              0x00
0x175                              0x00
0x176                              0x00
0x177                              0x00
0x178                              0x00
0x179                              0x00
0x17a                              0x00
0x17b                              0x00
0x17c                              0x00
0x17d                              0x00
0x17e                              0x00
0x17f                              0x00
0x180                              0x00
0x181                              0x00
0x182                              0x00
0x183                              0x00
0x184                              0x00
0x185                              0x00
0x186                              0x00
0x187                              0x00
0x188                              0x00
0x189                              0x00
0x18a                              0x00
0x18b                              0x00
0x18c                              0x00
0x18d                              0x00
0x18e                              0x00
0x18f                              0x00

Notch and Partition mode page (0xc)
-----------------------------------
Notched Drive                      1
Logical or Physical Notch          0
Max # of notches                   40
Active Notch                       0
Starting Boundary                  0x0
Ending Boundary                    0x5fc6c00
Pages Notched                      00000000 0000100c

SAS logical unit mode page (0x18)
----------------------------------------------------
Transport Layer Retries            0

SAS SSP port control mode page (0x19)
-------------------------------------
Ready LED meaning                  1
I_T Nexus Loss time                2000
Initiator response time-out        2000

SAS Phy Control and Discover mode subpage (0x19,0x1)
--------------------------------------------
Number of phys                     2
Phy Identifier                     0
Attached Device type               2
Negotiated Logical Link rate       10
Attached SSP Initiator port        0
Attached STP Initiator port        0
Attached SMP Initiator port        0
Attached SSP Target port           0
Attached STP Target port           0
Attached SMP Target port           1
SAS address                        0x5000cca254899139
Attached SAS address               0x5003048000b999bf
Attached Phy identifier            35
Programmed Min Physical Link rate  8
Hardware Min Physical Link rate    8
Programmed Max Physical Link rate  11
Hardware Max Physical Link rate    11
Phy Identifier                     1
Attached Device type               0
Negotiated Logical Link rate       0
Attached SSP Initiator port        0
Attached STP Initiator port        0
Attached SMP Initiator port        0
Attached SSP Target port           0
Attached STP Target port           0
Attached SMP Target port           0
SAS address                        0x5000cca25489913a
Attached SAS address               0x0000000000000000
Attached Phy identifier            0
Programmed Min Physical Link rate  8
Hardware Min Physical Link rate    8
Programmed Max Physical Link rate  11
Hardware Max Physical Link rate    11

SAS SSP shared protocol specific port mode subpage (0x19,0x2)
-----------------------------------------------------
Power loss timeout(ms)             0

SPI-4 Negotiated Settings mode subpage (0x19,0x3)
--------------------------------------------
Transfer period                    1
REQ/ACK offset                     0
Transfer width exponent            0
Protocol option bits               0
Transceiver mode                   0
Sent PCOMP_EN                      0
Received PCOMP_EN                  0

mode page: 0x19  subpage: 0x05
------------------------------
0x04                               0x00
0x05                               0x06
0x06                               0x04
0x07                               0x1c
0x08                               0x08
0x09                               0x00
0x0a                               0x02
0x0b                               0x0c
0x0c                               0x00
0x0d                               0x0b
0x0e                               0x07
0x0f                               0x00
0x10                               0x04
0x11                               0x00
0x12                               0x15
0x13                               0x08
0x14                               0x00
0x15                               0x00
0x16                               0x00
0x17                               0x00
0x18                               0x01
0x19                               0x0b
0x1a                               0x07
0x1b                               0x00
0x1c                               0x04
0x1d                               0x00
0x1e                               0x15
0x1f                               0x08
0x20                               0x00
0x21                               0x09
0x22                               0x0f
0x23                               0x00
0x24                               0x09
0x25                               0x00
0x26                               0x02
0x27                               0x0c
0x28                               0x00
0x29                               0x0d
0x2a                               0x06
0x2b                               0x05
0x2c                               0x04
0x2d                               0x00
0x2e                               0x15
0x2f                               0x08
0x30                               0x05
0x31                               0x00
0x32                               0x00
0x33                               0x00
0x34                               0x01
0x35                               0x0d
0x36                               0x06
0x37                               0x05
0x38                               0x04
0x39                               0x00
0x3a                               0x15
0x3b                               0x08
0x3c                               0x05
0x3d                               0x00
0x3e                               0x00
0x3f                               0x00
0x40                               0x0a
0x41                               0x00
0x42                               0x02
0x43                               0x0c
0x44                               0x00
0x45                               0x0a
0x46                               0x03
0x47                               0x06
0x48                               0x04
0x49                               0x00
0x4a                               0x15
0x4b                               0x08
0x4c                               0x06
0x4d                               0x00
0x4e                               0x0a
0x4f                               0x00
0x50                               0x01
0x51                               0x0a
0x52                               0x03
0x53                               0x06
0x54                               0x04
0x55                               0x00
0x56                               0x15
0x57                               0x08
0x58                               0x06
0x59                               0x00
0x5a                               0x00
0x5b                               0x00
0x5c                               0x0b
0x5d                               0x00
0x5e                               0x02
0x5f                               0x0c
0x60                               0x00
0x61                               0x0a
0x62                               0x00
0x63                               0x00
0x64                               0x02
0x65                               0x04
0x66                               0x15
0x67                               0x08
0x68                               0x05
0x69                               0x00
0x6a                               0x00
0x6b                               0x00
0x6c                               0x01
0x6d                               0x0a
0x6e                               0x00
0x6f                               0x00
0x70                               0x02
0x71                               0x04
0x72                               0x15
0x73                               0x08
0x74                               0x05
0x75                               0x00
0x76                               0x00
0x77                               0x00

Power Condition mode page (0x1a)
--------------------------------
Idle                               0
Standby                            0
Idle Condition counter (100ms)     0
Standby Condition counter (100ms)  0

Informational Exceptions mode page (0x1c)
-----------------------------------------
PERF                               0
EBF                                0
EWASC                              1
DEXCPT                             0
TEST                               0
EBACKERR                           0
LOGERR                             0
MRIE                               4
Interval Timer                     0
Report Count                       1

Background control mode subpage (0x1c,0x1)
--------------------------------------------
Enable background medium scan      1
Enable pre-scan                    0
BMS interval time (hour)           168
Pre-scan timeout value (hour)      0

mode page: 0x33
---------------
0x02                               0x21
0x03                               0xfb
0x04                               0x00
0x05                               0x00
0x06                               0x00
0x07                               0x00
0x08                               0x00
0x09                               0x00
0x0a                               0x01
0x0b                               0xd1
0x0c                               0x10
0x0d                               0x40
0x0e                               0x00
0x0f                               0x01
0x10                               0x00
0x11                               0x64
0x12                               0x00
0x13                               0x18
0x14                               0x40
0x15                               0x00
0x16                               0x00
0x17                               0x00

mode page: 0x34
---------------
0x02                               0x05
0x03                               0xfc
0x04                               0x6c
0x05                               0x0e
0x06                               0x00
0x07                               0x00
0x08                               0x00
0x09                               0x00
0x0a                               0x00
0x0b                               0x00
0x0c                               0x00
0x0d                               0x00
0x0e                               0x00
0x0f                               0x00
0x10                               0x00
0x11                               0x00
0x12                               0x00
0x13                               0x00
0x14                               0x1c
0x15                               0x20
0x16                               0x00
0x17                               0x00

mode page: 0x37
---------------
0x02                               0x00
0x03                               0x00
0x04                               0x00
0x05                               0x00
0x06                               0x00
0x07                               0x00
0x08                               0x00
0x09                               0x00
0x0a                               0x00
0x0b                               0x00
0x0c                               0x00
0x0d                               0x1e
0x0e                               0x00
0x0f                               0x00
0x10                               0x00
0x11                               0x00
0x12                               0x00
0x13                               0x00
0x14                               0x00
0x15                               0x00
0x16                               0x00
0x17                               0x00
0x18                               0x00
0x19                               0x00
0x1a                               0x00
0x1b                               0x00
0x1c                               0x00
0x1d                               0x00
0x1e                               0x00
0x1f                               0x00
0x20                               0x00
0x21                               0x00
0x22                               0xff
0x23                               0x00
0x24                               0x00
0x25                               0x00
0x26                               0x00
0x27                               0x00
0x28                               0x00
0x29                               0x00
0x2a                               0x00
0x2b                               0x00
0x2c                               0x00
0x2d                               0x00
0x2e                               0x00
0x2f                               0x00
0x30                               0x00
0x31                               0x00
0x32                               0x00
0x33                               0x00

mode page: 0x00   [Vendor (non-page format)]
---------------
0x00                               0x80
0x01                               0x18
0x02                               0x00
0x03                               0x00
0x04                               0x00
0x05                               0x02
0x06                               0x00
0x07                               0x00
0x08                               0x00
0x09                               0x00
0x0a                               0x00
0x0b                               0x30
0x0c                               0x16
0x0d                               0x14
0x0e                               0x00
0x0f                               0x00
0x10                               0x00
0x11                               0x00
0x12                               0x09
0x13                               0x05
0x14                               0x01
0x15                               0x10
0x16                               0x00
0x17                               0x00
0x18                               0x00
0x19                               0x00
PartialVolume commented 7 months ago

Interesting, thanks, unfortunately re sginfo -A, although it does contain hex data, it doesn't provide the level of detail hdparm --verbose does, unless sginfo has a similar option that outputs the real low level command and return data.

It is interesting that it also provides the same serial number result which seems to indicate that the field length is defined as larger than 20 characters.

I was looking for an example of a H7280A520SUN8.0T online to see what the typical serial number looks like and found one below, has a 18 character serial number. HUH model but half way down states it's a H720.

If there are other drives that exceed 20 character serial numbers I may have to consider a variable length. As these drives you have are not necessarily a typical H7280.. I'm not too concerned. However changing the serial number length to variable may happen. I need to look at the ata command specs. I've got a feeling it does provide a length field for serial number but need to double check that.

Screenshot_2024-03-02-08-48-45-74_40deb401b9ffe8e1df2f1cc5ba480b12~2