linux-stable/drivers/platform/chrome
Tzung-Bi Shih 675f8a7ad7 platform/chrome: cros_ec_debugfs: detach log reader wq from devm
[ Upstream commit 0e8eb5e8ac ]

Debugfs console_log uses devm memory (e.g. debug_info in
cros_ec_console_log_poll()).  However, lifecycles of device and debugfs
are independent.  An use-after-free issue is observed if userland
program operates the debugfs after the memory has been freed.

The call trace:
 do_raw_spin_lock
 _raw_spin_lock_irqsave
 remove_wait_queue
 ep_unregister_pollwait
 ep_remove
 do_epoll_ctl

A Python example to reproduce the issue:
... import select
... p = select.epoll()
... f = open('/sys/kernel/debug/cros_scp/console_log')
... p.register(f, select.POLLIN)
... p.poll(1)
[(4, 1)]                    # 4=fd, 1=select.POLLIN

[ shutdown cros_scp at the point ]

... p.poll(1)
[(4, 16)]                   # 4=fd, 16=select.POLLHUP
... p.unregister(f)

An use-after-free issue raises here.  It called epoll_ctl with
EPOLL_CTL_DEL which in turn to use the workqueue in the devm (i.e.
log_wq).

Detaches log reader's workqueue from devm to make sure it is persistent
even if the device has been removed.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Reviewed-by: Guenter Roeck <groeck@google.com>
Link: https://lore.kernel.org/r/20220209051130.386175-1-tzungbi@google.com
Signed-off-by: Benson Leung <bleung@chromium.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-05-25 09:59:01 +02:00
..
wilco_ec platform/chrome: wilco_ec: convert stream-like files from nonseekable_open -> stream_open 2021-03-30 18:25:22 +02:00
chromeos_laptop.c platform/chrome: chromeos_laptop - Prepare complete software nodes 2021-04-10 21:43:02 +02:00
chromeos_pstore.c chrome platform changes for 5.8 2020-06-04 10:54:45 -07:00
chromeos_tbmc.c
cros_ec.c platform/chrome: cros_ec: Call interrupt bottom half at probe time 2021-01-22 08:50:27 +01:00
cros_ec.h platform/chrome: cros_ec: Call interrupt bottom half in ISH or RPMSG mode 2021-01-22 08:50:27 +01:00
cros_ec_chardev.c platform/chrome: cros_ec_chardev: Replace zero-length array with flexible-array member 2020-03-22 11:15:18 +01:00
cros_ec_debugfs.c platform/chrome: cros_ec_debugfs: detach log reader wq from devm 2022-05-25 09:59:01 +02:00
cros_ec_i2c.c platform/chrome: cros_ec_i2c: Appease the kernel-doc deity 2020-05-04 14:01:45 -07:00
cros_ec_ishtp.c HID: intel-ish-hid: fix module device-id handling 2021-11-11 22:45:40 +01:00
cros_ec_lightbar.c platform/chrome: Constify static attribute_group structs 2021-01-20 16:19:17 +01:00
cros_ec_lpc.c platform/chrome: cros_ec: Fix spelling mistake "responsed" -> "response" 2021-09-30 10:09:47 +02:00
cros_ec_lpc_mec.c platform/chrome: cros_ec_lpc: Use DEFINE_MUTEX() for mutex lock 2021-04-21 10:00:30 +02:00
cros_ec_lpc_mec.h
cros_ec_proto.c platform/chrome: cros_ec_proto: Use ec_command for check_features 2021-10-31 15:52:55 -07:00
cros_ec_rpmsg.c platform/chrome: cros_ec: Call interrupt bottom half in ISH or RPMSG mode 2021-01-22 08:50:27 +01:00
cros_ec_sensorhub.c platform/chrome: cros_ec_sensorhub: simplify getting .driver_data 2021-09-27 09:18:58 +02:00
cros_ec_sensorhub_ring.c platform: chrome: Split trace include file 2022-04-08 13:58:51 +02:00
cros_ec_sensorhub_trace.h platform: chrome: Split trace include file 2022-04-08 13:58:51 +02:00
cros_ec_spi.c platform/chrome: cros_ec_spi: Drop bits_per_word assignment 2020-12-09 16:52:09 +00:00
cros_ec_sysfs.c platform/chrome: cros_ec_sysfs: Add cold-ap-off to sysfs reboot. 2021-01-20 16:19:17 +01:00
cros_ec_trace.c platform/chrome: cros_ec: Add command for regulator control. 2020-06-15 22:40:14 +01:00
cros_ec_trace.h platform: chrome: Split trace include file 2022-04-08 13:58:51 +02:00
cros_ec_typec.c platform/chrome: cros_ec_typec: Check for EC device 2022-04-08 13:58:58 +02:00
cros_ec_vbc.c platform/chrome: Constify static attribute_group structs 2021-01-20 16:19:17 +01:00
cros_kbd_led_backlight.c
cros_usbpd_logger.c platform/chrome: cros_usbpd_logger: Add __printf annotation to append_str() 2020-05-04 14:02:01 -07:00
cros_usbpd_notify.c platform/chrome: cros_ec_proto: Add version for ec_command 2021-09-30 10:09:47 +02:00
Kconfig platform/chrome: Kconfig: Remove the transitional MFD_CROS_EC config 2020-09-04 09:30:04 +02:00
Makefile platform: chrome: Split trace include file 2022-04-08 13:58:51 +02:00