linux-stable/drivers/edac
Toshi Kani c4cd52ab1e EDAC/ghes: Set the DIMM label unconditionally
commit 5e2805d537 upstream.

The commit

  cb51a371d0 ("EDAC/ghes: Setup DIMM label from DMI and use it in error reports")

enforced that both the bank and device strings passed to
dimm_setup_label() are not NULL.

However, there are BIOSes, for example on a

  HPE ProLiant DL360 Gen10/ProLiant DL360 Gen10, BIOS U32 03/15/2019

which don't populate both strings:

  Handle 0x0020, DMI type 17, 84 bytes
  Memory Device
          Array Handle: 0x0013
          Error Information Handle: Not Provided
          Total Width: 72 bits
          Data Width: 64 bits
          Size: 32 GB
          Form Factor: DIMM
          Set: None
          Locator: PROC 1 DIMM 1        <===== device
          Bank Locator: Not Specified   <===== bank

This results in a buffer overflow because ghes_edac_register() calls
strlen() on an uninitialized label, which had non-zero values left over
from krealloc_array():

  detected buffer overflow in __fortify_strlen
   ------------[ cut here ]------------
   kernel BUG at lib/string_helpers.c:983!
   invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
   CPU: 1 PID: 1 Comm: swapper/0 Tainted: G          I       5.18.6-200.fc36.x86_64 #1
   Hardware name: HPE ProLiant DL360 Gen10/ProLiant DL360 Gen10, BIOS U32 03/15/2019
   RIP: 0010:fortify_panic
   ...
   Call Trace:
    <TASK>
    ghes_edac_register.cold
    ghes_probe
    platform_probe
    really_probe
    __driver_probe_device
    driver_probe_device
    __driver_attach
    ? __device_attach_driver
    bus_for_each_dev
    bus_add_driver
    driver_register
    acpi_ghes_init
    acpi_init
    ? acpi_sleep_proc_init
    do_one_initcall

The label contains garbage because the commit in Fixes reallocs the
DIMMs array while scanning the system but doesn't clear the newly
allocated memory.

Change dimm_setup_label() to always initialize the label to fix the
issue. Set it to the empty string in case BIOS does not provide both
bank and device so that ghes_edac_register() can keep the default label
given by edac_mc_alloc_dimms().

  [ bp: Rewrite commit message. ]

Fixes: b9cae27728 ("EDAC/ghes: Scan the system once on driver init")
Co-developed-by: Robert Richter <rric@kernel.org>
Signed-off-by: Robert Richter <rric@kernel.org>
Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Tested-by: Robert Elliott <elliott@hpe.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220719220124.760359-1-toshi.kani@hpe.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-08-03 12:00:50 +02:00
..
al_mc_edac.c EDAC/al-mc-edac: Add Amazon's Annapurna Labs Memory Controller driver 2020-08-17 10:10:29 +02:00
altera_edac.c EDAC/altera: Fix deferred probing 2022-02-08 18:30:40 +01:00
altera_edac.h
amd64_edac.c EDAC/amd64: Handle three rank interleaving mode 2021-11-18 14:04:06 +01:00
amd64_edac.h EDAC/amd64: Add AMD family 17h model 60h PCI IDs 2020-05-22 18:43:13 +02:00
amd64_edac_dbg.c
amd64_edac_inj.c
amd76x_edac.c
amd8111_edac.c
amd8111_edac.h
amd8131_edac.c EDAC/amd8131: Remove defined but not used bridge_str 2020-04-24 09:08:47 +02:00
amd8131_edac.h
armada_xp_edac.c EDAC/armada-xp: Fix output of uncorrectable error counter 2021-10-20 11:45:01 +02:00
aspeed_edac.c EDAC/aspeed: Use module_platform_driver() to simplify 2020-09-18 09:14:01 +02:00
bluefield_edac.c
cell_edac.c
cpc925_edac.c
debugfs.c
dmc520_edac.c EDAC/dmc520: Don't print an error for each unconfigured interrupt line 2022-06-09 10:21:02 +02:00
e7xxx_edac.c
e752x_edac.c EDAC: Replace HTTP links with HTTPS ones 2020-08-17 09:31:19 +02:00
edac_device.c EDAC/device: Rework error logging API 2019-10-09 13:01:42 +02:00
edac_device.h EDAC/device: Rework error logging API 2019-10-09 13:01:42 +02:00
edac_device_sysfs.c EDAC: Fix reference count leaks 2020-06-17 15:38:35 +02:00
edac_mc.c EDAC: Fix calculation of returned address and next offset in edac_align_ptr() 2022-02-23 12:01:07 +01:00
edac_mc.h EDAC/mc: Determine mci pointer from the error descriptor 2020-02-17 13:05:10 +01:00
edac_mc_sysfs.c EDAC/mc_sysfs: Add missing newlines when printing {max,dimm}_location 2020-09-18 09:14:01 +02:00
edac_module.c
edac_module.h EDAC/mc: Change mci device removal to use put_device() 2020-02-17 12:32:44 +01:00
edac_pci.c
edac_pci.h
edac_pci_sysfs.c EDAC: Fix reference count leaks 2020-06-17 15:38:35 +02:00
fsl_ddr_edac.c
fsl_ddr_edac.h
ghes_edac.c EDAC/ghes: Set the DIMM label unconditionally 2022-08-03 12:00:50 +02:00
highbank_l2_edac.c
highbank_mc_edac.c
i7core_edac.c * Add Amazon's Annapurna Labs memory controller EDAC driver, by Talel 2020-10-12 10:12:26 -07:00
i10nm_base.c EDAC/i10nm: Fix NVDIMM detection 2021-09-15 09:50:30 +02:00
i3000_edac.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
i3200_edac.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
i5000_edac.c EDAC: Replace EDAC_DIMM_PTR() macro with edac_get_dimm() function 2019-11-09 10:32:32 +01:00
i5100_edac.c EDAC/i5100: Fix error handling order in i5100_init_one() 2020-09-01 12:10:19 +02:00
i5400_edac.c EDAC: Replace HTTP links with HTTPS ones 2020-08-17 09:31:19 +02:00
i7300_edac.c EDAC: Replace HTTP links with HTTPS ones 2020-08-17 09:31:19 +02:00
i82443bxgx_edac.c
i82860_edac.c
i82875p_edac.c
i82975x_edac.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
ie31200_edac.c EDAC: Replace HTTP links with HTTPS ones 2020-08-17 09:31:19 +02:00
Kconfig EDAC/al-mc-edac: Add Amazon's Annapurna Labs Memory Controller driver 2020-08-17 10:10:29 +02:00
layerscape_edac.c
Makefile EDAC/al-mc-edac: Add Amazon's Annapurna Labs Memory Controller driver 2020-08-17 10:10:29 +02:00
mce_amd.c EDAC/mce_amd: Do not load edac_mce_amd module on guests 2021-09-15 09:50:24 +02:00
mce_amd.h x86/mce/amd, edac: Remove report_gart_errors 2020-04-14 15:53:46 +02:00
mpc85xx_edac.c
mpc85xx_edac.h
mv64x60_edac.c
mv64x60_edac.h
octeon_edac-l2c.c
octeon_edac-lmc.c
octeon_edac-pc.c
octeon_edac-pci.c
pasemi_edac.c
pnd2_edac.c EDAC/Intel: Do not load EDAC driver when running as a guest 2021-07-14 16:56:00 +02:00
pnd2_edac.h
ppc4xx_edac.c
ppc4xx_edac.h
qcom_edac.c
r82600_edac.c
sb_edac.c EDAC/sb_edac: Fix top-of-high-memory value for Broadwell/Haswell 2021-11-18 14:03:45 +01:00
sifive_edac.c A garden variety of small fixes all over the place. 2020-01-27 09:16:22 -08:00
skx_base.c EDAC/Intel: Do not load EDAC driver when running as a guest 2021-07-14 16:56:00 +02:00
skx_common.c EDAC/{i7core,sb,pnd2,skx}: Fix error event severity 2020-08-18 15:40:30 +02:00
skx_common.h Merge branches 'edac-i10nm' and 'edac-misc' into edac-updates-for-5.8 2020-06-01 11:39:15 +02:00
synopsys_edac.c EDAC/synopsys: Read the error count from the correct register 2022-04-27 13:53:54 +02:00
thunderx_edac.c EDAC/thunderx: Make symbol lmc_dfs_ents static 2020-08-17 10:35:46 +02:00
ti_edac.c EDAC/ti: Add missing MODULE_DEVICE_TABLE 2021-07-14 16:55:57 +02:00
wq.c
x38_edac.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
xgene_edac.c EDAC/xgene: Fix deferred probing 2022-02-08 18:30:40 +01:00