Commit Graph
1 Commits
Author SHA1 Message Date
Dana Jansens 30318f87f7 Introduce StableStack to avoid UAF into Context stacks (#8055)
Stacks in Context can grow when eval is run, and if they are implemented
as SmallVector, the growing can cause a reallocation. Meanwhile for
stacks that hold larger structs/classes, we hold onto the pointer into
the stack instead of copying out. This can cause a UAF when reallocation
happens.

StableStack never reallocates when growing, as it is represented by a
vector of pointers to arrays, where each array is a factor larger than
the previous one. This prevents UAF from occurring when we run eval
while holding a pointer into a stack.

This solves a similar problem that our ValuesStores previously solved in
#5576. In that case, we also represent them as a vector of pointers to
arrays. The difference being our ValueStores are meant to grow but not
shrink, and they are built around the ID concept where IDs happen to be
an index into the store.
2026-11-12 16:48:09 +00:00