File Fix-out-of-bounds-read.patch of Package lapack.23119
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(-)
Index: lapack-3.5.0/SRC/clarrv.f
===================================================================
--- lapack-3.5.0.orig/SRC/clarrv.f
+++ lapack-3.5.0/SRC/clarrv.f
@@ -344,6 +344,13 @@
* .. Executable Statements ..
* ..
+*
+* Quick return if possible
+*
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
+ RETURN
+ END IF
+*
* The first N entries of WORK are reserved for the eigenvalues
INDLD = N+1
INDLLD= 2*N+1
Index: lapack-3.5.0/SRC/dlarrv.f
===================================================================
--- lapack-3.5.0.orig/SRC/dlarrv.f
+++ lapack-3.5.0/SRC/dlarrv.f
@@ -340,6 +340,13 @@
* .. Executable Statements ..
* ..
+*
+* Quick return if possible
+*
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
+ RETURN
+ END IF
+*
* The first N entries of WORK are reserved for the eigenvalues
INDLD = N+1
INDLLD= 2*N+1
Index: lapack-3.5.0/SRC/slarrv.f
===================================================================
--- lapack-3.5.0.orig/SRC/slarrv.f
+++ lapack-3.5.0/SRC/slarrv.f
@@ -340,6 +340,13 @@
* .. Executable Statements ..
* ..
+*
+* Quick return if possible
+*
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
+ RETURN
+ END IF
+*
* The first N entries of WORK are reserved for the eigenvalues
INDLD = N+1
INDLLD= 2*N+1
Index: lapack-3.5.0/SRC/zlarrv.f
===================================================================
--- lapack-3.5.0.orig/SRC/zlarrv.f
+++ lapack-3.5.0/SRC/zlarrv.f
@@ -344,6 +344,13 @@
* .. Executable Statements ..
* ..
+*
+* Quick return if possible
+*
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
+ RETURN
+ END IF
+*
* The first N entries of WORK are reserved for the eigenvalues
INDLD = N+1
INDLLD= 2*N+1