已开启
fix(cve): 修复 CVE-2026-2492 在 tensorflow 中的漏洞 #136
infra_team创建于 6月15日
fix(cve): 修复 CVE-2026-2492 在 tensorflow 中的漏洞 #136
已开启
共 2 个文件变更+99-1
| @@ -0,0 +1,92 @@ | |||
| 1 | +From 46e7f7fb144fd11cf6d17c23dd47620328d77082 Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: "A. Unique TensorFlower" <gardener@tensorflow.org> | ||
| 3 | +Date: Mon, 15 Dec 2025 13:20:46 -0800 | ||
| 4 | +Subject: [PATCH] Disable HDF5 plugin loading when importing h5py in | ||
| 5 | + Tensorflow. | ||
| 6 | + | ||
| 7 | +Set the HDF5_PLUGIN_PATH environment variable to "disable" before importing h5py to prevent the loading of external HDF5 plugins. | ||
| 8 | + | ||
| 9 | +PiperOrigin-RevId: 844896565 | ||
| 10 | +Signed-off-by: infra_team <zhaiwenjie1@huawei.com> | ||
| 11 | +--- | ||
| 12 | + tensorflow/python/keras/engine/training.py | 3 +++ | ||
| 13 | + tensorflow/python/keras/keras_parameterized.py | 4 ++++ | ||
| 14 | + tensorflow/python/keras/saving/hdf5_format.py | 3 +++ | ||
| 15 | + tensorflow/python/keras/saving/save.py | 4 +++- | ||
| 16 | + 4 files changed, 14 insertions(+), 1 deletion(-) | ||
| 17 | + | ||
| 18 | +diff --git a/tensorflow/python/keras/engine/training.py b/tensorflow/python/keras/engine/training.py | ||
| 19 | +index 9369ffa456392a..4206ef9f882ffc 100644 | ||
| 20 | +--- a/tensorflow/python/keras/engine/training.py | ||
| 21 | ++++ b/tensorflow/python/keras/engine/training.py | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + # pylint: disable=g-import-not-at-top | ||
| 25 | + try: | ||
| 26 | ++ # Disable loading HDF5 plugins from a default path and prevent ZDI-CAN-25480. | ||
| 27 | ++ # Importing h5py prior to importing tensorflow will restore the old behavior. | ||
| 28 | ++ os.environ['HDF5_PLUGIN_PATH'] = 'disable' | ||
| 29 | + import h5py | ||
| 30 | + except ImportError: | ||
| 31 | + h5py = None | ||
| 32 | +diff --git a/tensorflow/python/keras/keras_parameterized.py b/tensorflow/python/keras/keras_parameterized.py | ||
| 33 | +index 054df939e8e59a..1a44e6b76f3276 100644 | ||
| 34 | +--- a/tensorflow/python/keras/keras_parameterized.py | ||
| 35 | ++++ b/tensorflow/python/keras/keras_parameterized.py | ||
| 36 | + | ||
| 37 | + import collections | ||
| 38 | + import functools | ||
| 39 | + import itertools | ||
| 40 | ++import os | ||
| 41 | + import unittest | ||
| 42 | + | ||
| 43 | + from absl.testing import parameterized | ||
| 44 | + | ||
| 45 | + from tensorflow.python.util import nest | ||
| 46 | + | ||
| 47 | + try: | ||
| 48 | ++ # Disable loading HDF5 plugins from a default path and prevent ZDI-CAN-25480. | ||
| 49 | ++ # Importing h5py prior to importing tensorflow will restore the old behavior. | ||
| 50 | ++ os.environ['HDF5_PLUGIN_PATH'] = 'disable' | ||
| 51 | + import h5py # pylint:disable=g-import-not-at-top | ||
| 52 | + except ImportError: | ||
| 53 | + h5py = None | ||
| 54 | +diff --git a/tensorflow/python/keras/saving/hdf5_format.py b/tensorflow/python/keras/saving/hdf5_format.py | ||
| 55 | +index 1f6bbc43320d0a..05a2c9282909a2 100644 | ||
| 56 | +--- a/tensorflow/python/keras/saving/hdf5_format.py | ||
| 57 | ++++ b/tensorflow/python/keras/saving/hdf5_format.py | ||
| 58 | + | ||
| 59 | + | ||
| 60 | + # pylint: disable=g-import-not-at-top | ||
| 61 | + try: | ||
| 62 | ++ # Disable loading HDF5 plugins from a default path and prevent ZDI-CAN-25480. | ||
| 63 | ++ # Importing h5py prior to importing tensorflow will restore the old behavior. | ||
| 64 | ++ os.environ['HDF5_PLUGIN_PATH'] = 'disable' | ||
| 65 | + import h5py | ||
| 66 | + HDF5_OBJECT_HEADER_LIMIT = 64512 | ||
| 67 | + except ImportError: | ||
| 68 | +diff --git a/tensorflow/python/keras/saving/save.py b/tensorflow/python/keras/saving/save.py | ||
| 69 | +index eee859233e5eba..b9ba0bc20d0ba0 100644 | ||
| 70 | +--- a/tensorflow/python/keras/saving/save.py | ||
| 71 | ++++ b/tensorflow/python/keras/saving/save.py | ||
| 72 | + | ||
| 73 | + # limitations under the License. | ||
| 74 | + # ============================================================================== | ||
| 75 | + """Keras model saving code.""" | ||
| 76 | +- | ||
| 77 | ++import os | ||
| 78 | + from tensorflow.python import tf2 | ||
| 79 | + from tensorflow.python.keras.saving import hdf5_format | ||
| 80 | + from tensorflow.python.keras.saving import saving_utils | ||
| 81 | + | ||
| 82 | + | ||
| 83 | + # pylint: disable=g-import-not-at-top | ||
| 84 | + try: | ||
| 85 | ++ # Disable loading HDF5 plugins from a default path and prevent ZDI-CAN-25480. | ||
| 86 | ++ # Importing h5py prior to importing tensorflow will restore the old behavior. | ||
| 87 | ++ os.environ['HDF5_PLUGIN_PATH'] = 'disable' | ||
| 88 | + import h5py | ||
| 89 | + except ImportError: | ||
| 90 | + h5py = None | ||
| 91 | +-- | ||
| 92 | +2.43.0 | ||
| @@ -1,7 +1,7 @@ | |||
| 1 | %global _empty_manifest_terminate_build 0 | 1 | %global _empty_manifest_terminate_build 0 |
| 2 | Name: tensorflow | 2 | Name: tensorflow |
| 3 | Version: 2.12.1 | 3 | Version: 2.12.1 |
| 4 | -Release: 4 | 4 | +Release: 5 |
| 5 | Summary: An Open Source Machine Learning Framework for Everyone | 5 | Summary: An Open Source Machine Learning Framework for Everyone |
| 6 | License: Apache License 2.0 | 6 | License: Apache License 2.0 |
| 7 | URL: https://www.tensorflow.org/ | 7 | URL: https://www.tensorflow.org/ |
| @@ -11,6 +11,7 @@ Source2: external.tar.bz2.partab | |||
| 11 | Source3: external.tar.bz2.partac | 11 | Source3: external.tar.bz2.partac |
| 12 | Patch0: modify-deps-on-libclang-gcsfs-gast.patch | 12 | Patch0: modify-deps-on-libclang-gcsfs-gast.patch |
| 13 | Patch1: fix-boringssl-compile.patch | 13 | Patch1: fix-boringssl-compile.patch |
| 14 | +Patch2: CVE-2026-2492-backport.patch | ||
| 14 | %ifarch aarch64 | 15 | %ifarch aarch64 |
| 15 | Patch1000: aarch64_external_files.patch | 16 | Patch1000: aarch64_external_files.patch |
| 16 | %endif | 17 | %endif |
| @@ -46,6 +47,7 @@ TensorFlow provides stable Python and C++ APIs, as well as non-guaranteed backwa | |||
| 46 | %setup -n %{name}-%{version} | 47 | %setup -n %{name}-%{version} |
| 47 | %patch 0 -p1 | 48 | %patch 0 -p1 |
| 48 | %patch 1 -p1 | 49 | %patch 1 -p1 |
| 50 | +%patch 2 -p1 | ||
| 49 | extdir=$(bazel --output_user_root=`pwd`/../output_user_root info output_base) | 51 | extdir=$(bazel --output_user_root=`pwd`/../output_user_root info output_base) |
| 50 | mkdir -p ${extdir} | 52 | mkdir -p ${extdir} |
| 51 | instdir=$(bazel --output_user_root=`pwd`/../output_user_root info install_base) | 53 | instdir=$(bazel --output_user_root=`pwd`/../output_user_root info install_base) |
| @@ -82,6 +84,10 @@ bazel --output_user_root=`pwd`/../output_user_root build --nofetch --host_copt=- | |||
| 82 | %{_bindir}/* | 84 | %{_bindir}/* |
| 83 | 85 | ||
| 84 | %changelog | 86 | %changelog |
| 87 | +* Wed Jun 17 2026 infra_team <zhaiwenjie1@huawei.com> - 2.12.1-5 | ||
| 88 | +- fix CVE: CVE-2026-2492 | ||
| 89 | +- Disable HDF5 plugin loading when importing h5py in TensorFlow (ZDI-CAN-25480) | ||
| 90 | + | ||
| 85 | * Thu Mar 20 2025 Dingli Zhang <dingli@iscas.ac.cn> - 2.12.1-4 | 91 | * Thu Mar 20 2025 Dingli Zhang <dingli@iscas.ac.cn> - 2.12.1-4 |
| 86 | - Add support for riscv64 | 92 | - Add support for riscv64 |
| 87 | 93 | ||