[PATCH] tracing/osnoise: reject a zero sample runtime

From: Kyuwon Cho

Date: Thu Dec 03 2026 - 11:44:54 EST


The osnoise runtime parameter accepts zero, allowing the tracer to emit a
sample whose runtime is zero. Reading that sample from trace divides the
available CPU time by the zero runtime in trace_osnoise_print().

Set the runtime parameter minimum to one microsecond so every emitted
sample has a valid denominator.

Fixes: bce29ac9ce0b ("trace: Add osnoise tracer")
Signed-off-by: Kyuwon Cho <kyuwon.cho@xxxxxxxx>
---
The issue was found by an LLM-guided test generator that we are
developing as a research prototype.

The reproducer mounts tracefs, writes zero to osnoise/runtime_us, enables
the osnoise tracer, and reads its trace. Access to tracefs requires root
in the initial namespace.

The decoded trace is:

Oops: divide error: 0000 [#1] SMP KASAN NOPTI
RIP: 0010:trace_osnoise_print (kernel/trace/trace_output.c:1601)
Call Trace:
print_trace_line (kernel/trace/trace.c:3090 kernel/trace/trace.c:3256)
seq_read_iter (fs/seq_file.c:273)
seq_read (fs/seq_file.c:163)
vfs_read (fs/read_write.c:552)

The patch was tested on v7.4-rc5 and rebased onto tracing commit
175e5f3eddc6 ("tracing: Use test_bit() in event_enable_count_probe()").

kernel/trace/trace_osnoise.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index fbba42286747..f0af4133a506 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -2648,11 +2648,13 @@ static int timerlat_fd_release(struct inode *inode, struct file *file)
/*
* osnoise/runtime_us: cannot be greater than the period.
*/
+static u64 osnoise_min_runtime = 1;
+
static struct trace_min_max_param osnoise_runtime = {
.lock = &interface_lock,
.val = &osnoise_data.sample_runtime,
.max = &osnoise_data.sample_period,
- .min = NULL,
+ .min = &osnoise_min_runtime,
};

/*
--
2.43.0