Skip to content

Commit aa8b25b

Browse files
committed
block: prevent division by zero in blk_rq_stat_sum()
jira LE-1907 cve CVE-2024-35925 Rebuild_History Non-Buildable kernel-4.18.0-553.16.1.el8_10 commit-author Roman Smirnov <[email protected]> commit 93f52fb The expression dst->nr_samples + src->nr_samples may have zero value on overflow. It is necessary to add a check to avoid division by zero. Found by Linux Verification Center (linuxtesting.org) with Svace. Signed-off-by: Roman Smirnov <[email protected]> Reviewed-by: Sergey Shtylyov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]> (cherry picked from commit 93f52fb) Signed-off-by: Jonathan Maple <[email protected]>
1 parent ded3d3d commit aa8b25b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/blk-stat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void blk_rq_stat_init(struct blk_rq_stat *stat)
2727
/* src is a per-cpu stat, mean isn't initialized */
2828
void blk_rq_stat_sum(struct blk_rq_stat *dst, struct blk_rq_stat *src)
2929
{
30-
if (!src->nr_samples)
30+
if (dst->nr_samples + src->nr_samples <= dst->nr_samples)
3131
return;
3232

3333
dst->min = min(dst->min, src->min);

0 commit comments

Comments
 (0)