linux-brain/drivers/thunderbolt
Mika Westerberg 768033cf47 thunderbolt: Prevent crash if non-active NVMem file is read
commit 03cd45d2e219301880cabc357e3cf478a500080f upstream.

The driver does not populate .reg_read callback for the non-active NVMem
because the file is supposed to be write-only. However, it turns out
NVMem subsystem does not yet support this and expects that the .reg_read
callback is provided. If user reads the binary attribute it triggers
NULL pointer dereference like this one:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  ...
  Call Trace:
   bin_attr_nvmem_read+0x64/0x80
   kernfs_fop_read+0xa7/0x180
   vfs_read+0xbd/0x170
   ksys_read+0x5a/0xd0
   do_syscall_64+0x43/0x150
   entry_SYSCALL_64_after_hwframe+0x44/0xa9

Fix this in the driver by providing .reg_read callback that always
returns an error.

Reported-by: Nicholas Johnson <nicholas.johnson-opensource@outlook.com.au>
Fixes: e6b245ccd5 ("thunderbolt: Add support for host and device NVM firmware upgrade")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20200213095604.1074-1-mika.westerberg@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-02-28 16:38:44 +01:00
..
Kconfig thunderbolt: Add support for host and device NVM firmware upgrade 2017-06-09 11:42:43 +02:00
Makefile thunderbolt: Add support for XDomain discovery protocol 2017-10-02 11:24:41 -07:00
cap.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ctl.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-11-04 09:26:51 +09:00
ctl.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-11-04 09:26:51 +09:00
dma_port.c thunderbolt: Add support for Intel Titan Ridge 2018-03-09 12:54:11 +03:00
dma_port.h thunderbolt: Add support for DMA configuration based mailbox 2017-06-09 11:42:43 +02:00
domain.c thunderbolt: Add support for runtime PM 2018-07-25 10:55:29 +02:00
eeprom.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
icm.c thunderbolt: Fix to check the return value of kmemdup 2019-05-31 06:46:29 -07:00
nhi.c thunderbolt: Use 32-bit writes when writing ring producer/consumer 2019-11-06 13:06:12 +01:00
nhi.h thunderbolt: Add support for Intel Titan Ridge 2018-03-09 12:54:11 +03:00
nhi_regs.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-11-04 09:26:51 +09:00
path.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
property.c thunderbolt: property: Fix a NULL pointer dereference 2019-05-31 06:46:31 -07:00
switch.c thunderbolt: Prevent crash if non-active NVMem file is read 2020-02-28 16:38:44 +01:00
tb.c Char/Misc patches for 4.15-rc1 2017-11-16 09:10:59 -08:00
tb.h thunderbolt: Take domain lock in switch sysfs attribute callbacks 2019-05-31 06:46:20 -07:00
tb_msgs.h thunderbolt: Add support for runtime PM 2018-07-25 10:55:29 +02:00
tb_regs.h thunderbolt: Fix small typo in variable name 2018-07-25 10:15:24 +02:00
tunnel_pci.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
tunnel_pci.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xdomain.c thunderbolt: Fix to check return value of ida_simple_get 2019-05-31 06:46:31 -07:00