From 6f6ce32882014a7750127852c54fbed0163f0dbd Mon Sep 17 00:00:00 2001 From: Jacob Wang Date: Fri, 16 May 2025 10:47:33 +0800 Subject: [PATCH 1/3] [CVE]update to ruby-2.5.9-114 to #IC8722 update to ruby-2.5.9-114 for CVE-2019-19012 CVE-2021-43809 Project: TC2024080204 Signed-off-by: Jacob Wang --- ...-the-fact-that-lchmod-can-EOPNOTSUPP.patch | 91 -------- ...0-Moved-not-implemented-method-tests.patch | 128 ---------- ..._bug_reporter_add-witout-raising-err.patch | 34 --- ...overflow-related-to-reg-dmax-in-sear.patch | 221 ++++++++++++++++++ ruby.spec | 36 +-- 5 files changed, 232 insertions(+), 278 deletions(-) delete mode 100644 1000-ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch delete mode 100644 1001-ruby-2.8.0-Moved-not-implemented-method-tests.patch delete mode 100644 1002-ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch create mode 100644 ruby-3.5.0-fix-164-Integer-overflow-related-to-reg-dmax-in-sear.patch diff --git a/1000-ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch b/1000-ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch deleted file mode 100644 index 42f47a9..0000000 --- a/1000-ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch +++ /dev/null @@ -1,91 +0,0 @@ -From 29d9f866f686e81818fb9cf402c4fb479decb282 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= - -Date: Thu, 23 Jan 2020 15:33:42 +0900 -Subject: [PATCH 1/2] brace the fact that lchmod(2) can EOPNOTSUPP - -Musl libc has this function as a tiny wrapper of fchmodat(3posix). On -the other hand Linux kernel does not support changing modes of a symlink. -The operation always fails with EOPNOTSUPP. This fchmodat behaviour is -defined in POSIX. We have to take care of such exceptions. ---- - lib/fileutils.rb | 3 ++- - test/pathname/test_pathname.rb | 2 +- - test/ruby/test_notimp.rb | 19 ++++++++++++------- - 3 files changed, 15 insertions(+), 9 deletions(-) - -diff --git a/lib/fileutils.rb b/lib/fileutils.rb -index f56d7f9cb9..1a02d5435e 100644 ---- a/lib/fileutils.rb -+++ b/lib/fileutils.rb -@@ -1242,6 +1242,7 @@ def chmod(mode) - else - File.chmod mode, path() - end -+ rescue Errno::EOPNOTSUPP - end - - def chown(uid, gid) -@@ -1317,7 +1318,7 @@ def copy_metadata(path) - if st.symlink? - begin - File.lchmod mode, path -- rescue NotImplementedError -+ rescue NotImplementedError, Errno::EOPNOTSUPP - end - else - File.chmod mode, path -diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb -index 8a72b8026d..e381d3fa58 100644 ---- a/test/pathname/test_pathname.rb -+++ b/test/pathname/test_pathname.rb -@@ -823,7 +823,7 @@ def test_lchmod - old = path.lstat.mode - begin - path.lchmod(0444) -- rescue NotImplementedError -+ rescue NotImplementedError, Errno::EOPNOTSUPP - next - end - assert_equal(0444, path.lstat.mode & 0777) -diff --git a/test/ruby/test_notimp.rb b/test/ruby/test_notimp.rb -index ddebb657bf..daa5a82d7b 100644 ---- a/test/ruby/test_notimp.rb -+++ b/test/ruby/test_notimp.rb -@@ -13,11 +13,11 @@ def test_respond_to_fork - - def test_respond_to_lchmod - assert_include(File.methods, :lchmod) -- if /linux/ =~ RUBY_PLATFORM -- assert_equal(false, File.respond_to?(:lchmod)) -- end -- if /freebsd/ =~ RUBY_PLATFORM -+ case RUBY_PLATFORM -+ when /freebsd/, /linux-musl/ - assert_equal(true, File.respond_to?(:lchmod)) -+ when /linux/ -+ assert_equal(false, File.respond_to?(:lchmod)) - end - end - -@@ -57,9 +57,14 @@ def test_call_lchmod - File.open(f, "w") {} - File.symlink f, g - newmode = 0444 -- File.lchmod newmode, "#{d}/g" -- snew = File.lstat(g) -- assert_equal(newmode, snew.mode & 0777) -+ begin -+ File.lchmod newmode, "#{d}/g" -+ rescue Errno::EOPNOTSUPP -+ skip $! -+ else -+ snew = File.lstat(g) -+ assert_equal(newmode, snew.mode & 0777) -+ end - } - end - end --- -2.26.2 - diff --git a/1001-ruby-2.8.0-Moved-not-implemented-method-tests.patch b/1001-ruby-2.8.0-Moved-not-implemented-method-tests.patch deleted file mode 100644 index 72d09bc..0000000 --- a/1001-ruby-2.8.0-Moved-not-implemented-method-tests.patch +++ /dev/null @@ -1,128 +0,0 @@ -From 5400fc3c67446e2f7f35ea317c596e71f0cb1ca4 Mon Sep 17 00:00:00 2001 -From: Nobuyoshi Nakada -Date: Fri, 28 Feb 2020 21:15:37 +0900 -Subject: [PATCH 2/2] Moved not-implemented method tests [Bug #16662] - -Test not-implemented method with the dedicated methods, instead of -platform dependent features. ---- - test/-ext-/test_notimplement.rb | 7 +++ - test/ruby/test_notimp.rb | 90 --------------------------------- - 2 files changed, 7 insertions(+), 90 deletions(-) - delete mode 100644 test/ruby/test_notimp.rb - -diff --git a/test/-ext-/test_notimplement.rb b/test/-ext-/test_notimplement.rb -index 0eba7bdaf8..be8c3623cc 100644 ---- a/test/-ext-/test_notimplement.rb -+++ b/test/-ext-/test_notimplement.rb -@@ -10,6 +10,11 @@ def test_funcall_notimplement - end - - def test_respond_to -+ assert_include(Bug.methods(false), :notimplement) - assert_not_respond_to(Bug, :notimplement) - end -+ -+ def test_method_inspect_notimplement -+ assert_match(/not-implemented/, Bug.method(:notimplement).inspect) -+ end - end -diff --git a/test/ruby/test_notimp.rb b/test/ruby/test_notimp.rb -deleted file mode 100644 -index daa5a82d7b..0000000000 ---- a/test/ruby/test_notimp.rb -+++ /dev/null -@@ -1,90 +0,0 @@ --# frozen_string_literal: false --require 'test/unit' --require 'timeout' --require 'tmpdir' -- --class TestNotImplement < Test::Unit::TestCase -- def test_respond_to_fork -- assert_include(Process.methods, :fork) -- if /linux/ =~ RUBY_PLATFORM -- assert_equal(true, Process.respond_to?(:fork)) -- end -- end -- -- def test_respond_to_lchmod -- assert_include(File.methods, :lchmod) -- case RUBY_PLATFORM -- when /freebsd/, /linux-musl/ -- assert_equal(true, File.respond_to?(:lchmod)) -- when /linux/ -- assert_equal(false, File.respond_to?(:lchmod)) -- end -- end -- -- def test_call_fork -- GC.start -- pid = nil -- ps = -- case RUBY_PLATFORM -- when /linux/ # assume Linux Distribution uses procps -- proc {`ps -eLf #{pid}`} -- when /freebsd/ -- proc {`ps -lH #{pid}`} -- when /darwin/ -- proc {`ps -lM #{pid}`} -- else -- proc {`ps -l #{pid}`} -- end -- assert_nothing_raised(Timeout::Error, ps) do -- Timeout.timeout(EnvUtil.apply_timeout_scale(5)) { -- pid = fork {} -- Process.wait pid -- pid = nil -- } -- end -- ensure -- if pid -- Process.kill(:KILL, pid) -- Process.wait pid -- end -- end if Process.respond_to?(:fork) -- -- def test_call_lchmod -- if File.respond_to?(:lchmod) -- Dir.mktmpdir {|d| -- f = "#{d}/f" -- g = "#{d}/g" -- File.open(f, "w") {} -- File.symlink f, g -- newmode = 0444 -- begin -- File.lchmod newmode, "#{d}/g" -- rescue Errno::EOPNOTSUPP -- skip $! -- else -- snew = File.lstat(g) -- assert_equal(newmode, snew.mode & 0777) -- end -- } -- end -- end -- -- def test_method_inspect_fork -- m = Process.method(:fork) -- if Process.respond_to?(:fork) -- assert_not_match(/not-implemented/, m.inspect) -- else -- assert_match(/not-implemented/, m.inspect) -- end -- end -- -- def test_method_inspect_lchmod -- m = File.method(:lchmod) -- if File.respond_to?(:lchmod) -- assert_not_match(/not-implemented/, m.inspect) -- else -- assert_match(/not-implemented/, m.inspect) -- end -- end -- --end --- -2.26.2 - diff --git a/1002-ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch b/1002-ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch deleted file mode 100644 index b7ea046..0000000 --- a/1002-ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 9b42fce32bff25e0569581f76f532b9d57865aef Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?V=C3=ADt=20Ondruch?= -Date: Mon, 27 Jul 2020 14:56:05 +0200 -Subject: [PATCH] Timeout the test_bug_reporter_add witout raising error. - -While timeouting the threads might be still good idea, it does not seems -the timeout impacts the TestBugReporter#test_bug_reporter_add result, -because the output of the child process has been already collected -earlier. - -It seems that when the system is under heavy load, the thread might not -be sheduled to finish its processing. Even finishing the child process -might take tens of seconds and therefore the test case finish might take -a while. ---- - test/-ext-/bug_reporter/test_bug_reporter.rb | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/test/-ext-/bug_reporter/test_bug_reporter.rb b/test/-ext-/bug_reporter/test_bug_reporter.rb -index 628fcd0340..2c677cc8a7 100644 ---- a/test/-ext-/bug_reporter/test_bug_reporter.rb -+++ b/test/-ext-/bug_reporter/test_bug_reporter.rb -@@ -17,7 +17,7 @@ def test_bug_reporter_add - args = ["--disable-gems", "-r-test-/bug_reporter", - "-C", tmpdir] - stdin = "register_sample_bug_reporter(12345); Process.kill :SEGV, $$" -- assert_in_out_err(args, stdin, [], expected_stderr, encoding: "ASCII-8BIT") -+ assert_in_out_err(args, stdin, [], expected_stderr, encoding: "ASCII-8BIT", timeout_error: nil) - ensure - FileUtils.rm_rf(tmpdir) if tmpdir - end --- -2.27.0 - diff --git a/ruby-3.5.0-fix-164-Integer-overflow-related-to-reg-dmax-in-sear.patch b/ruby-3.5.0-fix-164-Integer-overflow-related-to-reg-dmax-in-sear.patch new file mode 100644 index 0000000..6521d60 --- /dev/null +++ b/ruby-3.5.0-fix-164-Integer-overflow-related-to-reg-dmax-in-sear.patch @@ -0,0 +1,221 @@ +From 377b776f01863c516224baa1f77c0bbb51861c5b Mon Sep 17 00:00:00 2001 +From: "K.Kosako" +Date: Tue, 29 Apr 2025 22:19:51 +0200 +Subject: [PATCH] fix #164: Integer overflow related to reg->dmax in + search_in_range() + +https://github.com/kkos/oniguruma/issues/164#issuecomment-558134827 + +Origin: https://github.com/kkos/oniguruma/commit/0463e21432515631a9bc925ce5eb95b097c73719 +Origin: https://github.com/kkos/oniguruma/commit/db64ef3189f54917a5008a02bdb000adc514a90a +Origin: https://github.com/kkos/oniguruma/commit/bfc36d3d8139b8be4d3df630d625c58687b0c7d4 +Origin: https://github.com/kkos/oniguruma/commit/778a43dd56925ed58bbe26e3a7bb8202d72c3f3f +Origin: https://github.com/kkos/oniguruma/commit/b6cb7580a7e0c56fc325fe9370b9d34044910aed + +Reviewed-by: Sylvain Beucler +--- + regexec.c | 93 ++++++++++++++++++++++++++++++++++--------------------- + 1 file changed, 58 insertions(+), 35 deletions(-) + +diff --git a/regexec.c b/regexec.c +index d200a3cc28..a988e35cd7 100644 +--- a/regexec.c ++++ b/regexec.c +@@ -3912,14 +3912,14 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s, + } + + p = s; +- if (reg->dmin > 0) { ++ if (reg->dmin != 0) { ++ if (end - p <= reg->dmin) ++ return 0; /* fail */ + if (ONIGENC_IS_SINGLEBYTE(reg->enc)) { + p += reg->dmin; + } + else { + UChar *q = p + reg->dmin; +- +- if (q >= end) return 0; /* fail */ + while (p < q) p += enclen(reg->enc, p, end); + } + } +@@ -3956,7 +3956,7 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s, + } + + if (p && p < range) { +- if (p - reg->dmin < s) { ++ if (p - s < reg->dmin) { + retry_gate: + pprev = p; + p += enclen(reg->enc, p, end); +@@ -4000,6 +4000,7 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s, + *low_prev = onigenc_get_prev_char_head(reg->enc, + (pprev ? pprev : str), p, end); + } ++ *high = p; + } + else { + if (reg->dmax != ONIG_INFINITE_DISTANCE) { +@@ -4024,9 +4025,12 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s, + } + } + } ++ /* no needs to adjust *high, *high is used as range check only */ ++ if (p - str < reg->dmin) ++ *high = (UChar* )str; ++ else ++ *high = p - reg->dmin; + } +- /* no needs to adjust *high, *high is used as range check only */ +- *high = p - reg->dmin; + + #ifdef ONIG_DEBUG_SEARCH + fprintf(stderr, +@@ -4053,7 +4057,6 @@ backward_search_range(regex_t* reg, const UChar* str, const UChar* end, + return 0; + } + +- range += reg->dmin; + p = s; + + retry: +@@ -4131,10 +4135,22 @@ backward_search_range(regex_t* reg, const UChar* str, const UChar* end, + } + } + +- /* no needs to adjust *high, *high is used as range check only */ + if (reg->dmax != ONIG_INFINITE_DISTANCE) { +- *low = p - reg->dmax; +- *high = p - reg->dmin; ++ if (p - str < reg->dmax) ++ *low = (UChar* )str; ++ else ++ *low = p - reg->dmax; ++ ++ if (reg->dmin != 0) { ++ if (p - str < reg->dmin) ++ *high = (UChar* )str; ++ else ++ *high = p - reg->dmin; ++ } ++ else { ++ *high = p; ++ } ++ + *high = onigenc_get_right_adjust_char_head(reg->enc, adjrange, *high, end); + } + +@@ -4277,12 +4292,12 @@ onig_search_gpos(regex_t* reg, const UChar* str, const UChar* end, + goto mismatch_no_msa; + + if (range > start) { +- if ((OnigDistance )(min_semi_end - start) > reg->anchor_dmax) { ++ if (min_semi_end - start > reg->anchor_dmax) { + start = min_semi_end - reg->anchor_dmax; + if (start < end) + start = onigenc_get_right_adjust_char_head(reg->enc, str, start, end); + } +- if ((OnigDistance )(max_semi_end - (range - 1)) < reg->anchor_dmin) { ++ if (max_semi_end - (range - 1) < reg->anchor_dmin) { + range = max_semi_end - reg->anchor_dmin + 1; + } + +@@ -4291,12 +3306,16 @@ onig_search_gpos(regex_t* reg, const UChar* str, const UChar* end, + Backward search is used. */ + } + else { +- if ((OnigDistance )(min_semi_end - range) > reg->anchor_dmax) { ++ if (min_semi_end - range > reg->anchor_dmax) { + range = min_semi_end - reg->anchor_dmax; + } +- if ((OnigDistance )(max_semi_end - start) < reg->anchor_dmin) { +- start = max_semi_end - reg->anchor_dmin; +- start = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, str, start, end); ++ if (max_semi_end - start < reg->anchor_dmin) { ++ if (max_semi_end - str < reg->anchor_dmin) ++ goto mismatch_no_msa; ++ else { ++ start = max_semi_end - reg->anchor_dmin; ++ start = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, str, start, end); ++ } + } + if (range > start) goto mismatch_no_msa; + } +@@ -4375,15 +4394,19 @@ onig_search_gpos(regex_t* reg, const UChar* str, const UChar* end, + if (reg->optimize != ONIG_OPTIMIZE_NONE) { + UChar *sch_range, *low, *high, *low_prev; + +- sch_range = (UChar* )range; + if (reg->dmax != 0) { + if (reg->dmax == ONIG_INFINITE_DISTANCE) + sch_range = (UChar* )end; + else { +- sch_range += reg->dmax; +- if (sch_range > end) sch_range = (UChar* )end; ++ if ((end - range) < reg->dmax) ++ sch_range = (UChar* )end; ++ else { ++ sch_range = (UChar* )range + reg->dmax; ++ } + } + } ++ else ++ sch_range = (UChar* )range; + + if ((end - start) < reg->threshold_len) + goto mismatch; +@@ -4440,18 +4463,28 @@ onig_search_gpos(regex_t* reg, const UChar* str, const UChar* end, + else { /* backward search */ + if (reg->optimize != ONIG_OPTIMIZE_NONE) { + UChar *low, *high, *adjrange, *sch_start; ++ const UChar *min_range; + + if (range < end) + adjrange = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, str, range, end); + else + adjrange = (UChar* )end; + ++ if (end - range > reg->dmin) ++ min_range = range + reg->dmin; ++ else ++ min_range = end; ++ + if (reg->dmax != ONIG_INFINITE_DISTANCE && + (end - range) >= reg->threshold_len) { + do { +- sch_start = s + reg->dmax; +- if (sch_start > end) sch_start = (UChar* )end; +- if (backward_search_range(reg, str, end, sch_start, range, adjrange, ++ if (end - s > reg->dmax) ++ sch_start = s + reg->dmax; ++ else { ++ sch_start = (UChar* )end; ++ } ++ ++ if (backward_search_range(reg, str, end, sch_start, min_range, adjrange, + &low, &high) <= 0) + goto mismatch; + +@@ -4469,19 +4502,9 @@ onig_search_gpos(regex_t* reg, const UChar* str, const UChar* end, + else { /* check only. */ + if ((end - range) < reg->threshold_len) goto mismatch; + +- sch_start = s; +- if (reg->dmax != 0) { +- if (reg->dmax == ONIG_INFINITE_DISTANCE) +- sch_start = (UChar* )end; +- else { +- sch_start += reg->dmax; +- if (sch_start > end) sch_start = (UChar* )end; +- else +- sch_start = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, +- start, sch_start, end); +- } +- } +- if (backward_search_range(reg, str, end, sch_start, range, adjrange, ++ sch_start = onigenc_get_prev_char_head(reg->enc, str, end, end); ++ ++ if (backward_search_range(reg, str, end, sch_start, min_range, adjrange, + &low, &high) <= 0) goto mismatch; + } + } diff --git a/ruby.spec b/ruby.spec index 8096d49..e4e4159 100644 --- a/ruby.spec +++ b/ruby.spec @@ -1,4 +1,3 @@ -%define anolis_release .0.1 %global major_version 2 %global minor_version 5 %global teeny_version 9 @@ -22,9 +21,9 @@ %endif -%global release 113 +%global release 114 -%{!?release_string:%global release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{anolis_release}%{?dist}} +%{!?release_string:%global release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{?dist}} # The RubyGems library has to stay out of Ruby directory tree, since the # RubyGems should be share by all Ruby implementations. @@ -271,21 +270,13 @@ Patch49: rubygem-rexml-3.2.9-Fix-CVE-2024-35176-DoS-in-REXML.patch # test file to patch. # https://github.com/ruby/rexml/commit/ce59f2eb1aeb371fe1643414f06618dbe031979f Patch50: rubygem-rexml-3.3.9-Fix-ReDoS-CVE-2024-49761.patch +# CVE-2019-19012 oniguruma: integer overflow in search_in_range function in +# regexec.c leads to out-of-bounds read. +# https://github.com/kkos/oniguruma/issues/164#issuecomment-558134827 +# https://issues.redhat.com/browse/RHEL-87505 +Patch51: ruby-3.5.0-fix-164-Integer-overflow-related-to-reg-dmax-in-sear.patch -# Begin: Anolis OS customized -# Fix lchmod test failures. -# refer url: https://src.fedoraproject.org/rpms/ruby/c/79683d7d629de74dbcefe8cce68d51ec1eb1da01?branch=rawhide -# https://github.com/ruby/ruby/commit/a19228f878d955eaf2cce086bcf53f46fdf894b9 -Patch1000: 1000-ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch -# https://github.com/ruby/ruby/commit/72c02aa4b79731c7f25c9267f74b347f1946c704 -Patch1001: 1001-ruby-2.8.0-Moved-not-implemented-method-tests.patch -# Avoid possible timeout errors in TestBugReporter#test_bug_reporter_add. -# https://bugs.ruby-lang.org/issues/16492 -# refer url: https://src.fedoraproject.org/rpms/ruby/c/4979be53acdcfd0d6021c4f209403c2e88fae58e?branch=rawhide -Patch1002: 1002-ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch -# End: Anolis OS customized - Requires: %{name}-libs%{?_isa} = %{version}-%{release} Suggests: rubypick Recommends: ruby(rubygems) >= %{rubygems_version} @@ -705,9 +696,7 @@ sed -i 's/"evaluation\/incorrect_words.yaml"\.freeze, //' \ %patch48 -p1 %patch49 -p1 %patch50 -p1 -%patch1000 -p1 -%patch1001 -p1 -%patch1002 -p1 +%patch51 -p1 # Provide an example of usage of the tapset: cp -a %{SOURCE3} . @@ -1272,12 +1261,9 @@ OPENSSL_SYSTEM_CIPHERS_OVERRIDE=xyz_nonexistent_file OPENSSL_CONF='' \ %{gem_dir}/specifications/xmlrpc-%{xmlrpc_version}.gemspec %changelog -* Fri Dec 06 2024 Weitao Zhou - 2.5.9-113.0.1 -- Fix FTBFS due to glibc 2.31.9000 implementing lchmod(2), compatible with glibc2.28 also - * Patch: ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch - * Patch: ruby-2.8.0-Moved-not-implemented-method-tests.patch -- Avoid possible timeout errors in TestBugReporter#test_bug_reporter_add. - * Patch: ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch +* Mon May 05 2025 Vít Ondruch - 2.5.9-114 +- Fix integer overflow in search_in_range function in regexec.c (CVE-2019-19012). + Resolves: RHEL-87505 * Tue Nov 26 2024 Jarek Prokop - 2.5.9-113 - Fix REXML ReDoS vulnerability. (CVE-2024-49761) -- Gitee From 94a1b545a272b154bbcba847ce88bb69b4835cf5 Mon Sep 17 00:00:00 2001 From: ZhouWeitao Date: Thu, 13 Jan 2022 14:11:40 +0800 Subject: [PATCH 2/3] Fix FTBFS due to glibc 2.31.9000 implementing lchmod(2), compatible with glibc2.28 also - Patch: ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch - Patch: ruby-2.8.0-Moved-not-implemented-method-tests.patch refer url: https://src.fedoraproject.org/rpms/ruby/c/79683d7d629de74dbcefe8cce68d51ec1eb1da01?branch=rawhide Signed-off-by: ZhouWeitao --- ...-the-fact-that-lchmod-can-EOPNOTSUPP.patch | 91 +++++++++++++ ...0-Moved-not-implemented-method-tests.patch | 128 ++++++++++++++++++ ruby.spec | 19 ++- 3 files changed, 237 insertions(+), 1 deletion(-) create mode 100644 1000-ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch create mode 100644 1001-ruby-2.8.0-Moved-not-implemented-method-tests.patch diff --git a/1000-ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch b/1000-ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch new file mode 100644 index 0000000..42f47a9 --- /dev/null +++ b/1000-ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch @@ -0,0 +1,91 @@ +From 29d9f866f686e81818fb9cf402c4fb479decb282 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= + +Date: Thu, 23 Jan 2020 15:33:42 +0900 +Subject: [PATCH 1/2] brace the fact that lchmod(2) can EOPNOTSUPP + +Musl libc has this function as a tiny wrapper of fchmodat(3posix). On +the other hand Linux kernel does not support changing modes of a symlink. +The operation always fails with EOPNOTSUPP. This fchmodat behaviour is +defined in POSIX. We have to take care of such exceptions. +--- + lib/fileutils.rb | 3 ++- + test/pathname/test_pathname.rb | 2 +- + test/ruby/test_notimp.rb | 19 ++++++++++++------- + 3 files changed, 15 insertions(+), 9 deletions(-) + +diff --git a/lib/fileutils.rb b/lib/fileutils.rb +index f56d7f9cb9..1a02d5435e 100644 +--- a/lib/fileutils.rb ++++ b/lib/fileutils.rb +@@ -1242,6 +1242,7 @@ def chmod(mode) + else + File.chmod mode, path() + end ++ rescue Errno::EOPNOTSUPP + end + + def chown(uid, gid) +@@ -1317,7 +1318,7 @@ def copy_metadata(path) + if st.symlink? + begin + File.lchmod mode, path +- rescue NotImplementedError ++ rescue NotImplementedError, Errno::EOPNOTSUPP + end + else + File.chmod mode, path +diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb +index 8a72b8026d..e381d3fa58 100644 +--- a/test/pathname/test_pathname.rb ++++ b/test/pathname/test_pathname.rb +@@ -823,7 +823,7 @@ def test_lchmod + old = path.lstat.mode + begin + path.lchmod(0444) +- rescue NotImplementedError ++ rescue NotImplementedError, Errno::EOPNOTSUPP + next + end + assert_equal(0444, path.lstat.mode & 0777) +diff --git a/test/ruby/test_notimp.rb b/test/ruby/test_notimp.rb +index ddebb657bf..daa5a82d7b 100644 +--- a/test/ruby/test_notimp.rb ++++ b/test/ruby/test_notimp.rb +@@ -13,11 +13,11 @@ def test_respond_to_fork + + def test_respond_to_lchmod + assert_include(File.methods, :lchmod) +- if /linux/ =~ RUBY_PLATFORM +- assert_equal(false, File.respond_to?(:lchmod)) +- end +- if /freebsd/ =~ RUBY_PLATFORM ++ case RUBY_PLATFORM ++ when /freebsd/, /linux-musl/ + assert_equal(true, File.respond_to?(:lchmod)) ++ when /linux/ ++ assert_equal(false, File.respond_to?(:lchmod)) + end + end + +@@ -57,9 +57,14 @@ def test_call_lchmod + File.open(f, "w") {} + File.symlink f, g + newmode = 0444 +- File.lchmod newmode, "#{d}/g" +- snew = File.lstat(g) +- assert_equal(newmode, snew.mode & 0777) ++ begin ++ File.lchmod newmode, "#{d}/g" ++ rescue Errno::EOPNOTSUPP ++ skip $! ++ else ++ snew = File.lstat(g) ++ assert_equal(newmode, snew.mode & 0777) ++ end + } + end + end +-- +2.26.2 + diff --git a/1001-ruby-2.8.0-Moved-not-implemented-method-tests.patch b/1001-ruby-2.8.0-Moved-not-implemented-method-tests.patch new file mode 100644 index 0000000..72d09bc --- /dev/null +++ b/1001-ruby-2.8.0-Moved-not-implemented-method-tests.patch @@ -0,0 +1,128 @@ +From 5400fc3c67446e2f7f35ea317c596e71f0cb1ca4 Mon Sep 17 00:00:00 2001 +From: Nobuyoshi Nakada +Date: Fri, 28 Feb 2020 21:15:37 +0900 +Subject: [PATCH 2/2] Moved not-implemented method tests [Bug #16662] + +Test not-implemented method with the dedicated methods, instead of +platform dependent features. +--- + test/-ext-/test_notimplement.rb | 7 +++ + test/ruby/test_notimp.rb | 90 --------------------------------- + 2 files changed, 7 insertions(+), 90 deletions(-) + delete mode 100644 test/ruby/test_notimp.rb + +diff --git a/test/-ext-/test_notimplement.rb b/test/-ext-/test_notimplement.rb +index 0eba7bdaf8..be8c3623cc 100644 +--- a/test/-ext-/test_notimplement.rb ++++ b/test/-ext-/test_notimplement.rb +@@ -10,6 +10,11 @@ def test_funcall_notimplement + end + + def test_respond_to ++ assert_include(Bug.methods(false), :notimplement) + assert_not_respond_to(Bug, :notimplement) + end ++ ++ def test_method_inspect_notimplement ++ assert_match(/not-implemented/, Bug.method(:notimplement).inspect) ++ end + end +diff --git a/test/ruby/test_notimp.rb b/test/ruby/test_notimp.rb +deleted file mode 100644 +index daa5a82d7b..0000000000 +--- a/test/ruby/test_notimp.rb ++++ /dev/null +@@ -1,90 +0,0 @@ +-# frozen_string_literal: false +-require 'test/unit' +-require 'timeout' +-require 'tmpdir' +- +-class TestNotImplement < Test::Unit::TestCase +- def test_respond_to_fork +- assert_include(Process.methods, :fork) +- if /linux/ =~ RUBY_PLATFORM +- assert_equal(true, Process.respond_to?(:fork)) +- end +- end +- +- def test_respond_to_lchmod +- assert_include(File.methods, :lchmod) +- case RUBY_PLATFORM +- when /freebsd/, /linux-musl/ +- assert_equal(true, File.respond_to?(:lchmod)) +- when /linux/ +- assert_equal(false, File.respond_to?(:lchmod)) +- end +- end +- +- def test_call_fork +- GC.start +- pid = nil +- ps = +- case RUBY_PLATFORM +- when /linux/ # assume Linux Distribution uses procps +- proc {`ps -eLf #{pid}`} +- when /freebsd/ +- proc {`ps -lH #{pid}`} +- when /darwin/ +- proc {`ps -lM #{pid}`} +- else +- proc {`ps -l #{pid}`} +- end +- assert_nothing_raised(Timeout::Error, ps) do +- Timeout.timeout(EnvUtil.apply_timeout_scale(5)) { +- pid = fork {} +- Process.wait pid +- pid = nil +- } +- end +- ensure +- if pid +- Process.kill(:KILL, pid) +- Process.wait pid +- end +- end if Process.respond_to?(:fork) +- +- def test_call_lchmod +- if File.respond_to?(:lchmod) +- Dir.mktmpdir {|d| +- f = "#{d}/f" +- g = "#{d}/g" +- File.open(f, "w") {} +- File.symlink f, g +- newmode = 0444 +- begin +- File.lchmod newmode, "#{d}/g" +- rescue Errno::EOPNOTSUPP +- skip $! +- else +- snew = File.lstat(g) +- assert_equal(newmode, snew.mode & 0777) +- end +- } +- end +- end +- +- def test_method_inspect_fork +- m = Process.method(:fork) +- if Process.respond_to?(:fork) +- assert_not_match(/not-implemented/, m.inspect) +- else +- assert_match(/not-implemented/, m.inspect) +- end +- end +- +- def test_method_inspect_lchmod +- m = File.method(:lchmod) +- if File.respond_to?(:lchmod) +- assert_not_match(/not-implemented/, m.inspect) +- else +- assert_match(/not-implemented/, m.inspect) +- end +- end +- +-end +-- +2.26.2 + diff --git a/ruby.spec b/ruby.spec index e4e4159..9ddcfed 100644 --- a/ruby.spec +++ b/ruby.spec @@ -1,3 +1,4 @@ +%define anolis_release .0.1 %global major_version 2 %global minor_version 5 %global teeny_version 9 @@ -23,7 +24,7 @@ %global release 114 -%{!?release_string:%global release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{?dist}} +%{!?release_string:%global release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{anolis_release}%{?dist}} # The RubyGems library has to stay out of Ruby directory tree, since the # RubyGems should be share by all Ruby implementations. @@ -277,6 +278,15 @@ Patch50: rubygem-rexml-3.3.9-Fix-ReDoS-CVE-2024-49761.patch Patch51: ruby-3.5.0-fix-164-Integer-overflow-related-to-reg-dmax-in-sear.patch +# Begin: Anolis OS customized +# Fix lchmod test failures. +# refer url: https://src.fedoraproject.org/rpms/ruby/c/79683d7d629de74dbcefe8cce68d51ec1eb1da01?branch=rawhide +# https://github.com/ruby/ruby/commit/a19228f878d955eaf2cce086bcf53f46fdf894b9 +Patch1000: 1000-ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch +# https://github.com/ruby/ruby/commit/72c02aa4b79731c7f25c9267f74b347f1946c704 +Patch1001: 1001-ruby-2.8.0-Moved-not-implemented-method-tests.patch +# End: Anolis OS customized + Requires: %{name}-libs%{?_isa} = %{version}-%{release} Suggests: rubypick Recommends: ruby(rubygems) >= %{rubygems_version} @@ -697,6 +707,8 @@ sed -i 's/"evaluation\/incorrect_words.yaml"\.freeze, //' \ %patch49 -p1 %patch50 -p1 %patch51 -p1 +%patch1000 -p1 +%patch1001 -p1 # Provide an example of usage of the tapset: cp -a %{SOURCE3} . @@ -1261,6 +1273,11 @@ OPENSSL_SYSTEM_CIPHERS_OVERRIDE=xyz_nonexistent_file OPENSSL_CONF='' \ %{gem_dir}/specifications/xmlrpc-%{xmlrpc_version}.gemspec %changelog +* Fri May 16 2025 Weitao Zhou - 2.5.9-114.0.1 +- Fix FTBFS due to glibc 2.31.9000 implementing lchmod(2), compatible with glibc2.28 also + * Patch: ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch + * Patch: ruby-2.8.0-Moved-not-implemented-method-tests.patch + * Mon May 05 2025 Vít Ondruch - 2.5.9-114 - Fix integer overflow in search_in_range function in regexec.c (CVE-2019-19012). Resolves: RHEL-87505 -- Gitee From bd144e3b240f60c888c8d28b5b5b6d44647c5b87 Mon Sep 17 00:00:00 2001 From: ZhouWeitao Date: Thu, 13 Jan 2022 14:58:38 +0800 Subject: [PATCH 3/3] Avoid possible timeout errors in TestBugReporter#test_bug_reporter_add. - Patch: ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch refer url: https://src.fedoraproject.org/rpms/ruby/c/4979be53acdcfd0d6021c4f209403c2e88fae58e?branch=rawhide Signed-off-by: ZhouWeitao --- ..._bug_reporter_add-witout-raising-err.patch | 34 +++++++++++++++++++ ruby.spec | 7 ++++ 2 files changed, 41 insertions(+) create mode 100644 1002-ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch diff --git a/1002-ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch b/1002-ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch new file mode 100644 index 0000000..b7ea046 --- /dev/null +++ b/1002-ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch @@ -0,0 +1,34 @@ +From 9b42fce32bff25e0569581f76f532b9d57865aef Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?V=C3=ADt=20Ondruch?= +Date: Mon, 27 Jul 2020 14:56:05 +0200 +Subject: [PATCH] Timeout the test_bug_reporter_add witout raising error. + +While timeouting the threads might be still good idea, it does not seems +the timeout impacts the TestBugReporter#test_bug_reporter_add result, +because the output of the child process has been already collected +earlier. + +It seems that when the system is under heavy load, the thread might not +be sheduled to finish its processing. Even finishing the child process +might take tens of seconds and therefore the test case finish might take +a while. +--- + test/-ext-/bug_reporter/test_bug_reporter.rb | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/test/-ext-/bug_reporter/test_bug_reporter.rb b/test/-ext-/bug_reporter/test_bug_reporter.rb +index 628fcd0340..2c677cc8a7 100644 +--- a/test/-ext-/bug_reporter/test_bug_reporter.rb ++++ b/test/-ext-/bug_reporter/test_bug_reporter.rb +@@ -17,7 +17,7 @@ def test_bug_reporter_add + args = ["--disable-gems", "-r-test-/bug_reporter", + "-C", tmpdir] + stdin = "register_sample_bug_reporter(12345); Process.kill :SEGV, $$" +- assert_in_out_err(args, stdin, [], expected_stderr, encoding: "ASCII-8BIT") ++ assert_in_out_err(args, stdin, [], expected_stderr, encoding: "ASCII-8BIT", timeout_error: nil) + ensure + FileUtils.rm_rf(tmpdir) if tmpdir + end +-- +2.27.0 + diff --git a/ruby.spec b/ruby.spec index 9ddcfed..82b67bd 100644 --- a/ruby.spec +++ b/ruby.spec @@ -285,6 +285,10 @@ Patch51: ruby-3.5.0-fix-164-Integer-overflow-related-to-reg-dmax-in-sear.patch Patch1000: 1000-ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch # https://github.com/ruby/ruby/commit/72c02aa4b79731c7f25c9267f74b347f1946c704 Patch1001: 1001-ruby-2.8.0-Moved-not-implemented-method-tests.patch +# Avoid possible timeout errors in TestBugReporter#test_bug_reporter_add. +# https://bugs.ruby-lang.org/issues/16492 +# refer url: https://src.fedoraproject.org/rpms/ruby/c/4979be53acdcfd0d6021c4f209403c2e88fae58e?branch=rawhide +Patch1002: 1002-ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch # End: Anolis OS customized Requires: %{name}-libs%{?_isa} = %{version}-%{release} @@ -709,6 +713,7 @@ sed -i 's/"evaluation\/incorrect_words.yaml"\.freeze, //' \ %patch51 -p1 %patch1000 -p1 %patch1001 -p1 +%patch1002 -p1 # Provide an example of usage of the tapset: cp -a %{SOURCE3} . @@ -1277,6 +1282,8 @@ OPENSSL_SYSTEM_CIPHERS_OVERRIDE=xyz_nonexistent_file OPENSSL_CONF='' \ - Fix FTBFS due to glibc 2.31.9000 implementing lchmod(2), compatible with glibc2.28 also * Patch: ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch * Patch: ruby-2.8.0-Moved-not-implemented-method-tests.patch +- Avoid possible timeout errors in TestBugReporter#test_bug_reporter_add. + * Patch: ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch * Mon May 05 2025 Vít Ondruch - 2.5.9-114 - Fix integer overflow in search_in_range function in regexec.c (CVE-2019-19012). -- Gitee