gh-145122: Add _GUARD_NOS_ANY_DICT to prevent STORE_SUBSCR_DICT on frozendict (gh-145039)

This commit is contained in:
Donghee Na 2026-02-25 00:48:45 +09:00 committed by GitHub
parent 4c95ad8e49
commit 0f759f1171
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 1244 additions and 1079 deletions

View file

@ -1057,17 +1057,22 @@ dummy_func(
}
op(_GUARD_NOS_DICT, (nos, unused -- nos, unused)) {
PyObject *o = PyStackRef_AsPyObjectBorrow(nos);
EXIT_IF(!PyDict_CheckExact(o));
}
op(_GUARD_NOS_ANY_DICT, (nos, unused -- nos, unused)) {
PyObject *o = PyStackRef_AsPyObjectBorrow(nos);
EXIT_IF(!PyAnyDict_CheckExact(o));
}
op(_GUARD_TOS_DICT, (tos -- tos)) {
op(_GUARD_TOS_ANY_DICT, (tos -- tos)) {
PyObject *o = PyStackRef_AsPyObjectBorrow(tos);
EXIT_IF(!PyAnyDict_CheckExact(o));
}
macro(BINARY_OP_SUBSCR_DICT) =
_GUARD_NOS_DICT + unused/5 + _BINARY_OP_SUBSCR_DICT + POP_TOP + POP_TOP;
_GUARD_NOS_ANY_DICT + unused/5 + _BINARY_OP_SUBSCR_DICT + POP_TOP + POP_TOP;
op(_BINARY_OP_SUBSCR_DICT, (dict_st, sub_st -- res, ds, ss)) {
PyObject *sub = PyStackRef_AsPyObjectBorrow(sub_st);
@ -2934,7 +2939,7 @@ dummy_func(
INPUTS_DEAD();
}
macro(CONTAINS_OP_DICT) = _GUARD_TOS_DICT + unused/1 + _CONTAINS_OP_DICT + POP_TOP + POP_TOP;
macro(CONTAINS_OP_DICT) = _GUARD_TOS_ANY_DICT + unused/1 + _CONTAINS_OP_DICT + POP_TOP + POP_TOP;
op(_CONTAINS_OP_DICT, (left, right -- b, l, r)) {
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);