public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Jitka Plesnikova <jplesnik@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/perl] rawhide: Fix heap buffer out-of-bounds access in regex superlinear cache for large strings (CVE-2026-15534)
Date: Tue, 03 Nov 2026 15:06:34 GMT [thread overview]
Message-ID: <179371839471.1.8534265083493583714.rpms-perl-4f999e8e0707@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/perl
Branch : rawhide
Commit : 4f999e8e0707cbe01e83f87a632799b724f571f6
Author : Jitka Plesnikova <jplesnik@redhat.com>
Date : 2026-11-03T16:05:36+01:00
Stats : +177/-1 in 3 file(s)
URL : https://src.fedoraproject.org/rpms/perl/c/4f999e8e0707cbe01e83f87a632799b724f571f6?branch=rawhide
Log:
Fix heap buffer out-of-bounds access in regex superlinear cache for large strings (CVE-2026-15534)
---
diff --git a/perl-5.45.1-regex-make-superlinear-cache-64-bit-clean.patch b/perl-5.45.1-regex-make-superlinear-cache-64-bit-clean.patch
new file mode 100644
index 0000000..e58e6a9
--- /dev/null
+++ b/perl-5.45.1-regex-make-superlinear-cache-64-bit-clean.patch
@@ -0,0 +1,88 @@
+From 54cf3d44cbbedd17d774e9a37921963e8fd5d0cb Mon Sep 17 00:00:00 2001
+From: David Mitchell <davem@iabyn.com>
+Date: Tue, 30 Jun 2026 12:14:52 +0100
+Subject: [PATCH] regex: make superlinear cache 64-bit clean
+
+(See the previous commit for an explanation of what the SLC is).
+
+The iter and maxiter variables associated with the SLC are currently
+declared as I32. This causes various possible issues, including
+potential out of bounds reads and writes of the cache in the presence of
+very large strings and many WHILEM nodes: for example when the string is
+over 128Mb and there are 16 nodes (the max).
+
+Following on from the previous commit which made iter never be negative,
+this commit changes the variables' type to STRLEN (typically equal to
+U64 on 64-bit systems) and does calculations in a way to avoid potential
+overflows. If an overflow *could* occur, the cache isn't enabled.
+
+Previously, a -ve overflow was "fixed" by setting maxiter to I32_MAX, and
++ve overflows weren't detected.
+
+No tests are added, since this code only affects very large strings
+using lots of memory and iterations, and such tests would crash on small
+memory machines.
+---
+ regexec.c | 23 ++++++++++++++---------
+ regexp.h | 4 ++--
+ 2 files changed, 16 insertions(+), 11 deletions(-)
+
+diff --git a/regexec.c b/regexec.c
+index 29aa73c13c..66e0c09240 100644
+--- a/regexec.c
++++ b/regexec.c
+@@ -9202,22 +9202,27 @@ NULL
+ if (!reginfo->poscache_maxiter) {
+ /* start the countdown: Postpone detection until we
+ * know the match is not *that* much linear. */
+- reginfo->poscache_maxiter
+- = (reginfo->strend - reginfo->strbeg + 1)
+- * (FLAGS(scan)>>4);
+- /* possible overflow for long strings and many CURLYX's */
+- if (reginfo->poscache_maxiter < 0)
+- reginfo->poscache_maxiter = I32_MAX;
+- reginfo->poscache_iter = reginfo->poscache_maxiter;
++ STRLEN len = reginfo->strend - reginfo->strbeg;
++ /* number of participating WHILEMs */
++ U8 n = (FLAGS(scan)>>4);
++
++ /* Only do the calculations and enable the cache if it
++ * won't overflow. This test is equivalent to:
++ * ((len + 1) * n + 7) <= max(STRLEN)
++ */
++ if (len < ((~(STRLEN)0) - 7)/n) {
++ reginfo->poscache_maxiter = (len + 1) * n;
++ reginfo->poscache_iter = reginfo->poscache_maxiter;
++ }
+ }
+
+ if (reginfo->poscache_iter == 1) {
+ reginfo->poscache_iter--;
+ /* initialise cache */
+- const SSize_t size = (reginfo->poscache_maxiter + 7)/8;
++ const STRLEN size = (reginfo->poscache_maxiter + 7)/8;
+ regmatch_info_aux *const aux = reginfo->info_aux;
+ if (aux->poscache) {
+- if ((SSize_t)reginfo->poscache_size < size) {
++ if (reginfo->poscache_size < size) {
+ Renew(aux->poscache, size, char);
+ reginfo->poscache_size = size;
+ }
+diff --git a/regexp.h b/regexp.h
+index 057d9ac501..d5d40e0a56 100644
+--- a/regexp.h
++++ b/regexp.h
+@@ -839,8 +839,8 @@ typedef struct {
+ char *cutpoint; /* (*COMMIT) position (if any) */
+ regmatch_info_aux *info_aux; /* extra fields that need cleanup */
+ regmatch_info_aux_eval *info_aux_eval; /* extra saved state for (?{}) */
+- I32 poscache_maxiter; /* how many whilems todo before S-L cache kicks in */
+- I32 poscache_iter; /* current countdown from _maxiter to zero */
++ STRLEN poscache_maxiter; /* how many whilems todo before S-L cache kicks in */
++ STRLEN poscache_iter; /* current countdown from _maxiter to zero */
+ STRLEN poscache_size; /* size of regmatch_info_aux.poscache */
+ bool intuit; /* re_intuit_start() is the top-level caller */
+ bool is_utf8_pat; /* regex is utf8 */
+--
+2.56.0
+
diff --git a/perl-5.45.1-regex-super-linear-cache-make-countdown-unsigned.patch b/perl-5.45.1-regex-super-linear-cache-make-countdown-unsigned.patch
new file mode 100644
index 0000000..490c667
--- /dev/null
+++ b/perl-5.45.1-regex-super-linear-cache-make-countdown-unsigned.patch
@@ -0,0 +1,75 @@
+From 568e6fd238867bb9e99fa3f47cba3169009239e0 Mon Sep 17 00:00:00 2001
+From: David Mitchell <davem@iabyn.com>
+Date: Tue, 30 Jun 2026 11:19:45 +0100
+Subject: [PATCH] regex super-linear cache: make countdown unsigned
+
+The super-linear cache is a block of flag bits malloc()ed during regex
+execution for patterns such as:
+
+ ((aaa)+)+
+
+which can go exponential in run time. The idea is that after the pattern
+has been executing for a while, the cache is malloced(), and subsequent
+failed iterations set a flag in the cache indicating a fail at this
+position, so that it can be failed quickly if a similar point is
+reached again after backtracking.
+
+The "executing for a while" bit is determined by setting a counter to a
+largish value, then counting down each time a WHILEM node is executed.
+When the count reaches zero, the cache is malloc()ed. When the count
+reaches -1, the cache becomes active, and no more decrements are done.
+
+This commit changes it so that the zero and -1 above become 1 and 0.
+This will allow the counter be made unsigned.
+
+This commit's only side effect is that the SLC will become active one
+iteration earlier than it did before. This isn't really an issue, as the
+current count start value is an extremely vague heuristic: the value
+used at the moment is (string length) x (the number of WHILEM nodes
+which can participate in the SLC).
+
+Actually changing the counter's type to unsigned will be done in the
+next commit.
+---
+ regexec.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/regexec.c b/regexec.c
+index 35a727459c..29aa73c13c 100644
+--- a/regexec.c
++++ b/regexec.c
+@@ -9211,7 +9211,8 @@ NULL
+ reginfo->poscache_iter = reginfo->poscache_maxiter;
+ }
+
+- if (reginfo->poscache_iter-- == 0) {
++ if (reginfo->poscache_iter == 1) {
++ reginfo->poscache_iter--;
+ /* initialise cache */
+ const SSize_t size = (reginfo->poscache_maxiter + 7)/8;
+ regmatch_info_aux *const aux = reginfo->info_aux;
+@@ -9232,11 +9233,10 @@ NULL
+ );
+ }
+
+- if (reginfo->poscache_iter < 0) {
++ if (reginfo->poscache_iter == 0) {
+ /* have we already failed at this position? */
+ SSize_t offset, mask;
+
+- reginfo->poscache_iter = -1; /* stop eventual underflow */
+ offset = (FLAGS(scan) & 0xf) - 1
+ + (locinput - reginfo->strbeg)
+ * (FLAGS(scan)>>4);
+@@ -9252,6 +9252,8 @@ NULL
+ ST.cache_offset = offset;
+ ST.cache_mask = mask;
+ }
++ else
++ reginfo->poscache_iter--;
+ }
+
+ /* Prefer B over A for minimal matching. */
+--
+2.56.0
+
diff --git a/perl.spec b/perl.spec
index 020b1d0..91facb9 100644
--- a/perl.spec
+++ b/perl.spec
@@ -121,7 +121,7 @@ License: GPL-1.0-or-later OR Artistic-1.0-Perl
Epoch: %{perl_epoch}
Version: %{perl_version}
# release number must be even higher, because dual-lived modules will be broken otherwise
-Release: 527%{?dist}
+Release: 528%{?dist}
Summary: Practical Extraction and Report Language
Url: https://www.perl.org/
Source0: https://www.cpan.org/src/5.0/perl-%{perl_version}.tar.xz
@@ -187,6 +187,11 @@ Patch12: perl-5.27.8-hints-linux-Add-lphtread-to-lddlflags.patch
# Pass the correct CFLAGS to dtrace
Patch13: perl-5.28.0-Pass-CFLAGS-to-dtrace.patch
+# Fix out-of-bounds heap reads and writes in regex superlinear cache due to
+# signed 32-bit integer overflow when matching large strings (CVE-2026-15534)
+Patch14: perl-5.45.1-regex-super-linear-cache-make-countdown-unsigned.patch
+Patch15: perl-5.45.1-regex-make-superlinear-cache-64-bit-clean.patch
+
# Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048
Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch
@@ -4228,6 +4233,8 @@ you're not running VMS, this module does nothing.
%patch -P11 -p1
%patch -P12 -p1
%patch -P13 -p1
+%patch -P14 -p1
+%patch -P15 -p1
%patch -P200 -p1
%patch -P201 -p1
%patch -P202 -p1
@@ -4249,6 +4256,8 @@ perl -x patchlevel.h \
'Fedora Patch11: Replace EU::MakeMaker dependency with EU::MM::Utils in IPC::Cmd (bug #1129443)' \
'Fedora Patch12: Link XS modules to pthread library to fix linking with -z defs' \
'Fedora Patch13: Pass the correct CFLAGS to dtrace' \
+ 'Fedora Patch14: Make regex superlinear cache countdown unsigned (CVE-2026-15534)' \
+ 'Fedora Patch15: Make regex superlinear cache 64-bit clean (CVE-2026-15534)' \
'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \
'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
'Fedora Patch202: Add definition of OPTIMIZE to .ph files' \
@@ -7298,6 +7307,10 @@ ln -s /app/bin/perl %{buildroot}/usr/bin/perl
# Old changelog entries are preserved in CVS.
%changelog
+* Tue Nov 03 2026 Jitka Plesnikova <jplesnik@redhat.com> - 4:5.44.0-528
+- Fix heap buffer out-of-bounds access in regex superlinear cache for large
+ strings (CVE-2026-15534)
+
* Thu Jul 23 2026 Jitka Plesnikova <jplesnik@redhat.com> - 4:5.44.0-527
- Perl 5.44 re-rebuild of bootstrapped packages
reply other threads:[~2026-11-03 15:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179371839471.1.8534265083493583714.rpms-perl-4f999e8e0707@fedoraproject.org \
--to=jplesnik@redhat.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox