Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1974367

Summary: "dmidecode -u" crashes due to data segment corruption
Product: Red Hat Enterprise Linux 8 Reporter: Renaud Métrich <rmetrich>
Component: dmidecodeAssignee: Coiby <coxu>
Status: CLOSED DUPLICATE QA Contact: Kernel-QE - Hardware <kernel-qe-hw>
Severity: high Docs Contact:
Priority: high    
Version: 8.4Flags: pm-rhel: mirror+
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-06-22 01:54:25 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 Renaud Métrich 2021-06-21 13:26:39 UTC
Description of problem:

On RHEL8.3 and later, "dmidecode -u" crashes with Segmentation Fault due to data segment corruption.
Investigation showed commit 11e134e54d15e67a64c39a623f492a28df922517 needs to be backported:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
commit 11e134e54d15e67a64c39a623f492a28df922517
Author: Jean Delvare <jdelvare>
Date:   Tue Jan 19 16:26:01 2021 +0100

    dmidecode: Fix crash with -u option
    
    A segmentation fault was reported with option -u. Turns out to be a
    stupid thinko where the buffer offset was reset at the wrong loop
    depth.
    
    Reported-by: Jerry Hoemann <jerry.hoemann>
    Fixes: da06888d08b9 ("dmidecode: Use the print helpers in dump mode too")
    Signed-off-by: Jean Delvare <jdelvare>
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Backtrace:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055db49dfcedf in dmi_table_decode (flags=1, ver=<optimized out>, num=<optimized out>, len=19154, 
    buf=<optimized out>) at dmidecode.c:5154
5154			display = ((opt.type == NULL || opt.type[h.type])
(gdb) bt
#0  0x000055db49dfcedf in dmi_table_decode (flags=1, ver=<optimized out>, num=<optimized out>, len=19154, 
    buf=<optimized out>) at dmidecode.c:5154
#1  dmi_table (base=<optimized out>, len=19154, num=<optimized out>, ver=<optimized out>, devmem=<optimized out>, 
    flags=1) at dmidecode.c:5316
#2  0x000055db49e03581 in smbios_decode (flags=1, devmem=0x55db49e070e2 "/sys/firmware/dmi/tables/DMI", 
    buf=0x55db4bff42b0 "_SM_\r\037\002\am") at dmidecode.c:5441
#3  smbios_decode (buf=0x55db4bff42b0 "_SM_\r\037\002\am", devmem=0x55db49e070e2 "/sys/firmware/dmi/tables/DMI", 
    flags=1) at dmidecode.c:5399
#4  0x000055db49dfb4f4 in main (argc=<optimized out>, argv=<optimized out>) at dmidecode.c:5662
(gdb) p opt
$1 = {devmem = 0x3320323320453220 <error: Cannot access memory at address 0x3320323320453220>, flags = 808656944, 
  type = 0x3033203533203233 <error: Cannot access memory at address 0x3033203533203233>, 
  string = 0x3533323320373320, dumpfile = 0x303020 <error: Cannot access memory at address 0x303020>, 
  handle = 4294967295}
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------


Version-Release number of selected component (if applicable):

dmidecode-3.2-6 and later


How reproducible:

Always

Steps to Reproduce:

1. Execute "dmidecode -u" in a QEMU/KVM

  Crash happens on next line after printing "QEMU" line:
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
  [...]
  Handle 0x0100, DMI type 1, 27 bytes
  	Header and Data:
  		01 1B 00 01 01 02 03 00 3D 72 EA 5F E4 B8 DB 49
  		B6 23 7F A0 1B C8 2A DF 06 00 00
  	Strings:
  		51 45 4D 55 00
  		QEMU
  		53 74 61 6E 64 61 72 64 20 50 43 20 28 51 33 35  
  --> CRASH HERE
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

2. Execute "dmidecode -u" under gdb, with a watch on "opt.type"

  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
  # gdb --args /usr/sbin/decode -u
  (gdb) watch opt.type
  (gdb) run
  ...
  
  	Strings:
  		51 45 4D 55 00
  		QEMU
  		53 74 61 6E 64 61 72 64 20 50 43 20 28 51 33 35
  
  Hardware watchpoint 1: opt.type
  
  Old value = (u8 *) 0x0
  New value = (u8 *) 0x33 <error: Cannot access memory at address 0x33>
  __GI__IO_default_xsputn (n=<optimized out>, data=<optimized out>, f=<optimized out>) at genops.c:393
  393		      for (i = count; --i >= 0; )
  (gdb) bt
  #0  __GI__IO_default_xsputn (n=<optimized out>, data=<optimized out>, f=<optimized out>) at genops.c:393
  #1  __GI__IO_default_xsputn (f=0x7fffffffd320, data=<optimized out>, n=2) at genops.c:370
  #2  0x00007ffff7a5bdc8 in _IO_vfprintf_internal (s=s@entry=0x7fffffffd320, format=format@entry=0x555555566aa5 " %02X", ap=ap@entry=0x7fffffffd460) at ../libio/libioP.h:838
  #3  0x00007ffff7b15a63 in ___vsprintf_chk (s=0x55555577226f <opt+15> " 3", flags=1, slen=18446744073709551615, format=0x555555566aa5 " %02X", args=args@entry=0x7fffffffd460) at vsprintf_chk.c:83
  #4  0x00007ffff7b1598e in ___sprintf_chk (s=<optimized out>, flags=<optimized out>, slen=<optimized out>, format=<optimized out>) at sprintf_chk.c:31
  #5  0x000055555555cc52 in sprintf (__fmt=0x555555566aa5 " %02X", __s=0x55555577226f <opt+15> " 3") at /usr/include/bits/stdio2.h:36
  #6  dmi_dump (h=0x7fffffffd600) at dmidecode.c:255
  #7  0x000055555555e11f in dmi_table_decode (flags=1, ver=<optimized out>, num=<optimized out>, len=465, buf=<optimized out>) at dmidecode.c:5233
  #8  dmi_table (base=<optimized out>, len=465, num=<optimized out>, ver=<optimized out>, devmem=<optimized out>, flags=1) at dmidecode.c:5333
  #9  0x00005555555646e1 in smbios_decode (flags=1, devmem=0x555555568242 "/sys/firmware/dmi/tables/DMI", buf=0x5555557736b0 "_SM_.\037\002\bK") at dmidecode.c:5458
  #10 smbios_decode (buf=0x5555557736b0 "_SM_.\037\002\bK", devmem=0x555555568242 "/sys/firmware/dmi/tables/DMI", flags=1) at dmidecode.c:5416
  #11 0x000055555555c644 in main (argc=<optimized out>, argv=<optimized out>) at dmidecode.c:5679
  (gdb) f 6
  #6  dmi_dump (h=0x7fffffffd600) at dmidecode.c:255
  255							off += sprintf(raw_data + off,
  (gdb) p raw_data
  $1 = "53 74 61 6E 64 61 72 64 20 50 43 20 28 51 33 352"
  (gdb) p off
  $2 = 79
  (gdb) k
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

  From above, we can see that raw_data (a 48 bytes array) gets filled on position 79, which makes the data segment containing "opt" variable get corrupted.

Comment 1 Coiby 2021-06-22 01:54:25 UTC
Hi Renaud,

This bug has been fixed in dmidecode-3.2-10.el8 for RHEL8.5.

*** This bug has been marked as a duplicate of bug 1885823 ***