mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] char/hpet: Fix missing TASK_RUNNING before put_user() in hpet_read()
@ 2026-11-20  9:32 Habil Eren Türker
  2026-11-28 12:12 ` Habil Eren Türker
  0 siblings, 1 reply; 4+ messages in thread
From: Habil Eren Türker @ 2026-11-20  9:32 UTC (permalink / raw)
  To: Clemens Ladisch, Arnd Bergmann, Greg Kroah-Hartman
  Cc: linux-kernel, syzbot+fc3a448093c17a792368,
	Habil Eren Türker, stable

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.

The warning was added with commit 8eb23b9f35aa
("sched: Debug nested sleeps").

The missing state reset was present since the initial Git import,
commit 1da177e4c3f4 ("Linux-2.6.12-rc2").

Reported-by: syzbot+fc3a448093c17a792368@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=fc3a448093c17a792368
Cc: stable@vger.kernel.org
Signed-off-by: Habil Eren Türker <habilerenturker@hotmail.com>
---
Changes in v2:
- Use set_current_state() instead of __set_current_state(),
  as suggested by Greg Kroah-Hartman.
Changes in v3:
- Add Cc: stable@vger.kernel.org since the issue was present
  since the initial Git import, commit 1da177e4c3f4
  ("Linux-2.6.12-rc2").

 drivers/char/hpet.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 285c6037417a..946a3806f664 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 v3] char/hpet: Fix missing TASK_RUNNING before put_user() in hpet_read()
  2026-11-20  9:32 [PATCH v3] char/hpet: Fix missing TASK_RUNNING before put_user() in hpet_read() Habil Eren Türker
@ 2026-11-28 12:12 ` Habil Eren Türker
  2026-11-29 12:22   ` gregkh
  0 siblings, 1 reply; 4+ messages in thread
From: Habil Eren Türker @ 2026-11-28 12:12 UTC (permalink / raw)
  To: Habil Eren Türker
  Cc: arnd, clemens, gregkh, linux-kernel, stable, syzbot+fc3a448093c17a792368

Hi Greg,

Just a gentle ping on this v3 patch.

Regards,
Türker

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] char/hpet: Fix missing TASK_RUNNING before put_user() in hpet_read()
  2026-11-28 12:12 ` Habil Eren Türker
@ 2026-11-29 12:22   ` gregkh
  2026-11-29 15:16     ` Habil Eren Türker
  0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2026-11-29 12:22 UTC (permalink / raw)
  To: Habil Eren Türker
  Cc: arnd, clemens, linux-kernel, stable, syzbot+fc3a448093c17a792368

On Sat, Nov 28, 2026 at 12:12:58PM +0000, Habil Eren Türker wrote:
> Hi Greg,
> 
> Just a gentle ping on this v3 patch.

I have no context here, sorry.

And what is with all of these "context-less" emails these days?  did
some email client get upgraded to never quote anything at all?  Or are
people using LLMs to send emails?  What tool did you use to send this?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] char/hpet: Fix missing TASK_RUNNING before put_user() in hpet_read()
  2026-11-29 12:22   ` gregkh
@ 2026-11-29 15:16     ` Habil Eren Türker
  0 siblings, 0 replies; 4+ messages in thread
From: Habil Eren Türker @ 2026-11-29 15:16 UTC (permalink / raw)
  To: gregkh
  Cc: arnd, clemens, Habil Eren Türker, linux-kernel, stable,
	syzbot+fc3a448093c17a792368

On Sun, Nov 29, 2026 at 01:22:04PM +0100, Greg Kroah-Hartman wrote:
> On Sat, Nov 28, 2026 at 12:12:58PM +0000, Habil Eren Türker wrote:
>> Hi Greg,
>> 
>> Just a gentle ping on this v3 patch.
>
> I have no context here, sorry.
>
> And what is with all of these "context-less" emails these days?  did
> some email client get upgraded to never quote anything at all?  Or are
> people using LLMs to send emails?  What tool did you use to send this?

Hi Greg,

Sorry for the lack of context. I forgot to add it and used git send-email.
I will be more careful next time.

Here is the v3 patch for the context:

> On Fri, Nov 20, 2026 at 09:32:04AM +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.
>> 
>> The warning was added with commit 8eb23b9f35aa
>> ("sched: Debug nested sleeps").
>> 
>> The missing state reset was present since the initial Git import,
>> commit 1da177e4c3f4 ("Linux-2.6.12-rc2").
>> 
>> Reported-by: syzbot+fc3a448093c17a792368@syzkaller.appspotmail.com
>> Closes: https://syzkaller.appspot.com/bug?extid=fc3a448093c17a792368
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Habil Eren Türker <habilerenturker@hotmail.com>
>> ---
>> Changes in v2:
>> - Use set_current_state() instead of __set_current_state(),
>>   as suggested by Greg Kroah-Hartman.
>> Changes in v3:
>> - Add Cc: stable@vger.kernel.org since the issue was present
>>   since the initial Git import, commit 1da177e4c3f4
>>   ("Linux-2.6.12-rc2").
>> 
>>  drivers/char/hpet.c | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
>> index 285c6037417a..946a3806f664 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

Regards,
Türker

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-29 15:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20  9:32 [PATCH v3] char/hpet: Fix missing TASK_RUNNING before put_user() in hpet_read() Habil Eren Türker
2026-11-28 12:12 ` Habil Eren Türker
2026-11-29 12:22   ` gregkh
2026-11-29 15:16     ` Habil Eren Türker

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®