linux/drivers/hwtracing/intel_th
Alexander Shishkin ec5b5ad6e2 intel_th: msu: Fix an off-by-one in attribute store
The 'nr_pages' attribute of the 'msc' subdevices parses a comma-separated
list of window sizes, passed from userspace. However, there is a bug in
the string parsing logic wherein it doesn't exclude the comma character
from the range of characters as it consumes them. This leads to an
out-of-bounds access given a sufficiently long list. For example:

> # echo 8,8,8,8 > /sys/bus/intel_th/devices/0-msc0/nr_pages
> ==================================================================
> BUG: KASAN: slab-out-of-bounds in memchr+0x1e/0x40
> Read of size 1 at addr ffff8803ffcebcd1 by task sh/825
>
> CPU: 3 PID: 825 Comm: npktest.sh Tainted: G        W         4.20.0-rc1+
> Call Trace:
>  dump_stack+0x7c/0xc0
>  print_address_description+0x6c/0x23c
>  ? memchr+0x1e/0x40
>  kasan_report.cold.5+0x241/0x308
>  memchr+0x1e/0x40
>  nr_pages_store+0x203/0xd00 [intel_th_msu]

Fix this by accounting for the comma character.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: ba82664c13 ("intel_th: Add Memory Storage Unit driver")
Cc: stable@vger.kernel.org # v4.4+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-19 20:21:06 +01:00
..
acpi.c intel_th: Add ACPI glue layer 2018-03-28 18:47:23 +03:00
core.c intel_th: Fix resource handling for ACPI glue layer 2018-09-18 16:08:38 +02:00
debug.c intel_th: Add SPDX GPL-2.0 header to replace GPLv2 boilerplate 2018-03-28 18:47:19 +03:00
debug.h intel_th: Add SPDX GPL-2.0 header to replace GPLv2 boilerplate 2018-03-28 18:47:19 +03:00
gth.c intel_th: Add SPDX GPL-2.0 header to replace GPLv2 boilerplate 2018-03-28 18:47:19 +03:00
gth.h intel_th: Add SPDX GPL-2.0 header to replace GPLv2 boilerplate 2018-03-28 18:47:19 +03:00
intel_th.h intel_th: Allow forcing host mode through drvdata 2018-03-28 18:47:21 +03:00
Kconfig intel_th: Add ACPI glue layer 2018-03-28 18:47:23 +03:00
Makefile intel_th: Add ACPI glue layer 2018-03-28 18:47:23 +03:00
msu.c intel_th: msu: Fix an off-by-one in attribute store 2018-12-19 20:21:06 +01:00
msu.h intel_th: Add SPDX GPL-2.0 header to replace GPLv2 boilerplate 2018-03-28 18:47:19 +03:00
pci.c intel_th: pci: Add Ice Lake PCH support 2018-09-18 16:08:38 +02:00
pti.c intel_th: Add SPDX GPL-2.0 header to replace GPLv2 boilerplate 2018-03-28 18:47:19 +03:00
pti.h intel_th: Add SPDX GPL-2.0 header to replace GPLv2 boilerplate 2018-03-28 18:47:19 +03:00
sth.c intel_th: Add SPDX GPL-2.0 header to replace GPLv2 boilerplate 2018-03-28 18:47:19 +03:00
sth.h intel_th: Add SPDX GPL-2.0 header to replace GPLv2 boilerplate 2018-03-28 18:47:19 +03:00