Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory access out of bounds in numpy + chrome 89 #1474

Merged
merged 23 commits into from
Apr 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Another numpy patch
  • Loading branch information
Hood committed Apr 15, 2021
commit 8fb7a7094169e79ab5065897071a875705a2d871
2 changes: 1 addition & 1 deletion packages/numpy/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source:
sha256: 16507ba6617f62ae3c6ab1725ae6f550331025d4d9a369b83f6d5a470446c342

patches:
- patches/fix-i32-load-memory-access-oob.patch
- patches/0001-temp.patch
- patches/add-emscripten-cpu.patch
- patches/disable-maybe-uninitialized.patch
- patches/dont-include-execinfo.patch
Expand Down
73 changes: 73 additions & 0 deletions packages/numpy/patches/0001-temp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
From 9b1a0e351c821992b77a9be3be45b97ce56bf586 Mon Sep 17 00:00:00 2001
From: Hood <hood@mit.edu>
Date: Fri, 2 Apr 2021 14:24:24 -0700
Subject: [PATCH] temp

---
numpy/core/src/multiarray/conversion_utils.c | 5 +++--
numpy/core/src/multiarray/iterators.c | 14 ++++++++------
2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/numpy/core/src/multiarray/conversion_utils.c b/numpy/core/src/multiarray/conversion_utils.c
index 52cb58726..5467f4d78 100644
--- a/numpy/core/src/multiarray/conversion_utils.c
+++ b/numpy/core/src/multiarray/conversion_utils.c
@@ -955,9 +955,9 @@ PyArray_IntpFromIndexSequence(PyObject *seq, npy_intp *vals, npy_intp maxvals)
return -1;
}

- vals[i] = PyArray_PyIntAsIntp(op);
+ npy_intp x = PyArray_PyIntAsIntp(op);
Py_DECREF(op);
- if(vals[i] == -1) {
+ if(x == -1) {
err = PyErr_Occurred();
if (err &&
PyErr_GivenExceptionMatches(err, PyExc_OverflowError)) {
@@ -968,6 +968,7 @@ PyArray_IntpFromIndexSequence(PyObject *seq, npy_intp *vals, npy_intp maxvals)
return -1;
}
}
+ vals[i] = x;
}
}
return nd;
diff --git a/numpy/core/src/multiarray/iterators.c b/numpy/core/src/multiarray/iterators.c
index 9da811f69..0bf69e14e 100644
--- a/numpy/core/src/multiarray/iterators.c
+++ b/numpy/core/src/multiarray/iterators.c
@@ -1162,23 +1162,25 @@ PyArray_Broadcast(PyArrayMultiIterObject *mit)
{
int i, nd, k, j;
npy_intp tmp;
- PyArrayIterObject *it;
+ PyArrayObject *ao;

/* Discover the broadcast number of dimensions */
for (i = 0, nd = 0; i < mit->numiter; i++) {
nd = PyArray_MAX(nd, PyArray_NDIM(mit->iters[i]->ao));
}
mit->nd = nd;
-
/* Discover the broadcast shape in each dimension */
for (i = 0; i < nd; i++) {
mit->dimensions[i] = 1;
- for (j = 0; j < mit->numiter; j++) {
- it = mit->iters[j];
+ }
+
+ for (j = 0; j < mit->numiter; j++) {
+ ao = mit->iters[j]->ao;
+ for (i = 0; i < nd; i++) {
/* This prepends 1 to shapes not already equal to nd */
- k = i + PyArray_NDIM(it->ao) - nd;
+ k = i + PyArray_NDIM(ao) - nd;
if (k >= 0) {
- tmp = PyArray_DIMS(it->ao)[k];
+ tmp = PyArray_DIMS(ao)[k];
if (tmp == 1) {
continue;
}
--
2.17.1