Skip to content

Commit

Permalink
(PA-6386) Patch Ruby for CVE-2024-27282
Browse files Browse the repository at this point in the history
 - Patches the ruby 'Use-After-Free' issue for regexp.
 - Upstream fix commit: ruby/ruby@90b194b
  • Loading branch information
shubhamshinde360 committed May 31, 2024
1 parent dd06b4f commit 1befac5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions configs/components/ruby-2.7.8.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
base = 'resources/patches/ruby_27'
# Patch for https://bugs.ruby-lang.org/issues/14972
pkg.apply_patch "#{base}/net_http_eof_14972_r2.5.patch"
pkg.apply_patch "#{base}/regexp_use_after_free.patch"

pkg.apply_patch "#{base}/uri-redos-cve-2023-36617.patch"

Expand Down
1 change: 1 addition & 0 deletions configs/components/ruby-3.2.3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#########

base = 'resources/patches/ruby_32'
pkg.apply_patch "#{base}/regexp_use_after_free.patch"

if platform.is_cross_compiled?
pkg.apply_patch "#{base}/rbinstall_gem_path.patch"
Expand Down
13 changes: 13 additions & 0 deletions resources/patches/ruby_27/regexp_use_after_free.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/regexec.c b/regexec.c
index 73694ab14a..140691ad42 100644
--- a/regexec.c
+++ b/regexec.c
@@ -3449,8 +3449,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
CASE(OP_MEMORY_END_PUSH_REC) MOP_IN(OP_MEMORY_END_PUSH_REC);
GET_MEMNUM_INC(mem, p);
STACK_GET_MEM_START(mem, stkp); /* should be before push mem-end. */
- STACK_PUSH_MEM_END(mem, s);
mem_start_stk[mem] = GET_STACK_INDEX(stkp);
+ STACK_PUSH_MEM_END(mem, s);
MOP_OUT;
JUMP;
13 changes: 13 additions & 0 deletions resources/patches/ruby_32/regexp_use_after_free.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/regexec.c b/regexec.c
index 73694ab14a..140691ad42 100644
--- a/regexec.c
+++ b/regexec.c
@@ -3449,8 +3449,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
CASE(OP_MEMORY_END_PUSH_REC) MOP_IN(OP_MEMORY_END_PUSH_REC);
GET_MEMNUM_INC(mem, p);
STACK_GET_MEM_START(mem, stkp); /* should be before push mem-end. */
- STACK_PUSH_MEM_END(mem, s);
mem_start_stk[mem] = GET_STACK_INDEX(stkp);
+ STACK_PUSH_MEM_END(mem, s);
MOP_OUT;
JUMP;

0 comments on commit 1befac5

Please sign in to comment.