From b1a4e124f24f03916877bc116c1f9e89dd6c34a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20=C3=9Acar?= Date: Tue, 30 Apr 2024 18:49:14 +0200 Subject: [PATCH] Security fix for CVE-2024-27322 --- R-CVE-2024-27322.patch | 49 ++++++++++++++++++++++++++++++++++++++++++ R.spec | 9 +++++++- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 R-CVE-2024-27322.patch diff --git a/R-CVE-2024-27322.patch b/R-CVE-2024-27322.patch new file mode 100644 index 0000000..a342697 --- /dev/null +++ b/R-CVE-2024-27322.patch @@ -0,0 +1,49 @@ +From f7c46500f455eb4edfc3656c3fa20af61b16abb7 Mon Sep 17 00:00:00 2001 +From: luke +Date: Sun, 31 Mar 2024 19:35:58 +0000 +Subject: [PATCH] readRDS() and unserialize() now signal an errorr instead of + returning a PROMSXP. + +git-svn-id: https://svn.r-project.org/R/trunk@86235 00db46b3-68df-0310-9c12-caf00c1e9a41 +--- + src/main/serialize.c | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/src/main/serialize.c b/src/main/serialize.c +index a389f713116..a190fbf8f3c 100644 +--- a/src/main/serialize.c ++++ b/src/main/serialize.c +@@ -2650,6 +2650,13 @@ do_serializeToConn(SEXP call, SEXP op, SEXP args, SEXP env) + return R_NilValue; + } + ++static SEXP checkNotPromise(SEXP val) ++{ ++ if (TYPEOF(val) == PROMSXP) ++ error(_("cannot return a promise (PROMSXP) object")); ++ return val; ++} ++ + /* unserializeFromConn(conn, hook) used from readRDS(). + It became public in R 2.13.0, and that version added support for + connections internally */ +@@ -2699,7 +2706,7 @@ do_unserializeFromConn(SEXP call, SEXP op, SEXP args, SEXP env) + con->close(con); + UNPROTECT(1); + } +- return ans; ++ return checkNotPromise(ans); + } + + /* +@@ -3330,8 +3337,8 @@ attribute_hidden SEXP + do_serialize(SEXP call, SEXP op, SEXP args, SEXP env) + { + checkArity(op, args); +- if (PRIMVAL(op) == 2) return R_unserialize(CAR(args), CADR(args)); +- ++ if (PRIMVAL(op) == 2) //return R_unserialize(CAR(args), CADR(args)); ++ return checkNotPromise(R_unserialize(CAR(args), CADR(args))); + SEXP object, icon, type, ver, fun; + object = CAR(args); args = CDR(args); + icon = CAR(args); args = CDR(args); diff --git a/R.spec b/R.spec index 4c59666..82695ba 100644 --- a/R.spec +++ b/R.spec @@ -35,7 +35,7 @@ Name: R Version: %{major_version}.%{minor_version}.%{patch_version} -Release: 1%{?dist} +Release: 2%{?dist} Summary: A language for data analysis and graphics License: GPL-2.0-or-later @@ -43,6 +43,9 @@ URL: https://www.r-project.org Source0: https://cran.r-project.org/src/base/R-4/R-%{version}.tar.gz # see https://bugzilla.redhat.com/show_bug.cgi?id=1324145 Patch0: R-3.3.0-fix-java_path-in-javareconf.patch +# see https://bugzilla.redhat.com/show_bug.cgi?id=2277884 +# https://github.com/r-devel/r-svn/commit/f7c46500f455eb4edfc3656c3fa20af61b16abb7 +Patch1: R-CVE-2024-27322.patch BuildRequires: gcc-gfortran BuildRequires: gcc-c++ @@ -303,6 +306,7 @@ from the R project. This package provides the static libRmath library. %prep %setup -q %patch -P0 -p1 -b .fixpath +%patch -P1 -p1 -b .fixcve %build # Comment out default R_LIBS_SITE (since R 4.2) and set our own as always @@ -933,6 +937,9 @@ TZ="Europe/Paris" make check %{_libdir}/libRmath.a %changelog +* Tue Apr 30 2024 Iñaki Úcar - 4.3.3-2 +- Security fix for CVE-2024-27322 + * Thu Feb 29 2024 Iñaki Úcar - 4.3.3-1 - Update to 4.3.3