* [PATCH RESEND] char/hpet: Fix missing TASK_RUNNING before put_user() in hpet_read()
@ 2026-11-17 11:16 Habil Eren Türker
2026-11-19 15:02 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: Habil Eren Türker @ 2026-11-17 11:16 UTC (permalink / raw)
To: Clemens Ladisch, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel
Cc: Habil Eren Türker, syzbot+fc3a448093c17a792368
hpet_read() sets the current task state to TASK_INTERRUPTIBLE within
the read loop. However, when data becomes available, it exits the loop
without restoring the TASK_RUNNING state. The subsequent put_user()
operation may go to sleep due to a page fault, which triggers:
do not call blocking ops when !TASK_RUNNING; state=1 set at
[<ffffffff85b6d1eb>] hpet_read+0x21b/0x6a0 drivers/char/hpet.c:285
WARNING: kernel/sched/core.c:9187 at __might_sleep+0x94/0xc0
kernel/sched/core.c:9187, CPU#0: syz.0.873/9126
Call Trace:
__might_fault+0x8b/0x140 mm/memory.c:7480
hpet_read+0x56f/0x6a0 drivers/char/hpet.c:309
do_loop_readv_writev fs/read_write.c:848 [inline]
do_loop_readv_writev fs/read_write.c:836 [inline]
vfs_readv+0x5d8/0x8d0 fs/read_write.c:1021
do_preadv+0x1ac/0x270 fs/read_write.c:1133
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Restore TASK_RUNNING before breaking out of the loop.
Reported-by: syzbot+fc3a448093c17a792368@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=fc3a448093c17a792368
Signed-off-by: Habil Eren Türker <habilerenturker@hotmail.com>
---
drivers/char/hpet.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 285c6037417a..7ad319c6d942 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -290,6 +290,7 @@ hpet_read(struct file *file, char __user *buf, size_t count, loff_t * ppos)
spin_unlock_irq(&hpet_lock);
if (data) {
+ __set_current_state(TASK_RUNNING);
break;
} else if (file->f_flags & O_NONBLOCK) {
retval = -EAGAIN;
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND] char/hpet: Fix missing TASK_RUNNING before put_user() in hpet_read()
2026-11-17 11:16 [PATCH RESEND] char/hpet: Fix missing TASK_RUNNING before put_user() in hpet_read() Habil Eren Türker
@ 2026-11-19 15:02 ` Greg Kroah-Hartman
2026-11-19 18:28 ` Habil Eren Türker
0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2026-11-19 15:02 UTC (permalink / raw)
To: Habil Eren Türker
Cc: Clemens Ladisch, Arnd Bergmann, linux-kernel,
syzbot+fc3a448093c17a792368
On Tue, Nov 17, 2026 at 11:16:37AM +0000, Habil Eren Türker wrote:
> hpet_read() sets the current task state to TASK_INTERRUPTIBLE within
> the read loop. However, when data becomes available, it exits the loop
> without restoring the TASK_RUNNING state. The subsequent put_user()
> operation may go to sleep due to a page fault, which triggers:
>
> do not call blocking ops when !TASK_RUNNING; state=1 set at
> [<ffffffff85b6d1eb>] hpet_read+0x21b/0x6a0 drivers/char/hpet.c:285
>
> WARNING: kernel/sched/core.c:9187 at __might_sleep+0x94/0xc0
> kernel/sched/core.c:9187, CPU#0: syz.0.873/9126
>
> Call Trace:
> __might_fault+0x8b/0x140 mm/memory.c:7480
> hpet_read+0x56f/0x6a0 drivers/char/hpet.c:309
> do_loop_readv_writev fs/read_write.c:848 [inline]
> do_loop_readv_writev fs/read_write.c:836 [inline]
> vfs_readv+0x5d8/0x8d0 fs/read_write.c:1021
> do_preadv+0x1ac/0x270 fs/read_write.c:1133
> do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
> do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> Restore TASK_RUNNING before breaking out of the loop.
>
> Reported-by: syzbot+fc3a448093c17a792368@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=fc3a448093c17a792368
> Signed-off-by: Habil Eren Türker <habilerenturker@hotmail.com>
> ---
> drivers/char/hpet.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
> index 285c6037417a..7ad319c6d942 100644
> --- a/drivers/char/hpet.c
> +++ b/drivers/char/hpet.c
> @@ -290,6 +290,7 @@ hpet_read(struct file *file, char __user *buf, size_t count, loff_t * ppos)
> spin_unlock_irq(&hpet_lock);
>
> if (data) {
> + __set_current_state(TASK_RUNNING);
Shouldn't this be set_current_state(TASK_RUNNING) instead?
And why hasn't this ever been noticed before, what changed to cause it
to show up now? And because of that, why is there not a Fixes: tag?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND] char/hpet: Fix missing TASK_RUNNING before put_user() in hpet_read()
2026-11-19 15:02 ` Greg Kroah-Hartman
@ 2026-11-19 18:28 ` Habil Eren Türker
2026-11-19 21:16 ` Arnd Bergmann
0 siblings, 1 reply; 4+ messages in thread
From: Habil Eren Türker @ 2026-11-19 18:28 UTC (permalink / raw)
To: gregkh
Cc: clemens, arnd, Habil Eren Türker, linux-kernel,
syzbot+fc3a448093c17a792368
On Thu, Nov 19, 2026 at 03:02:07PM +0000, Greg Kroah-Hartman wrote:
> Shouldn't this be set_current_state(TASK_RUNNING) instead?
Thanks for the review.
You're right, set_current_state(TASK_RUNNING) is more appropriate here.
I don't have a specific reason for choosing __set_current_state() in the
original patch. I'll correct it.
> And why hasn't this ever been noticed before, what changed to cause it
> to show up now? And because of that, why is there not a Fixes: tag?
My initial clone was shallow, so I fetched the full history and repeated
the investigation. I traced the history of hpet_read().
The TASK_INTERRUPTIBLE state handling followed by the put_user() call is
already present in the earliest available Git history, in the initial Git
import (1da177e4c3f4). I couldn't identify a later commit that introduced
this behavior.
The 2010 (54066a57c584) and 2024 (4e60131d0d36) changes I examined do not
appear to have introduced the issue. I couldn't identify a suitable commit
for a `Fixes:` tag.
I haven't identified what changed in the testing or execution conditions
that caused this issue to be detected now.
Regards,
Türker
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND] char/hpet: Fix missing TASK_RUNNING before put_user() in hpet_read()
2026-11-19 18:28 ` Habil Eren Türker
@ 2026-11-19 21:16 ` Arnd Bergmann
0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2026-11-19 21:16 UTC (permalink / raw)
To: Habil Eren Türker, Greg Kroah-Hartman
Cc: Clemens Ladisch, linux-kernel, syzbot+fc3a448093c17a792368
On Thu, Nov 19, 2026, at 19:28, Habil Eren Türker wrote:
> On Thu, Nov 19, 2026 at 03:02:07PM +0000, Greg Kroah-Hartman wrote:
>> And why hasn't this ever been noticed before, what changed to cause it
>> to show up now? And because of that, why is there not a Fixes: tag?
>
> My initial clone was shallow, so I fetched the full history and repeated
> the investigation. I traced the history of hpet_read().
> The TASK_INTERRUPTIBLE state handling followed by the put_user() call is
> already present in the earliest available Git history, in the initial Git
> import (1da177e4c3f4). I couldn't identify a later commit that introduced
> this behavior.
>
> The 2010 (54066a57c584) and 2024 (4e60131d0d36) changes I examined do not
> appear to have introduced the issue. I couldn't identify a suitable commit
> for a `Fixes:` tag.
I think the warning came from 8eb23b9f35aa ("sched: Debug nested sleeps"),
the behavior seems to be older. Maybe by that time user had moved
on from /dev/hpet to posix timers?
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-19 21:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 11:16 [PATCH RESEND] char/hpet: Fix missing TASK_RUNNING before put_user() in hpet_read() Habil Eren Türker
2026-11-19 15:02 ` Greg Kroah-Hartman
2026-11-19 18:28 ` Habil Eren Türker
2026-11-19 21:16 ` Arnd Bergmann
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®