All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] printk: Fix seq check inside devkmsg_read()
@ 2022-01-18 11:34 Mukesh Ojha
  2022-01-18 13:20 ` John Ogness
  0 siblings, 1 reply; 2+ messages in thread
From: Mukesh Ojha @ 2022-01-18 11:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: john.ogness, rostedt, senozhatsky, pmladek, Mukesh Ojha

prb_read_valid() could return a record whose seq number can be
newer than the requested one. In that case, we allow the reading
of the data instead of erroring out.

This commit fixes this by correcting the check.

Fixes: ce6de43a547b6e01a3 ("printk: avoid prb_first_valid_seq() where possible")
Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 kernel/printk/printk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 155229f..53b09b98 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -738,7 +738,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
 			goto out;
 	}
 
-	if (r->info->seq != atomic64_read(&user->seq)) {
+	if (r->info->seq < atomic64_read(&user->seq)) {
 		/* our last seen message is gone, return error and reset */
 		atomic64_set(&user->seq, r->info->seq);
 		ret = -EPIPE;
-- 
2.7.4


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

* Re: [PATCH] printk: Fix seq check inside devkmsg_read()
  2022-01-18 11:34 [PATCH] printk: Fix seq check inside devkmsg_read() Mukesh Ojha
@ 2022-01-18 13:20 ` John Ogness
  0 siblings, 0 replies; 2+ messages in thread
From: John Ogness @ 2022-01-18 13:20 UTC (permalink / raw)
  To: Mukesh Ojha, linux-kernel; +Cc: rostedt, senozhatsky, pmladek, Mukesh Ojha

On 2022-01-18, Mukesh Ojha <quic_mojha@quicinc.com> wrote:
> prb_read_valid() could return a record whose seq number can be
> newer than the requested one. In that case, we allow the reading
> of the data instead of erroring out.

The EPIPE error is intentional. It informs the devkmsg reader that a
record was missed.

For simple readers, like cat(1), this means that the kernel messages
cannot be read completely reliably. We talked about this a while back
[0] because initially I wanted to do what your patch does. In the end it
was agreed that readers of /dev/kmsg must implement EPIPE handling for
missed records.

John Ogness

[0] https://lore.kernel.org/all/87pneiyv12.fsf@linutronix.de

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

end of thread, other threads:[~2022-01-18 13:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18 11:34 [PATCH] printk: Fix seq check inside devkmsg_read() Mukesh Ojha
2022-01-18 13:20 ` John Ogness

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.