diff options
| author | Hitendra Prajapati <hprajapati@mvista.com> | 2024-07-11 10:02:04 +0530 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2024-07-17 05:36:13 -0700 |
| commit | 88ccb9dabb5b58c2fcbbccf6cf087ccff2d43b26 (patch) | |
| tree | e0af90b32793084772b0b5efcc6a1b4c4fd28bbf /meta/recipes-devtools/ruby | |
| parent | 3c430b70b7541a3202d6f565cbfa8a5fa1c23e04 (diff) | |
| download | poky-88ccb9dabb5b58c2fcbbccf6cf087ccff2d43b26.tar.gz | |
ruby: fix CVE-2024-27281
References:
https://github.com/ruby/ruby/pull/10316
https://security-tracker.debian.org/tracker/CVE-2024-27281
Upstream-Status: Backport from https://github.com/ruby/rdoc/commit/da7a0c7553ef7250ca665a3fecdc01dbaacbb43d
(From OE-Core rev: 16685f3b2d22eac20f0134cbd589c3b23a187084)
Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/recipes-devtools/ruby')
| -rw-r--r-- | meta/recipes-devtools/ruby/ruby/CVE-2024-27281.patch | 97 | ||||
| -rw-r--r-- | meta/recipes-devtools/ruby/ruby_3.2.2.bb | 1 |
2 files changed, 98 insertions, 0 deletions
diff --git a/meta/recipes-devtools/ruby/ruby/CVE-2024-27281.patch b/meta/recipes-devtools/ruby/ruby/CVE-2024-27281.patch new file mode 100644 index 0000000000..f69f3bcf4f --- /dev/null +++ b/meta/recipes-devtools/ruby/ruby/CVE-2024-27281.patch | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | From da7a0c7553ef7250ca665a3fecdc01dbaacbb43d Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Nobuyoshi Nakada <nobu@...> | ||
| 3 | Date: Mon, 15 Apr 2024 11:40:00 +0000 | ||
| 4 | Subject: [PATCH] Filter marshaled objets | ||
| 5 | |||
| 6 | CVE: CVE-2024-27281 | ||
| 7 | Upstream-Status: Backport [https://github.com/ruby/rdoc/commit/da7a0c7553ef7250ca665a3fecdc01dbaacbb43d] | ||
| 8 | Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com> | ||
| 9 | --- | ||
| 10 | lib/rdoc/store.rb | 45 ++++++++++++++++++++++++++------------------- | ||
| 11 | 1 file changed, 26 insertions(+), 19 deletions(-) | ||
| 12 | |||
| 13 | diff --git a/lib/rdoc/store.rb b/lib/rdoc/store.rb | ||
| 14 | index 9fc540d..5b663d7 100644 | ||
| 15 | --- a/lib/rdoc/store.rb | ||
| 16 | +++ b/lib/rdoc/store.rb | ||
| 17 | @@ -556,9 +556,7 @@ class RDoc::Store | ||
| 18 | def load_cache | ||
| 19 | #orig_enc = @encoding | ||
| 20 | |||
| 21 | - File.open cache_path, 'rb' do |io| | ||
| 22 | - @cache = Marshal.load io | ||
| 23 | - end | ||
| 24 | + @cache = marshal_load(cache_path) | ||
| 25 | |||
| 26 | load_enc = @cache[:encoding] | ||
| 27 | |||
| 28 | @@ -615,9 +613,7 @@ class RDoc::Store | ||
| 29 | def load_class_data klass_name | ||
| 30 | file = class_file klass_name | ||
| 31 | |||
| 32 | - File.open file, 'rb' do |io| | ||
| 33 | - Marshal.load io | ||
| 34 | - end | ||
| 35 | + marshal_load(file) | ||
| 36 | rescue Errno::ENOENT => e | ||
| 37 | error = MissingFileError.new(self, file, klass_name) | ||
| 38 | error.set_backtrace e.backtrace | ||
| 39 | @@ -630,14 +626,10 @@ class RDoc::Store | ||
| 40 | def load_method klass_name, method_name | ||
| 41 | file = method_file klass_name, method_name | ||
| 42 | |||
| 43 | - File.open file, 'rb' do |io| | ||
| 44 | - obj = Marshal.load io | ||
| 45 | - obj.store = self | ||
| 46 | - obj.parent = | ||
| 47 | - find_class_or_module(klass_name) || load_class(klass_name) unless | ||
| 48 | - obj.parent | ||
| 49 | - obj | ||
| 50 | - end | ||
| 51 | + obj = marshal_load(file) | ||
| 52 | + obj.store = self | ||
| 53 | + obj.parent ||= find_class_or_module(klass_name) || load_class(klass_name) | ||
| 54 | + obj | ||
| 55 | rescue Errno::ENOENT => e | ||
| 56 | error = MissingFileError.new(self, file, klass_name + method_name) | ||
| 57 | error.set_backtrace e.backtrace | ||
| 58 | @@ -650,11 +642,9 @@ class RDoc::Store | ||
| 59 | def load_page page_name | ||
| 60 | file = page_file page_name | ||
| 61 | |||
| 62 | - File.open file, 'rb' do |io| | ||
| 63 | - obj = Marshal.load io | ||
| 64 | - obj.store = self | ||
| 65 | - obj | ||
| 66 | - end | ||
| 67 | + obj = marshal_load(file) | ||
| 68 | + obj.store = self | ||
| 69 | + obj | ||
| 70 | rescue Errno::ENOENT => e | ||
| 71 | error = MissingFileError.new(self, file, page_name) | ||
| 72 | error.set_backtrace e.backtrace | ||
| 73 | @@ -976,4 +966,21 @@ class RDoc::Store | ||
| 74 | @unique_modules | ||
| 75 | end | ||
| 76 | |||
| 77 | + private | ||
| 78 | + def marshal_load(file) | ||
| 79 | + File.open(file, 'rb') {|io| Marshal.load(io, MarshalFilter)} | ||
| 80 | + end | ||
| 81 | + | ||
| 82 | + MarshalFilter = proc do |obj| | ||
| 83 | + case obj | ||
| 84 | + when true, false, nil, Array, Class, Encoding, Hash, Integer, String, Symbol, RDoc::Text | ||
| 85 | + else | ||
| 86 | + unless obj.class.name.start_with("RDoc::") | ||
| 87 | + raise TypeError, "not permitted class: #{obj.class.name}" | ||
| 88 | + end | ||
| 89 | + end | ||
| 90 | + obj | ||
| 91 | + end | ||
| 92 | + private_constant :MarshalFilter | ||
| 93 | + | ||
| 94 | end | ||
| 95 | -- | ||
| 96 | 2.25.1 | ||
| 97 | |||
diff --git a/meta/recipes-devtools/ruby/ruby_3.2.2.bb b/meta/recipes-devtools/ruby/ruby_3.2.2.bb index d1359e388c..5c2b07e5e4 100644 --- a/meta/recipes-devtools/ruby/ruby_3.2.2.bb +++ b/meta/recipes-devtools/ruby/ruby_3.2.2.bb | |||
| @@ -33,6 +33,7 @@ SRC_URI = "http://cache.ruby-lang.org/pub/ruby/${SHRT_VER}/ruby-${PV}.tar.gz \ | |||
| 33 | file://0001-fiddle-Use-C11-_Alignof-to-define-ALIGN_OF-when-poss.patch \ | 33 | file://0001-fiddle-Use-C11-_Alignof-to-define-ALIGN_OF-when-poss.patch \ |
| 34 | file://CVE-2023-36617_1.patch \ | 34 | file://CVE-2023-36617_1.patch \ |
| 35 | file://CVE-2023-36617_2.patch \ | 35 | file://CVE-2023-36617_2.patch \ |
| 36 | file://CVE-2024-27281.patch \ | ||
| 36 | " | 37 | " |
| 37 | UPSTREAM_CHECK_URI = "https://www.ruby-lang.org/en/downloads/" | 38 | UPSTREAM_CHECK_URI = "https://www.ruby-lang.org/en/downloads/" |
| 38 | 39 | ||
