* [PATCH v4] Input: atkbd - fix uaf in atkbd_set_repeat_rate
@ 2026-08-29 13:59 Jeffin Philip
2026-08-29 16:34 ` Dmitry Torokhov
0 siblings, 1 reply; 4+ messages in thread
From: Jeffin Philip @ 2026-08-29 13:59 UTC (permalink / raw)
To: dmitry.torokhov
Cc: linux-input, linux-kernel, Jeffin Philip, syzbot+1e2ef9bcb29af666b2e6
atkbd_disable() marks atkbd as disabled to prevent any work
event to be executed, however this can race with atkbd_event_work().
If a pending work passes the atkbd->enabled check and atkbd_disable()
runs after in disconnect, it could dereference dev which is freed in
disconnect following atkbd being marked disabled. Fix this by adding
disable_delayed_work_sync() which drops all work events preventing
any rescheduling after atkbd is marked disabled.
Reported-by: syzbot+1e2ef9bcb29af666b2e6@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1e2ef9bcb29af666b2e6
Fixes: 0ef7a26af127 ("Input: atkbd - fix canceling event_work in disconnect")
Signed-off-by: Jeffin Philip <jeffinphilip14@gmail.com>
---
Changelog:
- Changed in v4:
Changed location of disable_pending_work_sync() after input_unregister_device()
as per Dmitry's suggestion.
- Changes in v3:
Rewrote the patch to include disable_delayed_work_sync() as per
Dmitry's suggestion.
- Changes in v2:
Added a check for atkbd->enabled so userspace cannot queue events after
atkbd_disable.
---
drivers/input/keyboard/atkbd.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 5736f4bc5a50..41a0d55dae0e 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -966,12 +966,9 @@ static void atkbd_disconnect(struct serio *serio)
input_unregister_device(atkbd->dev);
/*
- * Make sure we don't have a command in flight.
- * Note that since atkbd->enabled is false event work will keep
- * rescheduling itself until it gets canceled and will not try
- * accessing freed input device or serio port.
+ * Prevent work from being rescheduled after atkbd is marked disabled
*/
- cancel_delayed_work_sync(&atkbd->event_work);
+ disable_delayed_work_sync(&atkbd->event_work);
serio_close(serio);
serio_set_drvdata(serio, NULL);
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] Input: atkbd - fix uaf in atkbd_set_repeat_rate
2026-08-29 13:59 [PATCH v4] Input: atkbd - fix uaf in atkbd_set_repeat_rate Jeffin Philip
@ 2026-08-29 16:34 ` Dmitry Torokhov
2026-08-30 8:14 ` Jeffin Philip
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2026-08-29 16:34 UTC (permalink / raw)
To: Jeffin Philip; +Cc: linux-input, linux-kernel, syzbot+1e2ef9bcb29af666b2e6
On Sat, Aug 29, 2026 at 07:29:59PM +0530, Jeffin Philip wrote:
> atkbd_disable() marks atkbd as disabled to prevent any work
> event to be executed, however this can race with atkbd_event_work().
> If a pending work passes the atkbd->enabled check and atkbd_disable()
> runs after in disconnect, it could dereference dev which is freed in
> disconnect following atkbd being marked disabled. Fix this by adding
> disable_delayed_work_sync() which drops all work events preventing
> any rescheduling after atkbd is marked disabled.
>
> Reported-by: syzbot+1e2ef9bcb29af666b2e6@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=1e2ef9bcb29af666b2e6
> Fixes: 0ef7a26af127 ("Input: atkbd - fix canceling event_work in disconnect")
> Signed-off-by: Jeffin Philip <jeffinphilip14@gmail.com>
> ---
> Changelog:
> - Changed in v4:
> Changed location of disable_pending_work_sync() after input_unregister_device()
> as per Dmitry's suggestion.
Actually I think I was wrong and Sashiko was right. I will probably pick
your v3 but I do not like that we do not clean up/reset LEDs properly
on disconnect. I will have to think about it some more...
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] Input: atkbd - fix uaf in atkbd_set_repeat_rate
2026-08-29 16:34 ` Dmitry Torokhov
@ 2026-08-30 8:14 ` Jeffin Philip
2026-08-30 8:27 ` Jeffin Philip
0 siblings, 1 reply; 4+ messages in thread
From: Jeffin Philip @ 2026-08-30 8:14 UTC (permalink / raw)
To: dmitry.torokhov
Cc: jeffinphilip14, linux-input, linux-kernel, syzbot+1e2ef9bcb29af666b2e6
On Sat, 29 Aug 2026 09:34:48 -0700, Dmitry Torokhov wrote:
>Actually I think I was wrong and Sashiko was right. I will probably pick
>your v3 but I do not like that we do not clean up/reset LEDs properly
>on disconnect.
Would cleaning up leds cause any weird issues on reconnect? We could reset
LEDs though. Compiled only, but this?
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 41a0d55dae0e..3d0e58be5ba2 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -963,13 +963,16 @@ static void atkbd_disconnect(struct serio *serio)
atkbd_disable(atkbd);
- input_unregister_device(atkbd->dev);
-
/*
* Prevent work from being rescheduled after atkbd is marked disabled
*/
disable_delayed_work_sync(&atkbd->event_work);
+ if (atkbd->write)
+ atkbd_set_leds(atkbd);
+
+ input_unregister_device(atkbd->dev);
+
serio_close(serio);
serio_set_drvdata(serio, NULL);
kfree(atkbd);
Thanks,
Jeffin.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] Input: atkbd - fix uaf in atkbd_set_repeat_rate
2026-08-30 8:14 ` Jeffin Philip
@ 2026-08-30 8:27 ` Jeffin Philip
0 siblings, 0 replies; 4+ messages in thread
From: Jeffin Philip @ 2026-08-30 8:27 UTC (permalink / raw)
To: jeffinphilip14
Cc: dmitry.torokhov, linux-input, linux-kernel, syzbot+1e2ef9bcb29af666b2e6
On Sun, 30 Aug 2026 13:44:15 +0530, Jeffin Philip wrote:
>Would cleaning up leds cause any weird issues on reconnect?
Correction: Would _NOT_ cleaning up leds cause any weird issues
on reconnect?
Thanks,
Jeffin.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-30 8:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-29 13:59 [PATCH v4] Input: atkbd - fix uaf in atkbd_set_repeat_rate Jeffin Philip
2026-08-29 16:34 ` Dmitry Torokhov
2026-08-30 8:14 ` Jeffin Philip
2026-08-30 8:27 ` Jeffin Philip
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®