Binary Ninja applies the type of a data variable of a function type to a tail call to the variable, but not to a call
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- reverse-engineering
Línea de trabajo
Start by reviewing the medium level IL call and tail call behavior in the Binary Ninja analysis or type propagation code; the issue does not identify a source file or test. Reproduce with the supplied Python script on the arm64e /bin/ls slice and compare the call's one argument with the tail call's five. Done when the call uses the variable's function type, passes five arguments, and returns int64_t, with a regression test covering the case.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
The following issue was identified, triaged and written by Claude Opus 5.5, I have read through it to make sure the information is coherent and useful.
Version and Platform (required):
- Binary Ninja Version: 6.1.10957-dev (build 2899315201)
- Edition: Ultimate
- OS: macOS
- OS Version: 26.6.2 (25G83)
- CPU Architecture: Apple M2 Ultra
Bug Description:
In the steps below, a call (bl) and a tail call (b) both branch to 0x10000c010 in __data. A user data variable at that address has a function type with five parameters, and no function starts there. Binary Ninja applies the variable's type to the tail call, and the tail call passes five arguments. Binary Ninja does not apply the type to the call. In the medium level IL, the call passes one argument, x0_9. The call's destination has the type int64_t (*)(…), a pointer to the variable's function type.
Steps To Reproduce:
- Open
/bin/lsfrom macOS 26.6.2 (SHA-25624752389e1d97c9555dd153b644902fadd460dfbe1a166251876c67bbacb0810), and choose the arm64e slice. - Wait for analysis to finish.
- Run the following script in the Python console. The script defines a user data variable in
__data, with a function type that has five parameters. The script then rewrites one call to the stub of_strlenasbl <variable>, and the first instruction of the stub asb <variable>. The script writes to the binary view, not to the file on disk.
import struct
# A variable of a function type of five parameters, in `__data`. No function starts at its address.
target = bv.get_section_by_name("__data").start + 0x10
bv.define_user_data_var(target, bv.parse_type_string("int64_t (int64_t a, int64_t b, int64_t c, int64_t d, int64_t e)")[0])
print("variable:", hex(target), bv.get_data_var_at(target).type)
# The stub of `_strlen`, and the call to the stub at the lowest address.
stub = next(f for f in bv.functions if f.name == "_strlen" and f.start in bv.get_section_by_name("__auth_stubs"))
call = min((r for r in bv.get_code_refs(stub.start) if r.function.start != stub.start), key=lambda r: r.address)
# Rewrite the call as `bl <variable>`, and the stub's first instruction as `b <variable>`.
def branch(pc, destination, link):
return struct.pack("<I", (0x94000000 if link else 0x14000000) | (((destination - pc) >> 2) & 0x3FFFFFF))
bv.write(call.address, branch(call.address, target, True))
bv.write(stub.start, branch(stub.start, target, False))
bv.update_analysis_and_wait()
def call_at(function, address):
calls = ("MLIL_CALL", "MLIL_TAILCALL")
return next(i for i in function.mlil.instructions if i.address == address and i.operation.name.startswith(calls))
tail_call = call_at(stub, stub.start)
print("tail call in", stub.name, "@", hex(stub.start), ":", tail_call)
call_ins = call_at(call.function, call.address)
print("call in", call.function.name, "@", hex(call.address), ":", call_ins)
print("type of the call's destination:", call_ins.dest.expr_type)
- The script prints:
variable: 0x10000c010 int64_t(int64_t a, int64_t b, int64_t c, int64_t d, int64_t e)
tail call in _strlen @ 0x1000046d4 : return 0x10000c010(__s, b, c, d, e) __tailcall
call in sub_100001a78 @ 0x100001e48 : x0_10 = 0x10000c010(x0_9)
type of the call's destination: int64_t (*)(int64_t a, int64_t b, int64_t c, int64_t d, int64_t e)
The tail call passes five arguments, and the call passes one. The high level IL of sub_100001a78 reads void* x0_10 = (&data_10000c010)(a).
Expected Behavior:
Binary Ninja applies the type of the variable at the call's destination to the call, as it does to the tail call. The call in sub_100001a78 then passes five arguments and returns an int64_t.
Screenshots/Video Recording:
Not applicable. The script prints the medium level IL of both instructions.
Binary:
/bin/ls from macOS 26.6.2 (SHA-256 above). The steps use a binary that ships with macOS.
Additional Information:
- The section that contains the variable does not change the result. With the variable in
__constof__DATA_CONSTat0x1000084d0, in__bssat0x10000c1d0, or at the extern_strlenin.externat0x100018240, the tail call passes five arguments and the call passes one. - With the variable at the extern
_strlen, Binary Ninja does not apply the type to a call that it inlines from the stub either. Settargetto the address of the extern_strlenin.extern,0x100018240. Leave out the write ofbl <variable>, keep the write ofb <variable>at the stub, and setstub.inline_during_analysis = Truebeforebv.update_analysis_and_wait(). The inlined call insub_100001a78at0x100001e48readsx0_10 = 0x100018240()and does not pass any arguments. The tail call in_strlenstill passes five arguments. - After
call.function.reanalyze(), the call still readsx0_10 = 0x10000c010(x0_9).
- Lenguaje dominante
- C++
- Estrellas
- 1.3k
- Forks
- 304
- Merge medio
- 2 d 20 h
- PR fusionados (30 d)
- 10
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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 Menos de una hora Aptitud para principiantes 84/100
Vector35/binaryninja-api#8715 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Vector35/binaryninja-api#8714 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
Vector35/binaryninja-api#8713 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
Vector35/binaryninja-api#8689 ·
Los mantenedores suelen responder en 2 días
-
Component: Python API
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Vector35/binaryninja-api#8649 ·
Los mantenedores suelen responder en 2 días
Todos los issues de Vector35/binaryninja-api
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
ESPresense/ESPresense#2680 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 Menos de una hora Aptitud para principiantes 75/100
stew675/llama-cpp-rdna-boosts#348 ·
Los mantenedores suelen responder en 1 día
-
Documentation: Add comprehensive newcomer onboarding guide, project structure, and local usage to READMEPosiblemente ocupada @Ash-Blanc la tomó hoy. Abiertoarea/other status/bot-triaged status/need-triage
Dificultad 2/5 Medio día Aptitud para principiantes 85/100
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día