1 Star 0 Fork 45

小松鼠/tensorflow

forked from src-openEuler/tensorflow 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CVE-2021-37635.patch 1.59 KB
一键复制 编辑 原始数据 按行查看 历史
starlet_dx 提交于 2021-08-31 15:06 . fix the cves to tensorflow
From 87158f43f05f2720a374f3e6d22a7aaa3a33f750 Mon Sep 17 00:00:00 2001
From: Mihai Maruseac <mihaimaruseac@google.com>
Date: Fri, 30 Jul 2021 21:11:18 -0700
Subject: [PATCH] Prevent heap OOB in sparse reduction ops.
PiperOrigin-RevId: 387934524
Change-Id: I894aa30f1e454f09b471d565b4a325da49322c1a
---
tensorflow/core/kernels/sparse_reduce_op.cc | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tensorflow/core/kernels/sparse_reduce_op.cc b/tensorflow/core/kernels/sparse_reduce_op.cc
index b65f31e5..2bfa3299 100644
--- a/tensorflow/core/kernels/sparse_reduce_op.cc
+++ b/tensorflow/core/kernels/sparse_reduce_op.cc
@@ -219,7 +219,20 @@ class SparseReduceOp : public OpKernel {
sp.Reorder<T>(reduction.reorder_dims);
for (const auto &g : sp.group(reduction.group_by_dims)) {
Op::template Run<T>(ctx, reduced_val, g.template values<T>());
+ OP_REQUIRES(ctx,
+ output_strides.empty() ||
+ (g.group().size() == output_strides.size()),
+ errors::Internal(
+ "Expected group size and output_strides size to match",
+ ", but got ", g.group().size(), " and ",
+ output_strides.size()));
const int64 idx = CoordinatesToFlatIndex(g.group(), output_strides);
+ OP_REQUIRES(ctx,
+ idx >= 0 && idx < out_flat.size(),
+ errors::Internal(
+ "Obtained a write index of ", idx,
+ " which is outside of bounds of [0, ",
+ out_flat.size(), ")"));
out_flat(idx) = reduced_val();
VLOG(2) << "coords: " << absl::StrJoin(g.group(), ",")
<< "; idx: " << idx << "; group " << Op::Name() << ": "
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wang_songsong/tensorflow.git
git@gitee.com:wang_songsong/tensorflow.git
wang_songsong
tensorflow
tensorflow
master

搜索帮助