From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796319205; b=Z2BuF0ejEHF358aLORCTcu0ADbhcNCs60T/nfgaOu/xvlrdzNlBioubQIH2Eo+Ucm/Wj MIE8DU8wvP1Y52KBHOlN4GBXilAT503INVqcDEWdvufSe2Na8BU79Mte8Mlbl0shb5uz8 XogvwQTGmPsvCTM+Q3IpEFmSgGAPeUO5jlL81Q2/LlPrmYxWdlw/rF/iLB9wamsa/KjN3 vCPz2wwTXohBC+yS3O3wDaeFtGJkJD+NKh2Ebv//93qpWAE3at/kmVcjiCbGAcDGBhk/1 SY9ubNL4rLiSVsF3FnwPBfa5P9fG46Cw1Sxim6PNt/yM61a6lug3jkZY8WD88L8MHHA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796319205; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=blJ0Cw9+KODk7PC5NcKac0CniGzm33FQf8alZygRtBc=; b=Kt3t0g0YY+PpFfxzO4KXdUxLm7j43BSqSOmV0m76ff/WkPvjjcs9X99/dPPQ0BS781F5 i5TPnbpkbnYGUGXx1x9vOvR+SZ+IHJ+uF3WB37/o5t+9zVQ1LK9YZQAT0quyw/SaNZFuK BI/S9ApY/bdEDhlPVcAmsq4fsa9HS5Vn48vnI02OwyKp8RHqlVVnjLniJqWBFBlEUWVty 8lfPce6SLruweDnSb9NHNhT4ncX2ykuVco66DIozLln387ErgRvOhwNOjNPt2QZINFxqY bqMw0kjHh0gyYoK/bbJlBJantRY5gdJAiL2mTlHzG6hXanp3VOKeUjBZaFc49LOAaqA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SPJUm5as; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03BA1606A32C for ; Thu, 3 Dec 2026 17:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SPJUm5as Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A0421F000C1; Thu, 3 Dec 2026 17:33:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796319204; bh=blJ0Cw9+KODk7PC5NcKac0CniGzm33FQf8alZygRtBc=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=SPJUm5asVC6pyM/5JpyA1TAFmlhVmWEu9UNxpf+F+kJX/diA8MXgf2l8c0jzA9dpK i5cxmdoyp36mY4IjuGikkPEF8phTUGZD/FXwhkRH5h2lNoD34zwT2vqh1E0B5JDCDH 9Bam/wyZQEIyBRUyFzqXnLYDLk4K3/j4lN0yYiRNb0DriyVpwTFNlTVLSgeRlpaI43 hDxGDsHQ5fTDrDetVfWrVGyp0kurqFPQSWpQF/NlEPiMRhjqombLNuNd3DYdRdPM+L D79GWr49tFGp6izQ6VCElkp8W+BE7qRpMFGSzCHx4JywvZO3sYm4dadmq16uT5TUDS hZzg55k5a48Jw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] tracing/osnoise: reject a zero sample runtime Reply-To: sashiko-reviews@lists.linux.dev To: "Kyuwon Cho" Cc: linux-trace-kernel@vger.kernel.org In-Reply-To: <179620722295.2187910.14090340832228644346@skku.edu> References: <179620722295.2187910.14090340832228644346@skku.edu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 17:33:24 +0000 X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] tracing/osnoise: sample_runtime overflow and unguarded do_div() still oops - [Medium] tracing/osnoise: early kthread_should_stop() in run_osnoise() emits 0 runtime -- commit 0bc0514d9a266d7169b712fb53eb8b8e5f3c1884 Author: Kyuwon Cho tracing/osnoise: reject a zero sample runtime This commit sets a lower bound of one microsecond on the osnoise/runtime_us parameter to prevent emitting zero-runtime samples that trigger a divide error in trace_osnoise_print(). > diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c > index fbba422867474..f0af4133a506a 100644 > --- a/kernel/trace/trace_osnoise.c > +++ b/kernel/trace/trace_osnoise.c > @@ -2648,11 +2648,13 @@ static int timerlat_fd_release(struct inode *inod= e, struct file *file) > /* > * osnoise/runtime_us: cannot be greater than the period. > */ > +static u64 osnoise_min_runtime =3D 1; > + > static struct trace_min_max_param osnoise_runtime =3D { > .lock =3D &interface_lock, > .val =3D &osnoise_data.sample_runtime, > .max =3D &osnoise_data.sample_period, > - .min =3D NULL, > + .min =3D &osnoise_min_runtime, > }; [Severity: High] Can sample_runtime still overflow to zero in run_osnoise() because osnoise_period has no upper bound? osnoise_period sets .max =3D NULL, so userspace can write 1ULL << 61 (2305843009213693952) to osnoise/period_us and then osnoise/runtime_us. In run_osnoise(), osnoise_data.sample_runtime * NSEC_PER_USEC wraps u64 to 0, causing the loop to exit with total < 1000 ns and emit s.runtime =3D= =3D 0, which still triggers a divide-by-zero oops in trace_osnoise_print(). In addition, trace_osnoise_print() passes u64 field->runtime to do_div(), which truncates the divisor to 32 bits, so any runtime that is a multiple of 2^32 microseconds also divides by zero and runtimes >=3D 2^32 us compute the wrong percentage. Adding an upper bound to osnoise_period and guarding field->runtime =3D=3D 0 with div64_u64() in trace_osnoise_print() would cover both cases. [Severity: Medium] Does run_osnoise() still emit a zero-runtime sample if the kthread is stopped before the first microsecond elapses? Control paths like osnoise_cpus_write() call stop_per_cpu_kthreads() while instances are still registered in osnoise_instances: CPU0 (osnoise kthread) CPU1 (osnoise_cpus_write) run_osnoise() start =3D time_get() do { ... } stop_per_cpu_kthreads() kthread_stop() while (total < runtime && !kthread_should_stop()) <-- exits with total < 1000 ns s.runtime =3D time_to_us(total) <-- truncates to 0 record_osnoise_sample(&s) Reading that committed entry then hits the same divide-by-zero oops in trace_osnoise_print(). Skipping samples when s.runtime =3D=3D 0 (or guardi= ng the division in trace_osnoise_print()) would prevent this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/179620722295.218791= 0.14090340832228644346@skku.edu?part=3D1