linux-stable/drivers/comedi
Kees Cook 3bc93c7bde comedi: drivers: ni_routes: Use strcmp() instead of memcmp()
The family and device comparisons were using memcmp(), but this could
lead to Out-of-bounds reads when the length was larger than the
buffers being compared. Since these appear to always be NUL-terminated
strings, just use strcmp() instead.

This was found with Clang under LTO:

[ 92.405851][    T1] kernel BUG at lib/string_helpers.c:980!
...
[ 92.409141][ T1] RIP: 0010:fortify_panic (fbdev.c:?)
...
[ 92.410056][ T1] ni_assign_device_routes (fbdev.c:?)
[ 92.410056][ T1] ? unittest_enter (fbdev.c:?)
[ 92.410056][ T1] ni_routes_unittest (ni_routes_test.c:?)
[ 92.410056][ T1] ? unittest_enter (fbdev.c:?)
[ 92.410056][ T1] __initstub__kmod_ni_routes_test__505_604_ni_routes_unittest6 (fbdev.c:?)
[ 92.410056][ T1] do_one_initcall (fbdev.c:?)

Link: https://lore.kernel.org/lkml/20220210072821.GD4074@xsang-OptiPlex-9020
Fixes: 4bb90c87ab ("staging: comedi: add interface to ni routing table information")
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Spencer E. Olson <olsonse@umich.edu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Lee Jones <lee.jones@linaro.org>
Reported-by: kernel test robot <oliver.sang@intel.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20220215171017.1247291-1-keescook@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-02-25 12:08:52 +01:00
..
drivers comedi: drivers: ni_routes: Use strcmp() instead of memcmp() 2022-02-25 12:08:52 +01:00
kcomedilib comedi: Move the main COMEDI headers 2021-11-26 16:48:59 +01:00
comedi_buf.c comedi: Move the main COMEDI headers 2021-11-26 16:48:59 +01:00
comedi_fops.c comedi: Move the main COMEDI headers 2021-11-26 16:48:59 +01:00
comedi_internal.h
comedi_pci.c comedi: Move the main COMEDI headers 2021-11-26 16:48:59 +01:00
comedi_pcmcia.c comedi: Move the main COMEDI headers 2021-11-26 16:48:59 +01:00
comedi_usb.c comedi: Move the main COMEDI headers 2021-11-26 16:48:59 +01:00
drivers.c comedi: Move the main COMEDI headers 2021-11-26 16:48:59 +01:00
Kconfig
Makefile
proc.c comedi: Move the main COMEDI headers 2021-11-26 16:48:59 +01:00
range.c comedi: Move the main COMEDI headers 2021-11-26 16:48:59 +01:00
TODO