linux-brain/drivers/nvdimm
Vishal Verma 05a085c7c5 libnvdimm: fix ars_status output length calculation
commit 286e877181 upstream.

Commit efda1b5d87 ("acpi, nfit, libnvdimm: fix / harden ars_status output length handling")
Introduced additional hardening for ambiguity in the ACPI spec for
ars_status output sizing. However, it had a couple of cases mixed up.
Where it should have been checking for (and returning) "out_field[1] -
4" it was using "out_field[1] - 8" and vice versa.

This caused a four byte discrepancy in the buffer size passed on to
the command handler, and in some cases, this caused memory corruption
like:

  ./daxdev-errors.sh: line 76: 24104 Aborted   (core dumped) ./daxdev-errors $busdev $region
  malloc(): memory corruption
  Program received signal SIGABRT, Aborted.
  [...]
  #5  0x00007ffff7865a2e in calloc () from /lib64/libc.so.6
  #6  0x00007ffff7bc2970 in ndctl_bus_cmd_new_ars_status (ars_cap=ars_cap@entry=0x6153b0) at ars.c:136
  #7  0x0000000000401644 in check_ars_status (check=0x7fffffffdeb0, bus=0x604c20) at daxdev-errors.c:144
  #8  test_daxdev_clear_error (region_name=<optimized out>, bus_name=<optimized out>)
      at daxdev-errors.c:332

Cc: <stable@vger.kernel.org>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Lukasz Dorau <lukasz.dorau@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Fixes: efda1b5d87 ("acpi, nfit, libnvdimm: fix / harden ars_status output length handling")
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-of-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-09 20:01:25 +02:00
..
blk.c libnvdimm, {btt, blk}: do integrity setup before add_disk() 2018-03-28 18:39:22 +02:00
btt_devs.c nvdimm, btt: add a size attribute for BTTs 2016-08-08 09:26:14 -07:00
btt.c libnvdimm, {btt, blk}: do integrity setup before add_disk() 2018-03-28 18:39:22 +02:00
btt.h libnvdimm, btt: Fix an incompatibility in the log layout 2018-01-23 19:57:03 +01:00
bus.c libnvdimm: fix ars_status output length calculation 2018-09-09 20:01:25 +02:00
claim.c libnvdimm, pmem: use nvdimm_flush() for namespace I/O writes 2016-07-12 15:13:48 -07:00
core.c libnvdimm: fix badblock range handling of ARS range 2017-07-27 15:08:02 -07:00
dax_devs.c libnvdimm, dax: autodetect support 2016-05-20 22:02:57 -07:00
dimm_devs.c libnvdimm: fix blk free space accounting 2017-04-21 09:31:21 +02:00
dimm.c libnvdimm: Fix nvdimm_probe error on NVDIMM-N 2016-09-01 18:20:39 -07:00
e820.c libnvdimm: move ->module to struct nvdimm_bus_descriptor 2016-07-21 20:03:19 -07:00
Kconfig nvdimm: make CONFIG_NVDIMM_DAX 'bool' 2016-10-27 16:16:21 -07:00
label.c libnvdimm, namespace: fix label initialization to use valid seq numbers 2017-11-30 08:39:07 +00:00
label.h libnvdimm: write blk label set 2015-06-24 21:24:10 -04:00
Makefile libnvdimm, dax: introduce device-dax infrastructure 2016-05-09 15:35:42 -07:00
namespace_devs.c libnvdimm, namespace: use a safe lookup for dimm device name 2018-04-24 09:34:13 +02:00
nd-core.h libnvdimm, namespace: allow creation of multiple pmem-namespaces per region 2016-10-07 09:22:53 -07:00
nd.h nfit, libnvdimm: fix interleave set cookie calculation 2017-03-15 10:02:47 +08:00
pfn_devs.c libnvdimm, dax: fix 1GB-aligned namespaces vs physical misalignment 2018-02-28 10:18:34 +01:00
pfn.h libnvdimm, dax: autodetect support 2016-05-20 22:02:57 -07:00
pmem.c pmem: return EIO on read_pmem() failure 2017-07-05 14:40:25 +02:00
pmem.h pmem: kill __pmem address space 2016-07-12 19:25:38 -07:00
region_devs.c libnvdimm, region: fix flush hint detection crash 2017-05-20 14:28:42 +02:00
region.c libnvdimm: keep region data alive over namespace removal 2016-07-11 16:13:41 -07:00