fix out of bounds read in xlarrv

Signed-off-by: qinyu <chinyu0704@outlook.com>
This commit is contained in:
qinyu 2021-12-15 12:10:54 +08:00
parent 4a696a69d6
commit 17fda536dc
2 changed files with 86 additions and 1 deletions

View File

@ -0,0 +1,81 @@
From 0631b6beaed60ba118b0b027c0f8d35397bf5df0 Mon Sep 17 00:00:00 2001
From: Keno Fischer <keno@juliacomputing.com>
Date: Thu, 30 Sep 2021 03:51:23 -0400
Subject: [PATCH] Fix out of bounds read in slarrv
This was originally reported as https://github.com/JuliaLang/julia/issues/42415.
I've tracked this down to an our of bounds read on the following line:
https://github.com/Reference-LAPACK/lapack/blob/44ecb6a5ff821b1cbb39f8cc2166cb098e060b4d/SRC/slarrv.f#L423
In the crashing example, `M` is `0`, causing `slarrv` to read uninitialized
memory from the work array. I believe the `0` for `M` is correct and indeed,
the documentation above supports that `M` may be zero:
https://github.com/Reference-LAPACK/lapack/blob/44ecb6a5ff821b1cbb39f8cc2166cb098e060b4d/SRC/slarrv.f#L113-L116
I believe it may be sufficient to early-out this function as suggested
in this PR. However, I have limited context for the full routine here,
so I would appreciate a sanity check.
---
SRC/clarrv.f | 2 +-
SRC/dlarrv.f | 2 +-
SRC/slarrv.f | 2 +-
SRC/zlarrv.f | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/SRC/clarrv.f b/SRC/clarrv.f
index 1f09e4d..42f7107 100644
--- a/SRC/clarrv.f
+++ b/SRC/clarrv.f
@@ -348,7 +348,7 @@
*
* Quick return if possible
*
- IF( N.LE.0 ) THEN
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
RETURN
END IF
*
diff --git a/SRC/dlarrv.f b/SRC/dlarrv.f
index b036c1e..2994303 100644
--- a/SRC/dlarrv.f
+++ b/SRC/dlarrv.f
@@ -350,7 +350,7 @@
*
* Quick return if possible
*
- IF( N.LE.0 ) THEN
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
RETURN
END IF
*
diff --git a/SRC/slarrv.f b/SRC/slarrv.f
index 9d72b33..95f94fd 100644
--- a/SRC/slarrv.f
+++ b/SRC/slarrv.f
@@ -350,7 +350,7 @@
*
* Quick return if possible
*
- IF( N.LE.0 ) THEN
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
RETURN
END IF
*
diff --git a/SRC/zlarrv.f b/SRC/zlarrv.f
index 51ec558..e4be63e 100644
--- a/SRC/zlarrv.f
+++ b/SRC/zlarrv.f
@@ -348,7 +348,7 @@
*
* Quick return if possible
*
- IF( N.LE.0 ) THEN
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
RETURN
END IF
*
--
1.8.3.1

View File

@ -5,7 +5,7 @@
Name: lapack Name: lapack
Version: %{mediumver}.0 Version: %{mediumver}.0
Release: 2 Release: 3
Summary: The LAPACK libraries for numerical linear algebra. Summary: The LAPACK libraries for numerical linear algebra.
License: BSD License: BSD
URL: http://www.netlib.org/lapack/ URL: http://www.netlib.org/lapack/
@ -13,6 +13,7 @@ Source0: https://github.com/Reference-LAPACK/lapack/archive/v%{version}.tar.gz
Source1: http://www.netlib.org/lapack/manpages.tgz Source1: http://www.netlib.org/lapack/manpages.tgz
Patch1: 0001-fix-lapack-devel-build-error.patch Patch1: 0001-fix-lapack-devel-build-error.patch
Patch2: 0002-Fix-out-of-bounds-read-in-slarrv.patch
BuildRequires: gcc-gfortran BuildRequires: gcc-gfortran
Provides: blas = %{version}-%{release} Provides: blas = %{version}-%{release}
@ -207,6 +208,9 @@ sed -i 's|@LAPACK_VERSION@|%{version}|g' %{buildroot}%{_libdir}/pkgconfig/lapack
%endif %endif
%changelog %changelog
* Wed Dec 15 2021 qinyu <chinyu0704@outlook.com> - 3.10.0-3
- fix lapack-devel build error
* Mon Dec 6 2021 zhouwenpei <zhouwenpei1huawei.com> - 3.10.0-2 * Mon Dec 6 2021 zhouwenpei <zhouwenpei1huawei.com> - 3.10.0-2
- fix lapack-devel build error - fix lapack-devel build error