Skip to content

Commit 571f0cc

Browse files
committed
Apply the patch from Reference-LAPACK/lapack#625 (ref JuliaLang/julia#42415)
1 parent 27fe6fe commit 571f0cc

File tree

3 files changed

+234
-0
lines changed

3 files changed

+234
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
From 0631b6beaed60ba118b0b027c0f8d35397bf5df0 Mon Sep 17 00:00:00 2001
2+
From: Keno Fischer <[email protected]>
3+
Date: Thu, 30 Sep 2021 03:51:23 -0400
4+
Subject: [PATCH] Fix out of bounds read in slarrv
5+
6+
This was originally reported as https://github.com/JuliaLang/julia/issues/42415.
7+
I've tracked this down to an our of bounds read on the following line:
8+
9+
https://github.com/Reference-LAPACK/lapack/blob/44ecb6a5ff821b1cbb39f8cc2166cb098e060b4d/SRC/slarrv.f#L423
10+
11+
In the crashing example, `M` is `0`, causing `slarrv` to read uninitialized
12+
memory from the work array. I believe the `0` for `M` is correct and indeed,
13+
the documentation above supports that `M` may be zero:
14+
15+
https://github.com/Reference-LAPACK/lapack/blob/44ecb6a5ff821b1cbb39f8cc2166cb098e060b4d/SRC/slarrv.f#L113-L116
16+
17+
I believe it may be sufficient to early-out this function as suggested
18+
in this PR. However, I have limited context for the full routine here,
19+
so I would appreciate a sanity check.
20+
---
21+
SRC/clarrv.f | 2 +-
22+
SRC/dlarrv.f | 2 +-
23+
SRC/slarrv.f | 2 +-
24+
SRC/zlarrv.f | 2 +-
25+
4 files changed, 4 insertions(+), 4 deletions(-)
26+
27+
diff --git a/SRC/clarrv.f b/SRC/clarrv.f
28+
index 1f09e4da6..42f710757 100644
29+
--- a/SRC/clarrv.f
30+
+++ b/SRC/clarrv.f
31+
@@ -348,7 +348,7 @@ SUBROUTINE CLARRV( N, VL, VU, D, L, PIVMIN,
32+
*
33+
* Quick return if possible
34+
*
35+
- IF( N.LE.0 ) THEN
36+
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
37+
RETURN
38+
END IF
39+
*
40+
diff --git a/SRC/dlarrv.f b/SRC/dlarrv.f
41+
index b036c1e66..299430361 100644
42+
--- a/SRC/dlarrv.f
43+
+++ b/SRC/dlarrv.f
44+
@@ -350,7 +350,7 @@ SUBROUTINE DLARRV( N, VL, VU, D, L, PIVMIN,
45+
*
46+
* Quick return if possible
47+
*
48+
- IF( N.LE.0 ) THEN
49+
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
50+
RETURN
51+
END IF
52+
*
53+
diff --git a/SRC/slarrv.f b/SRC/slarrv.f
54+
index 9d72b339a..95f94fd1b 100644
55+
--- a/SRC/slarrv.f
56+
+++ b/SRC/slarrv.f
57+
@@ -350,7 +350,7 @@ SUBROUTINE SLARRV( N, VL, VU, D, L, PIVMIN,
58+
*
59+
* Quick return if possible
60+
*
61+
- IF( N.LE.0 ) THEN
62+
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
63+
RETURN
64+
END IF
65+
*
66+
diff --git a/SRC/zlarrv.f b/SRC/zlarrv.f
67+
index 51ec558f5..e4be63e0d 100644
68+
--- a/SRC/zlarrv.f
69+
+++ b/SRC/zlarrv.f
70+
@@ -348,7 +348,7 @@ SUBROUTINE ZLARRV( N, VL, VU, D, L, PIVMIN,
71+
*
72+
* Quick return if possible
73+
*
74+
- IF( N.LE.0 ) THEN
75+
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
76+
RETURN
77+
END IF
78+
*
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
From 0631b6beaed60ba118b0b027c0f8d35397bf5df0 Mon Sep 17 00:00:00 2001
2+
From: Keno Fischer <[email protected]>
3+
Date: Thu, 30 Sep 2021 03:51:23 -0400
4+
Subject: [PATCH] Fix out of bounds read in slarrv
5+
6+
This was originally reported as https://github.com/JuliaLang/julia/issues/42415.
7+
I've tracked this down to an our of bounds read on the following line:
8+
9+
https://github.com/Reference-LAPACK/lapack/blob/44ecb6a5ff821b1cbb39f8cc2166cb098e060b4d/SRC/slarrv.f#L423
10+
11+
In the crashing example, `M` is `0`, causing `slarrv` to read uninitialized
12+
memory from the work array. I believe the `0` for `M` is correct and indeed,
13+
the documentation above supports that `M` may be zero:
14+
15+
https://github.com/Reference-LAPACK/lapack/blob/44ecb6a5ff821b1cbb39f8cc2166cb098e060b4d/SRC/slarrv.f#L113-L116
16+
17+
I believe it may be sufficient to early-out this function as suggested
18+
in this PR. However, I have limited context for the full routine here,
19+
so I would appreciate a sanity check.
20+
---
21+
SRC/clarrv.f | 2 +-
22+
SRC/dlarrv.f | 2 +-
23+
SRC/slarrv.f | 2 +-
24+
SRC/zlarrv.f | 2 +-
25+
4 files changed, 4 insertions(+), 4 deletions(-)
26+
27+
diff --git a/SRC/clarrv.f b/SRC/clarrv.f
28+
index 1f09e4da6..42f710757 100644
29+
--- a/SRC/clarrv.f
30+
+++ b/SRC/clarrv.f
31+
@@ -348,7 +348,7 @@ SUBROUTINE CLARRV( N, VL, VU, D, L, PIVMIN,
32+
*
33+
* Quick return if possible
34+
*
35+
- IF( N.LE.0 ) THEN
36+
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
37+
RETURN
38+
END IF
39+
*
40+
diff --git a/SRC/dlarrv.f b/SRC/dlarrv.f
41+
index b036c1e66..299430361 100644
42+
--- a/SRC/dlarrv.f
43+
+++ b/SRC/dlarrv.f
44+
@@ -350,7 +350,7 @@ SUBROUTINE DLARRV( N, VL, VU, D, L, PIVMIN,
45+
*
46+
* Quick return if possible
47+
*
48+
- IF( N.LE.0 ) THEN
49+
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
50+
RETURN
51+
END IF
52+
*
53+
diff --git a/SRC/slarrv.f b/SRC/slarrv.f
54+
index 9d72b339a..95f94fd1b 100644
55+
--- a/SRC/slarrv.f
56+
+++ b/SRC/slarrv.f
57+
@@ -350,7 +350,7 @@ SUBROUTINE SLARRV( N, VL, VU, D, L, PIVMIN,
58+
*
59+
* Quick return if possible
60+
*
61+
- IF( N.LE.0 ) THEN
62+
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
63+
RETURN
64+
END IF
65+
*
66+
diff --git a/SRC/zlarrv.f b/SRC/zlarrv.f
67+
index 51ec558f5..e4be63e0d 100644
68+
--- a/SRC/zlarrv.f
69+
+++ b/SRC/zlarrv.f
70+
@@ -348,7 +348,7 @@ SUBROUTINE ZLARRV( N, VL, VU, D, L, PIVMIN,
71+
*
72+
* Quick return if possible
73+
*
74+
- IF( N.LE.0 ) THEN
75+
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
76+
RETURN
77+
END IF
78+
*
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
From 0631b6beaed60ba118b0b027c0f8d35397bf5df0 Mon Sep 17 00:00:00 2001
2+
From: Keno Fischer <[email protected]>
3+
Date: Thu, 30 Sep 2021 03:51:23 -0400
4+
Subject: [PATCH] Fix out of bounds read in slarrv
5+
6+
This was originally reported as https://github.com/JuliaLang/julia/issues/42415.
7+
I've tracked this down to an our of bounds read on the following line:
8+
9+
https://github.com/Reference-LAPACK/lapack/blob/44ecb6a5ff821b1cbb39f8cc2166cb098e060b4d/SRC/slarrv.f#L423
10+
11+
In the crashing example, `M` is `0`, causing `slarrv` to read uninitialized
12+
memory from the work array. I believe the `0` for `M` is correct and indeed,
13+
the documentation above supports that `M` may be zero:
14+
15+
https://github.com/Reference-LAPACK/lapack/blob/44ecb6a5ff821b1cbb39f8cc2166cb098e060b4d/SRC/slarrv.f#L113-L116
16+
17+
I believe it may be sufficient to early-out this function as suggested
18+
in this PR. However, I have limited context for the full routine here,
19+
so I would appreciate a sanity check.
20+
---
21+
SRC/clarrv.f | 2 +-
22+
SRC/dlarrv.f | 2 +-
23+
SRC/slarrv.f | 2 +-
24+
SRC/zlarrv.f | 2 +-
25+
4 files changed, 4 insertions(+), 4 deletions(-)
26+
27+
diff --git a/SRC/clarrv.f b/SRC/clarrv.f
28+
index 1f09e4da6..42f710757 100644
29+
--- a/SRC/clarrv.f
30+
+++ b/SRC/clarrv.f
31+
@@ -348,7 +348,7 @@ SUBROUTINE CLARRV( N, VL, VU, D, L, PIVMIN,
32+
*
33+
* Quick return if possible
34+
*
35+
- IF( N.LE.0 ) THEN
36+
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
37+
RETURN
38+
END IF
39+
*
40+
diff --git a/SRC/dlarrv.f b/SRC/dlarrv.f
41+
index b036c1e66..299430361 100644
42+
--- a/SRC/dlarrv.f
43+
+++ b/SRC/dlarrv.f
44+
@@ -350,7 +350,7 @@ SUBROUTINE DLARRV( N, VL, VU, D, L, PIVMIN,
45+
*
46+
* Quick return if possible
47+
*
48+
- IF( N.LE.0 ) THEN
49+
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
50+
RETURN
51+
END IF
52+
*
53+
diff --git a/SRC/slarrv.f b/SRC/slarrv.f
54+
index 9d72b339a..95f94fd1b 100644
55+
--- a/SRC/slarrv.f
56+
+++ b/SRC/slarrv.f
57+
@@ -350,7 +350,7 @@ SUBROUTINE SLARRV( N, VL, VU, D, L, PIVMIN,
58+
*
59+
* Quick return if possible
60+
*
61+
- IF( N.LE.0 ) THEN
62+
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
63+
RETURN
64+
END IF
65+
*
66+
diff --git a/SRC/zlarrv.f b/SRC/zlarrv.f
67+
index 51ec558f5..e4be63e0d 100644
68+
--- a/SRC/zlarrv.f
69+
+++ b/SRC/zlarrv.f
70+
@@ -348,7 +348,7 @@ SUBROUTINE ZLARRV( N, VL, VU, D, L, PIVMIN,
71+
*
72+
* Quick return if possible
73+
*
74+
- IF( N.LE.0 ) THEN
75+
+ IF( (N.LE.0).OR.(M.LE.0) ) THEN
76+
RETURN
77+
END IF
78+
*

0 commit comments

Comments
 (0)