[PATCH] printk: Fix skipped entries after index iterator restart

From: Avi Weiss

Date: Mon Nov 16 2026 - 03:56:20 EST


seq_read_iter() can advance the iterator before the next record
fits in the read buffer. When iteration resumes, pi_start() calls
pi_next() at the saved position and advances past the pending printk
index entry. As a result, index reads can silently omit formats.

Return the entry corresponding to the saved position without
advancing the iterator.

Fixes: 337015573718 ("printk: Userspace format indexing support")
Signed-off-by: Avi Weiss <thnkslprpt@xxxxxxxxx>
---
kernel/printk/index.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/printk/index.c b/kernel/printk/index.c
index a6b27526baaf6..642640a36abe1 100644
--- a/kernel/printk/index.c
+++ b/kernel/printk/index.c
@@ -59,7 +59,7 @@ static void *pi_start(struct seq_file *s, loff_t *pos)
if (*pos == 0)
return SEQ_START_TOKEN;

- return pi_next(s, NULL, pos);
+ return pi_get_entry(s->file->f_inode->i_private, *pos - 1);
}

/*

base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
--
2.43.0