Mukesh Ojha
753255d2fc
leds: class: Protect brightness_show() with led_cdev->led_access mutex
[ Upstream commit 4ca7cd938725a4050dcd62ae9472e931d603118d ]
There is NULL pointer issue observed if from Process A where hid device
being added which results in adding a led_cdev addition and later a
another call to access of led_cdev attribute from Process B can result
in NULL pointer issue.
Use mutex led_cdev->led_access to protect access to led->cdev and its
attribute inside brightness_show() and max_brightness_show() and also
update the comment for mutex that it should be used to protect the led
class device fields.
Process A Process B
kthread+0x114
worker_thread+0x244
process_scheduled_works+0x248
uhid_device_add_worker+0x24
hid_add_device+0x120
device_add+0x268
bus_probe_device+0x94
device_initial_probe+0x14
__device_attach+0xfc
bus_for_each_drv+0x10c
__device_attach_driver+0x14c
driver_probe_device+0x3c
__driver_probe_device+0xa0
really_probe+0x190
hid_device_probe+0x130
ps_probe+0x990
ps_led_register+0x94
devm_led_classdev_register_ext+0x58
led_classdev_register_ext+0x1f8
device_create_with_groups+0x48
device_create_groups_vargs+0xc8
device_add+0x244
kobject_uevent+0x14
kobject_uevent_env[jt]+0x224
mutex_unlock[jt]+0xc4
__mutex_unlock_slowpath+0xd4
wake_up_q+0x70
try_to_wake_up[jt]+0x48c
preempt_schedule_common+0x28
__schedule+0x628
__switch_to+0x174
el0t_64_sync+0x1a8/0x1ac
el0t_64_sync_handler+0x68/0xbc
el0_svc+0x38/0x68
do_el0_svc+0x1c/0x28
el0_svc_common+0x80/0xe0
invoke_syscall+0x58/0x114
__arm64_sys_read+0x1c/0x2c
ksys_read+0x78/0xe8
vfs_read+0x1e0/0x2c8
kernfs_fop_read_iter+0x68/0x1b4
seq_read_iter+0x158/0x4ec
kernfs_seq_show+0x44/0x54
sysfs_kf_seq_show+0xb4/0x130
dev_attr_show+0x38/0x74
brightness_show+0x20/0x4c
dualshock4_led_get_brightness+0xc/0x74
[ 3313.874295][ T4013] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000060
[ 3313.874301][ T4013] Mem abort info:
[ 3313.874303][ T4013] ESR = 0x0000000096000006
[ 3313.874305][ T4013] EC = 0x25: DABT (current EL), IL = 32 bits
[ 3313.874307][ T4013] SET = 0, FnV = 0
[ 3313.874309][ T4013] EA = 0, S1PTW = 0
[ 3313.874311][ T4013] FSC = 0x06: level 2 translation fault
[ 3313.874313][ T4013] Data abort info:
[ 3313.874314][ T4013] ISV = 0, ISS = 0x00000006, ISS2 = 0x00000000
[ 3313.874316][ T4013] CM = 0, WnR = 0, TnD = 0, TagAccess = 0
[ 3313.874318][ T4013] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[ 3313.874320][ T4013] user pgtable: 4k pages, 39-bit VAs, pgdp=00000008f2b0a000
..
[ 3313.874332][ T4013] Dumping ftrace buffer:
[ 3313.874334][ T4013] (ftrace buffer empty)
..
..
[ dd3313.874639][ T4013] CPU: 6 PID: 4013 Comm: InputReader
[ 3313.874648][ T4013] pc : dualshock4_led_get_brightness+0xc/0x74
[ 3313.874653][ T4013] lr : led_update_brightness+0x38/0x60
[ 3313.874656][ T4013] sp : ffffffc0b910bbd0
..
..
[ 3313.874685][ T4013] Call trace:
[ 3313.874687][ T4013] dualshock4_led_get_brightness+0xc/0x74
[ 3313.874690][ T4013] brightness_show+0x20/0x4c
[ 3313.874692][ T4013] dev_attr_show+0x38/0x74
[ 3313.874696][ T4013] sysfs_kf_seq_show+0xb4/0x130
[ 3313.874700][ T4013] kernfs_seq_show+0x44/0x54
[ 3313.874703][ T4013] seq_read_iter+0x158/0x4ec
[ 3313.874705][ T4013] kernfs_fop_read_iter+0x68/0x1b4
[ 3313.874708][ T4013] vfs_read+0x1e0/0x2c8
[ 3313.874711][ T4013] ksys_read+0x78/0xe8
[ 3313.874714][ T4013] __arm64_sys_read+0x1c/0x2c
[ 3313.874718][ T4013] invoke_syscall+0x58/0x114
[ 3313.874721][ T4013] el0_svc_common+0x80/0xe0
[ 3313.874724][ T4013] do_el0_svc+0x1c/0x28
[ 3313.874727][ T4013] el0_svc+0x38/0x68
[ 3313.874730][ T4013] el0t_64_sync_handler+0x68/0xbc
[ 3313.874732][ T4013] el0t_64_sync+0x1a8/0x1ac
Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
Reviewed-by: Anish Kumar <yesanishhere@gmail.com>
Link: https://lore.kernel.org/r/20241103160527.82487-1-quic_mojha@quicinc.com
Signed-off-by: Lee Jones <lee@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
2025-12-24 11:22:37 +00:00
..
2022-06-25 11:46:26 +02:00
2023-01-18 09:26:05 +01:00
2019-09-10 10:32:19 +01:00
2019-12-05 15:37:22 +01:00
2020-05-22 20:19:43 +08:00
2021-12-25 18:03:37 +05:30
2021-12-25 18:03:37 +05:30
2021-12-25 18:03:37 +05:30
2021-12-25 18:03:37 +05:30
2022-08-31 12:13:12 +00:00
2022-03-16 12:57:07 +01:00
2022-01-03 23:21:18 +05:30
2022-06-14 16:54:02 +02:00
2022-01-03 23:21:18 +05:30
2022-09-05 10:25:03 +02:00
2021-12-25 18:03:37 +05:30
2021-12-25 18:03:37 +05:30
2018-10-18 09:16:24 +02:00
2020-03-03 04:08:26 +08:00
2022-09-19 11:18:02 +05:30
2023-05-30 12:38:38 +01:00
2020-06-30 15:38:04 -04:00
2020-09-14 12:19:13 +08:00
2020-03-03 04:05:49 +08:00
2025-09-21 09:20:40 +00:00
2021-12-25 18:03:37 +05:30
2021-12-25 18:03:37 +05:30
2025-12-24 11:16:57 +00:00
2025-12-24 11:20:53 +00:00
2020-03-03 04:07:29 +08:00
2022-08-17 15:18:46 +05:30
2023-06-09 10:56:51 +00:00
2021-12-25 18:03:37 +05:30
2021-05-22 10:57:12 +02:00
2020-01-09 10:17:55 +01:00
2021-12-25 18:03:37 +05:30
2020-03-03 02:03:29 +08:00
2022-04-02 12:58:22 +02:00
2022-10-26 13:17:05 +02:00
2019-12-17 20:38:59 +01:00
2022-02-04 15:28:00 +05:30
2025-09-21 09:20:40 +00:00
2021-12-25 18:03:37 +05:30
2021-02-23 14:00:30 +01:00
2018-10-13 09:27:30 +02:00
2021-12-25 18:03:37 +05:30
2020-02-05 16:16:37 -08:00
2020-08-21 09:48:15 +02:00
2025-12-24 11:21:24 +00:00
2020-06-25 15:41:57 +02:00
2019-04-17 08:37:52 +02:00
2022-11-10 15:47:24 +01:00
2021-12-25 18:03:37 +05:30
2020-08-14 22:49:29 +08:00
2025-12-24 11:22:29 +00:00
2020-05-20 08:17:03 +02:00
2024-03-23 23:45:31 +05:30
2024-03-23 23:45:30 +05:30
2025-08-27 18:27:50 +05:30
2025-12-24 11:17:03 +00:00
2024-03-23 23:45:27 +05:30
2022-09-15 12:23:51 +02:00
2019-10-05 12:48:01 +02:00
2025-08-27 18:30:56 +05:30
2021-11-12 14:28:23 +01:00
2019-08-16 10:13:47 +02:00
2023-10-31 18:44:28 +05:30
2023-10-31 18:44:28 +05:30
2019-04-05 22:31:31 +02:00
2020-03-03 00:07:02 +08:00
2020-03-03 00:04:10 +08:00
2019-08-06 19:05:24 +02:00
2019-08-06 19:05:23 +02:00
2025-12-24 11:20:53 +00:00
2019-12-13 07:14:20 -08:00
2019-12-13 07:14:20 -08:00
2021-01-30 14:56:15 +01:00
2019-01-31 08:13:45 +01:00
2021-10-06 15:35:04 +02:00
2021-05-26 11:47:01 +02:00
2021-11-26 11:40:24 +01:00
2022-11-10 15:47:24 +01:00
2019-11-12 14:15:50 -08:00
2019-12-02 17:06:03 -08:00
2023-08-20 12:27:39 +05:30
2019-11-20 18:00:23 +01:00
2021-12-25 18:03:37 +05:30
2021-12-25 18:03:37 +05:30
2022-06-25 11:46:35 +02:00
2020-07-03 14:25:20 +08:00
2020-03-03 02:04:49 +08:00
2023-12-20 15:32:35 +01:00
2018-09-26 08:42:37 +02:00
2019-08-02 10:12:21 -07:00
2020-10-01 13:12:30 +02:00
2019-03-21 16:19:55 -07:00
2020-04-24 08:00:36 +02:00
2022-01-03 23:21:18 +05:30
2025-12-24 11:16:58 +00:00
2020-08-14 22:48:59 +08:00
2020-06-19 14:55:52 +08:00
2022-05-25 08:41:22 +02:00
2025-12-24 11:17:10 +00:00
2022-11-03 14:44:57 +05:30
2019-11-20 18:00:45 +01:00
2021-03-11 13:51:06 +01:00
2022-11-10 15:47:23 +01:00
2021-10-27 09:51:40 +02:00
2020-06-25 15:41:57 +02:00
2025-12-24 11:20:17 +00:00
2023-01-18 09:26:11 +01:00
2021-04-07 12:47:03 +02:00
2020-04-13 15:24:54 +00:00
2019-11-24 08:22:48 +01:00
2025-12-24 11:21:32 +00:00
2021-12-08 08:46:55 +01:00
2025-08-27 18:27:49 +05:30
2021-12-25 18:03:37 +05:30
2020-10-14 09:51:10 +02:00
2025-12-24 11:17:19 +00:00
2020-03-03 04:12:35 +08:00
2020-06-22 09:43:05 -07:00
2025-12-24 11:20:57 +00:00
2023-10-31 18:45:19 +05:30
2023-04-26 14:14:55 +05:30
2020-04-02 16:34:21 +02:00
2019-12-05 15:37:52 +01:00
2020-06-25 15:42:00 +02:00
2019-02-12 19:46:06 +01:00
2025-12-24 11:20:04 +00:00
2019-12-11 12:19:38 -08:00
2019-09-10 10:32:13 +01:00
2019-03-23 14:35:27 +01:00
2021-12-25 18:03:37 +05:30
2021-12-25 18:03:37 +05:30
2019-02-15 08:09:13 +01:00
2018-12-17 09:28:49 +01:00
2023-04-01 18:17:23 +05:30
2020-03-03 00:04:10 +08:00
2020-11-05 11:07:05 +01:00
2019-01-13 10:01:02 +01:00
2025-12-24 11:17:32 +00:00
2020-04-16 17:06:03 +08:00
2018-10-20 09:48:53 +02:00
2020-03-03 04:07:53 +08:00
2025-08-27 18:30:56 +05:30
2022-06-25 11:46:35 +02:00
2025-12-24 11:21:05 +00:00
2020-08-21 09:48:00 +02:00
2020-09-23 10:46:34 +02:00
2021-12-25 18:03:37 +05:30
2018-11-21 09:24:11 +01:00
2021-03-03 18:22:57 +01:00
2020-09-09 19:03:12 +02:00
2020-05-10 10:29:03 +02:00
2023-09-23 10:47:01 +02:00
2020-01-12 12:12:04 +01:00
2021-03-30 14:40:10 +02:00
2019-08-09 17:53:35 +02:00
2023-10-10 21:43:38 +02:00
2020-12-11 13:39:03 +01:00
2023-03-11 16:26:46 +01:00
2021-12-25 18:03:37 +05:30
2020-03-20 10:54:13 +01:00
2019-12-13 07:14:18 -08:00
2018-12-01 09:43:00 +01:00
2021-02-03 23:22:23 +01:00
2020-02-28 16:36:15 +01:00
2020-03-22 19:33:11 +08:00
2020-07-29 07:42:58 +02:00
2020-04-24 08:00:28 +02:00
2020-03-03 04:05:45 +08:00
2022-11-03 14:44:57 +05:30
2021-12-08 08:46:53 +01:00
2021-03-03 18:58:56 +01:00
2020-08-21 09:48:23 +02:00
2019-04-05 22:31:35 +02:00
2025-12-24 11:21:50 +00:00
2025-12-24 11:22:19 +00:00
2018-12-05 19:41:17 +01:00
2020-03-03 04:02:16 +08:00
2019-07-10 09:14:22 -07:00
2019-07-10 09:14:20 -07:00
2020-01-13 19:40:11 +00:00
2021-01-09 13:37:39 +01:00
2023-04-01 18:17:23 +05:30
2023-02-06 07:46:34 +01:00
2019-12-17 21:13:36 +01:00
2022-07-02 16:18:11 +02:00
2020-04-24 08:01:25 +02:00
2021-03-03 18:58:56 +01:00
2020-08-14 22:49:29 +08:00
2022-08-25 11:11:25 +02:00
2020-06-20 10:25:11 +02:00
2020-10-14 09:51:14 +02:00
2022-09-21 13:06:50 +05:30
2023-03-11 16:26:46 +01:00
2022-07-06 18:53:52 -07:00
2021-02-07 14:47:41 +01:00
2022-08-25 11:11:29 +02:00
2025-12-24 11:22:37 +00:00
2025-12-24 11:19:47 +00:00
2020-01-04 13:59:54 +01:00
2020-01-24 18:05:38 -08:00
2022-08-17 15:18:45 +05:30
2019-06-09 09:18:17 +02:00
2020-02-28 16:36:03 +01:00
2021-09-22 11:45:24 +02:00
2020-06-05 16:00:00 +08:00
2020-09-09 19:35:54 +02:00
2025-09-21 09:20:40 +00:00
2025-12-24 11:17:15 +00:00
2022-06-14 16:53:51 +02:00
2018-12-29 13:39:11 +01:00
2023-10-25 11:13:30 +02:00
2021-10-09 14:09:45 +02:00
2020-03-11 18:04:31 +08:00
2021-04-07 12:47:03 +02:00
2021-12-25 18:03:37 +05:30
2021-09-22 11:45:34 +02:00
2021-12-25 18:03:37 +05:30
2020-03-03 04:07:51 +08:00
2019-12-31 12:37:21 +01:00
2018-09-19 22:43:48 +02:00
2021-12-25 18:03:37 +05:30
2025-08-27 18:30:54 +05:30
2021-07-11 12:48:09 +02:00
2022-04-28 21:02:36 +05:30
2022-11-01 19:14:44 +01:00
2021-05-22 11:25:16 +02:00
2025-12-24 11:20:33 +00:00
2021-08-26 08:37:04 -04:00
2022-01-03 23:21:18 +05:30
2020-01-29 18:00:16 +00:00
2025-12-24 11:17:29 +00:00
2022-05-18 09:18:05 +02:00
2025-12-24 11:20:35 +00:00
2023-06-21 15:38:58 +02:00
2020-06-05 16:01:49 +08:00
2025-12-24 11:22:21 +00:00
2022-04-20 09:08:28 +02:00
2020-10-01 13:12:40 +02:00
2019-09-06 10:21:00 +02:00
2023-09-23 10:46:53 +02:00
2023-08-11 11:33:34 +02:00
2022-06-14 16:54:01 +02:00
2023-02-25 11:50:31 +01:00
2020-04-24 08:00:36 +02:00
2025-12-24 11:20:51 +00:00
2021-12-25 18:03:37 +05:30
2021-12-25 18:03:37 +05:30
2021-01-09 13:37:38 +01:00
2023-01-18 09:26:04 +01:00
2020-10-29 09:07:08 +01:00
2021-12-25 18:03:37 +05:30
2021-12-25 18:03:37 +05:30
2021-12-25 18:03:37 +05:30
2021-12-25 18:03:37 +05:30
2025-12-24 11:21:24 +00:00
2020-05-27 16:43:05 +02:00
2019-07-10 09:14:20 -07:00
2020-08-27 23:56:11 +08:00
2022-01-03 23:21:18 +05:30
2020-06-16 12:53:13 -07:00
2025-12-24 11:22:06 +00:00
2020-04-24 08:00:37 +02:00
2025-12-24 11:20:48 +00:00
2020-04-24 08:01:20 +02:00
2020-03-03 00:12:51 +08:00
2023-10-25 11:33:41 +00:00
2018-12-01 09:42:59 +01:00
2020-03-20 10:54:12 +01:00
2019-08-12 13:29:46 -04:00
2019-05-04 09:15:18 +02:00
2023-11-08 11:21:07 +01:00
2020-05-22 20:21:07 +08:00
2020-03-03 04:05:16 +08:00
2020-03-03 04:06:41 +08:00
2025-12-24 11:17:49 +00:00
2021-12-25 18:03:37 +05:30
2019-10-11 14:59:23 -07:00
2020-06-05 16:00:11 +08:00
2020-05-20 08:17:09 +02:00
2025-12-24 11:17:27 +00:00
2020-01-04 14:00:12 +01:00
2018-10-03 17:00:50 -07:00
2021-12-25 18:03:37 +05:30
2022-06-25 11:46:39 +02:00
2023-05-21 20:35:03 +05:30
2019-08-12 13:29:46 -04:00
2021-12-25 18:03:37 +05:30
2019-03-23 14:35:24 +01:00
2022-06-13 16:44:58 +00:00
2022-06-13 16:44:58 +00:00
2019-06-11 12:21:48 +02:00
2019-01-09 17:14:44 +01:00
2022-06-14 16:53:43 +02:00
2023-11-28 16:45:44 +00:00
2019-12-17 20:38:38 +01:00
2020-01-04 13:59:43 +01:00
2019-12-17 20:39:43 +01:00
2023-08-30 16:35:16 +02:00
2023-02-25 11:50:31 +01:00
2022-07-02 16:18:08 +02:00
2020-02-28 16:36:03 +01:00
2019-07-31 07:28:25 +02:00
2020-05-22 20:21:07 +08:00
2019-04-05 22:31:26 +02:00
2019-12-05 15:36:51 +01:00
2018-12-08 13:03:40 +01:00
2021-12-25 18:03:37 +05:30
2018-09-19 22:43:46 +02:00
2025-12-24 11:21:42 +00:00
2022-09-07 17:56:45 +05:30
2020-03-03 02:02:07 +08:00
2023-11-08 11:21:08 +01:00
2020-03-26 16:00:35 +08:00
2021-12-25 18:03:37 +05:30
2019-11-12 19:18:30 +01:00
2025-09-01 11:37:06 +02:00
2019-12-13 07:14:20 -08:00
2025-12-24 11:17:15 +00:00
2020-04-02 16:34:36 +02:00
2020-12-29 13:47:00 +01:00
2020-01-06 18:33:56 +00:00
2020-10-01 13:12:31 +02:00
2020-03-13 15:28:37 +00:00
2023-08-11 11:33:46 +02:00
2025-12-24 11:20:16 +00:00
2023-03-22 13:26:16 +01:00
2021-12-08 08:46:53 +01:00
2025-08-27 18:30:56 +05:30
2020-01-27 14:46:43 +01:00
2022-06-25 11:46:39 +02:00
2025-12-24 11:20:13 +00:00
2019-07-10 09:14:20 -07:00
2021-12-25 18:03:37 +05:30
2018-10-03 17:00:55 -07:00
2021-05-22 10:57:35 +02:00
2019-05-31 06:47:23 -07:00
2020-03-03 04:05:03 +08:00
2020-04-16 17:06:03 +08:00
2020-08-01 00:48:35 +08:00
2020-03-03 04:11:18 +08:00
2020-01-09 14:58:35 -08:00
2019-03-13 14:03:20 -07:00
2021-03-17 16:34:35 +01:00
2021-02-23 14:00:30 +01:00
2020-04-24 08:00:31 +02:00
2020-04-16 17:06:03 +08:00
2020-04-24 08:01:20 +02:00
2025-12-24 11:20:53 +00:00
2023-02-06 07:46:33 +01:00
2021-03-07 11:27:45 +01:00
2021-12-25 18:03:37 +05:30
2018-11-13 11:15:11 -08:00
2023-08-11 11:33:50 +02:00
2020-03-03 02:02:49 +08:00
2021-03-24 11:39:32 +01:00
2020-03-03 00:11:39 +08:00
2020-11-18 18:27:52 +01:00
2019-12-21 10:47:36 +01:00
2020-06-05 16:41:06 +08:00
2023-01-18 09:26:09 +01:00
2022-06-25 11:46:38 +02:00
2021-12-25 18:03:37 +05:30
2018-09-19 22:43:38 +02:00
2025-12-24 11:20:14 +00:00
2020-12-29 13:47:00 +01:00
2020-08-21 09:48:02 +02:00
2021-05-22 10:57:29 +02:00
2022-07-29 17:06:53 +02:00
2023-05-21 20:35:03 +05:30
2025-08-27 17:12:00 +05:30
2021-03-30 14:40:09 +02:00
2020-09-09 19:35:54 +02:00
2021-12-25 18:03:37 +05:30
2019-02-15 08:09:14 +01:00
2020-02-27 19:24:11 -08:00
2025-12-24 11:16:57 +00:00
2021-12-25 18:03:37 +05:30
2021-03-24 11:05:02 +01:00
2023-05-30 12:38:38 +01:00
2025-08-27 18:30:57 +05:30
2025-12-24 11:22:31 +00:00
2020-06-20 10:25:16 +02:00
2022-03-16 12:57:09 +01:00
2023-08-30 16:35:12 +02:00
2019-04-17 08:37:53 +02:00
2021-03-25 02:06:30 +00:00
2022-03-16 12:57:09 +01:00
2021-12-25 18:03:37 +05:30
2020-03-03 04:07:53 +08:00
2018-09-19 22:43:48 +02:00
2021-12-25 18:03:37 +05:30
2019-07-21 09:04:37 +02:00
2023-05-17 11:11:43 +02:00
2020-04-02 16:34:36 +02:00
2021-12-14 10:16:55 +01:00
2021-12-25 18:03:37 +05:30
2020-04-09 15:28:36 +00:00
2023-08-20 12:32:54 +05:30
2020-08-21 11:00:26 +02:00
2021-12-25 18:03:37 +05:30
2021-03-07 11:46:40 +01:00