1- From eec0ac4143c01736700e50c87112d8687e1cc151 Mon Sep 17 00:00:00 2001
1+ From 3d6022ab4b79367911cede68a550bfd5b61e2f6d Mon Sep 17 00:00:00 2001
22From: hertschuh <
[email protected] >
33Date: Mon, 23 Jun 2025 18:36:47 -0700
4- Subject: [PATCH 1/2] Disable loading functions within deserialization.
5- (#21412)
6-
7- Upstream source link: https://github.com/keras-team/keras/commit/3d6022ab4b79367911cede68a550bfd5b61e2f6d.patch
4+ Subject: [PATCH 1/2] Disable loading functions within deserialization. (#21412)
85
96Loading files while loading a model is not allowed.
7+
8+ Upstream Patch Reference: https://github.com/keras-team/keras/commit/3d6022ab4b79367911cede68a550bfd5b61e2f6d.patch
109---
1110 keras/src/saving/serialization_lib.py | 35 +++++++++++++++++++++------
1211 1 file changed, 27 insertions(+), 8 deletions(-)
@@ -65,24 +64,25 @@ index ed9f10b..1c47b70 100644
6564 if obj is not None:
6665 return obj
6766- -
68- 2.34.1
69-
67+ 2.43.0
7068
71- From d64692c8d18ea3a4a253159b3f25bc6c06cec6be Mon Sep 17 00:00:00 2001
72- From: hertschuh <
[email protected] >
73- Date: Sun, 29 Jun 2025 10:32:40 -0700
74- Subject: [PATCH 2/2] Only allow deserialization of `KerasSaveable`s by module
75- and name. (#21429)
7669
77- Upstream source link: https://github.com/keras-team/keras/commit/713172ab56b864e59e2aa79b1a51b0e728bba858.patch
78- Backported by <
[email protected] > for azurelinux
70+ From c69516b50242c568d591353627c895e561350215 Mon Sep 17 00:00:00 2001
71+ From: Fabien Hertschuh <
[email protected] >
72+ Date: Fri, 27 Jun 2025 10:10:39 -0700
73+ Subject: [PATCH 2/2] Only allow deserialization of `KerasSaveable`s by module and name.
7974
8075Arbitrary functions and classes are not allowed.
8176
8277- Made `Operation` extend `KerasSaveable`, this required moving imports to avoid circular imports
8378- `Layer` no longer need to extend `KerasSaveable` directly
8479- Made feature space `Cross` and `Feature` extend `KerasSaveable`
8580- Also dissallow public function `enable_unsafe_deserialization`
81+
82+ Modified to apply to Azure Linux
83+ Modified by: Akhila Guruju <
[email protected] >
84+
85+ Upstream Patch Reference: https://github.com/keras-team/keras/commit/c69516b50242c568d591353627c895e561350215.patch
8686---
8787 keras/src/layers/layer.py | 3 +-
8888 .../src/layers/preprocessing/feature_space.py | 11 ++++--
@@ -258,7 +258,7 @@ index 10b79d5..6c738f3 100644
258258 def _post_build(self):
259259 """Can be overridden for per backend post build actions."""
260260diff --git a/keras/src/saving/saving_lib.py b/keras/src/saving/saving_lib.py
261- index c16d2ff..e71e33b 100644
261+ index c16d2ff..94b9561 100644
262262--- a/keras/src/saving/saving_lib.py
263263+++ b/keras/src/saving/saving_lib.py
264264@@ -12,14 +12,9 @@ import numpy as np
@@ -284,7 +284,7 @@ index c16d2ff..e71e33b 100644
284284+ from keras.src.ops.operation import Operation
285285+
286286+ ref_obj = Operation()
287- + skipset.update( dir(ref_obj) )
287+ + skiplist += dir(ref_obj)
288288 if obj_type == "Layer":
289289+ from keras.src.layers.layer import Layer
290290+
@@ -322,12 +322,12 @@ index c16d2ff..e71e33b 100644
322322+ from keras.src.layers.preprocessing.feature_space import Cross
323323+
324324+ ref_obj = Cross((), 1)
325- + skipset.update( dir(ref_obj) )
325+ + skiplist += dir(ref_obj)
326326+ elif obj_type == "Feature":
327327+ from keras.src.layers.preprocessing.feature_space import Feature
328328+
329329+ ref_obj = Feature("int32", lambda x: x, "int")
330- + skipset.update( dir(ref_obj) )
330+ + skiplist += dir(ref_obj)
331331 else:
332332 raise ValueError(
333333 f"get_attr_skiplist got invalid {obj_type=}. "
@@ -374,5 +374,5 @@ index 1c47b70..e680d04 100644
374374 raise TypeError(
375375 f"Could not deserialize {obj_type} '{name}' because "
376376- -
377- 2.34.1
377+ 2.43.0
378378
0 commit comments