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=1795921481; b=Z8vKeTl2woBzRHDdMcbJrnaY+qs28PGBAHaHmIBYItVuVeEsV1j+L85vzkX46On+Ft87 YhtAHqKgUfOtjnDIZSNlD3uXpVd7kTAcOdaGETXf9to9d1XykxQqRWdY9/muO7CkmR9QK 1Lam+wRCSIdHjXTQMAMGNJ+Knuxv5JlO7HnL8Z16sl2QMPOk4GwQ9gUb1aqwgaGOpQn14 B2biFPTnNftKLj4J02GdyTHMBwh3w7IaowRvAS3+Am1GTX2VhUGr6pYd5dFRgWGuT9vjP ZKbgbV46fPHwMQAKutyFpDn4kTIRk/91s/bQaQ6G6px5h6bR2RtvU7PfkGSgriOlnkw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795921481; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=N5xDjAJ0JorD6OjssrhHovBVdoz4SxHgSEe7VtSOSzE=; b=CBv88IHCHxRf4n72/JWC/Dh0PNl/5KxvsYf7QUjelR2j3iav6vguG5/xfQUU9Lrx8F+j XKYAh5q4qyF5fj+ZGKB/4XXkdrxlGd3ONDyEJVxBqCqREu0hi3juKodx9AWiZ4GaA7giZ F/o4rrsa9pRC64yF/bG7nL1zx4HpiHawLp0So4J9vJG+nmATZpI9ffHeg6lLPvukW3cYb 5sJPwnt97NU5CgbEhSPWKZ9vfJ3qTKm6HhFyVqNPgcy25Vvsf0yw1Haza79ppAOrnyZku QKCukzWoYdVAwiTpgCe6HuklQcBXZqtY3YdgGVbHWgWdB+mz6tsaavQugtu1mEh63zQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=kBOmMqgk; 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 E3AEE606A31C for ; Sun, 29 Nov 2026 03:04:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=kBOmMqgk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 911EB1F000C1; Sun, 29 Nov 2026 03:04:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1795921480; bh=N5xDjAJ0JorD6OjssrhHovBVdoz4SxHgSEe7VtSOSzE=; h=Date:To:From:In-Reply-To:References:Subject; b=kBOmMqgkASCtz6F1Gogg6UzLgbwen8HyyroKfDRJXhRloXmbL5opwUBHLhgeCuLHu mwJJnKUA83CplW6aTpVYbtDnnYcktEA0lcGbka3WBlK2uVCIsB8yyrGxnz6dJ6Vfce 7e41oY8cRu2TdzjzwO7iFFXHbZ1VjyEI2wBcalh4= Date: Sat, 28 Nov 2026 19:04:40 -0800 To: mm-commits@vger.kernel.org,listdansp@mail.ru,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261128004018.135865-1-listdansp@mail.ru> References: <20261128004018.135865-1-listdansp@mail.ru> Subject: + lib-interval_tree_test-fix-division-by-zero-on-a-zero-endpoint.patch added to mm-nonmm-unstable branch Message-Id: <20261129030440.911EB1F000C1@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: lib: interval_tree_test: fix division by zero on a zero endpoint has been added to the -mm mm-nonmm-unstable branch. Its filename is lib-interval_tree_test-fix-division-by-zero-on-a-zero-endpoint.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/lib-interval_tree_test-fix-division-by-zero-on-a-zero-endpoint.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Danila Chernetsov Subject: lib: interval_tree_test: fix division by zero on a zero endpoint Date: Sat, 28 Nov 2026 00:40:18 +0000 The test draws an interval endpoint with last = (prandom_u32_state(&rnd) >> 4) % max_endpoint; so last is in [0, max_endpoint), and then draws the start with start = (prandom_u32_state(&rnd) >> 4) % last; When last is zero this is a division by zero. The result is undefined, and on x86 it triggers a divide error and causes a kernel oops during module initialization. Commit c1fff9794a16 ("lib: interval_tree_test: validate benchmark parameters") rejects max_endpoint values below 2, so the case where every endpoint is zero is already excluded. It does not prevent an individual draw from being zero. With max_endpoint=2 about half of the draws are zero, and with the default max_endpoint of ~0 it takes a shifted random value of zero, roughly 1 in 2^28 per draw. The same two-statement pattern is used in init() to generate the nodes and in intersection_range_check() and span_iteration_check() to generate search ranges, so all three are affected. The only interval whose last endpoint is 0 is the point [0, 0], and the tree allows start == last. When last is zero, use that point and skip the modulo. Behavior for last > 0 is unchanged. Found by Linux Verification Center (linuxtesting.org) with SVACE. Link: https://patch.msgid.link/20261128004018.135865-1-listdansp@mail.ru Fixes: a8ec14d4f6aa ("lib/interval_tree_test.c: allow users to limit scope of endpoint") Fixes: 82114e45131f ("lib/interval_tree: add test case for interval_tree_iter_xxx() helpers") Fixes: ccaf3efceefc ("lib/interval_tree: add test case for span iteration") Signed-off-by: Danila Chernetsov Signed-off-by: Andrew Morton lib/interval_tree_test.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/lib/interval_tree_test.c~lib-interval_tree_test-fix-division-by-zero-on-a-zero-endpoint +++ a/lib/interval_tree_test.c @@ -48,7 +48,8 @@ static void init(void) for (i = 0; i < nnodes; i++) { u32 b = (prandom_u32_state(&rnd) >> 4) % max_endpoint; - u32 a = (prandom_u32_state(&rnd) >> 4) % b; + /* A zero endpoint is the point [0, 0], not a divisor. */ + u32 a = b ? (prandom_u32_state(&rnd) >> 4) % b : 0; nodes[i].start = a; nodes[i].last = b; @@ -165,7 +166,8 @@ static int intersection_range_check(void last = ULONG_MAX; } else { last = (prandom_u32_state(&rnd) >> 4) % max_endpoint; - start = (prandom_u32_state(&rnd) >> 4) % last; + /* A zero endpoint is the point [0, 0], not a divisor. */ + start = last ? (prandom_u32_state(&rnd) >> 4) % last : 0; } /* Walk nodes to mark intersection nodes */ @@ -272,7 +274,8 @@ static int span_iteration_check(void) last = ULONG_MAX; } else { last = (prandom_u32_state(&rnd) >> 4) % max_endpoint; - start = (prandom_u32_state(&rnd) >> 4) % last; + /* A zero endpoint is the point [0, 0], not a divisor. */ + start = last ? (prandom_u32_state(&rnd) >> 4) % last : 0; } mas_span.first_index = start; _ Patches currently in -mm which might be from listdansp@mail.ru are lib-interval_tree_test-fix-division-by-zero-on-a-zero-endpoint.patch