Files
linux-stable-mirror/lib
Josh Law 20909df31b lib/ts_kmp: fix integer overflow in pattern length calculation
commit 8cdf30813e upstream.

The ts_kmp algorithm stores its prefix_tbl[] table and pattern in a single
allocation sized from the pattern length.  If the prefix_tbl[] size
calculation wraps, the resulting allocation can be too small and
subsequent pattern copies can overflow it.

Fix this by rejecting zero-length patterns and by using overflow helpers
before calculating the combined allocation size.


This fixes a potential heap overflow.  The pattern length calculation can
wrap during a size_t addition, leading to an undersized allocation.
Because the textsearch library is reachable from userspace via Netfilter's
xt_string module, this is a security risk that should be backported to LTS
kernels.

Link: https://lkml.kernel.org/r/20260308202028.2889285-2-objecting@objecting.org
Signed-off-by: Josh Law <objecting@objecting.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-06-01 17:29:18 +02:00
..
2024-07-18 13:05:40 +02:00
2024-10-17 15:07:50 +02:00
2025-10-29 14:01:15 +01:00
2022-06-22 14:13:18 +02:00
2022-06-22 14:13:18 +02:00
2023-06-21 15:45:35 +02:00