Type resolution can give surprisingly different results for local variables in similar code
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- objective-c
- Área
- reverse-engineering
Línea de trabajo
Reproduce the discrepancy using the attached good and bad binaries, switch to HLIL at 0x100000890, and apply the shown _objc_msgSendSuper2 call type override. Compare how obj_3 is resolved, including the objc_retain call at 0x100000918. Done means both cases resolve obj_3 as MyClass* after the override, rather than leaving bad at id.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Version and Platform (required):
- Binary Ninja Version: 5.2.8236-dev Ultimate, d8af0ff0
- OS: macos
- OS Version: 26.0
- CPU Architecture: arm64
Bug Description:
While working on applying more type information from Objective-C binaries I noticed that the type resolution algorithm gives different results in code that is very similar. Specifically, in cases when the return type of a function that is used to initialize a variable and a function to which the variable is passed have a) different types and b) the same confidence, the function parameter type can end up taking precedence over the return type. This can give the effect of a call type adjustment not being applied.
Whether the return type or later parameter type ends up being selected for the local variable's type depends on the order the algorithm traverses the basic blocks and their edges.
Steps To Reproduce:
- Open both
goodandbad. Switch to HLIL and go to0x100000890. - Right-click on the call to
_objc_msgSendSuper2and add a call type override to:MyClass* _objc_msgSendSuper2(struct objc_super* super, SEL sel)
Expected Behavior:
The type of the local variable obj_3 should update to MyClass* to reflect the new type information.
good behaves as expected.
In bad it stays at id as the type information from the objc_retain call at 0x100000918 is seen first. Since it has the same full confidence as the return type of the call type override, it ends up being used.
Workaround:
Apply a type to the local variable.
Binaries:
These can be built from this source file (call-type-override.m by doing:
cc -DBAD -o bad -fobjc-arc -framework Foundation -Os call-type-override.m
cc -UBAD -o good -fobjc-arc -framework Foundation -Os call-type-override.m
The only difference between them is if (!a || !b || !c) becomes if (!a && !b && !c)
- Lenguaje dominante
- C++
- Estrellas
- 1.3k
- Forks
- 298
- Merge medio
- 5 d 5 h
- PR fusionados (30 d)
- 19
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Vector35/binaryninja-api
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
Vector35/binaryninja-api#8540 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Vector35/binaryninja-api#8516 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
Vector35/binaryninja-api#8503 ·
-
normalize time logs from WARP Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Vector35/binaryninja-api#8446 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Vector35/binaryninja-api#8444 ·
Todos los issues de Vector35/binaryninja-api
Issues similares
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 92/100
autowarefoundation/autoware_universe#13413 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
automated-analysis bug memory-safety
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
-
Sensor initialization takes very long when `--initial-sim-time` is set to current UNIX timestamp Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
gazebosim/gz-sensors#662 · 1 comentario ·