Bug 1833092

Summary: hdparm crashes with free(): invalid pointer
Product: Red Hat Enterprise Linux 8 Reporter: Rob Leese <rleese>
Component: hdparmAssignee: Tomáš Bžatek <tbzatek>
Status: CLOSED ERRATA QA Contact: Robin Hack <rhack>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.2CC: asanders, jpittman, qe-baseos-daemons, rhack, rhandlin, tbzatek
Target Milestone: rcKeywords: TestCaseNotNeeded, Triaged
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: hdparm-9.54-3.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-18 14:56:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Rob Leese 2020-05-07 19:06:51 UTC
Created attachment 1686310 [details]
app crash core

Description of problem:

Running hdparm on some of the system's drives works as expected:
=======
$ sudo hdparm -i /dev/sda                                                         
/dev/sda:

 Model=SK hynix SC210 2.5 7MM 512GB, FwRev=20001L00, SerialNo=1I52N024210102857
 Config={ }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=16
 (maybe): CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=1000215216
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio3 pio4 
 DMA modes:  mdma0 mdma1 mdma2 
 UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
 AdvancedPM=yes: disabled (255) WriteCache=enabled
 Drive conforms to: Unspecified:  ATA/ATAPI-2,3,4,5,6,7

 * signifies the current active mode

$ echo $?
0
=======

Running it on other drives triggers an abort and exit failure due to
freeing an invalid pointer:
=======
$ sudo hdparm -i /dev/sdb

/dev/sdb:

 Model=WDC WD5003AZEX-00K1GA0, FwRev=80.00A80, SerialNo=WD-WCC1S2239733
 Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=16
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=976773168
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio3 pio4 
 DMA modes:  mdma0 mdma1 mdma2 
 UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
 AdvancedPM=no WriteCache=enabled
 Drive conforms to: Unspecified:  ATA/ATAPI-1,2,3,4,5,6,7

 * signifies the current active mode

free(): invalid pointer
Abort
$ echo $?
262
Version-Release number of selected component (if applicable):


How reproducible:

Happens only on some drives

Comment 1 John Pittman 2020-05-07 19:22:48 UTC
hdparm-9.54-2.el8 is package level

Comment 3 Tomáš Bžatek 2020-06-01 15:46:16 UTC
This is a fallout from memory leak fixes: bug 1606961.

hdparm-9.54-resourceleak-fixes.patch adds free() calls on strip() in-place modified pointers. While upstream is leaking those three strings it's not a big deal since the hdparm process is short-lived.

Comment 4 Tomáš Bžatek 2020-06-01 16:01:58 UTC
Reproducible on my local SSD:

# ./hdparm -i /dev/sda

/dev/sda:

 Model=TOSHIBA THNSNH128GBST, FwRev=HTRAN101, SerialNo=53HS111PTE4Y
 Config={ Fixed }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=16
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=250069680
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio3 pio4 
 DMA modes:  mdma0 mdma1 mdma2 
 UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5 
 AdvancedPM=yes: unknown setting WriteCache=enabled
 Drive conforms to: Unspecified:  ATA/ATAPI-3,4,5,6,7

 * signifies the current active mode

free(): invalid pointer
Aborted

Comment 18 errata-xmlrpc 2021-05-18 14:56:09 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (hdparm bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:1625