Vector35 / Vector35/binaryninja-api
PowerPC SVR4 64bit parameters read from wrong registers
Nessuno ha ancora preso questa issue.
- Lingua principale
- C++
- Stelle
- 1.3k
- Fork
- 298
- Merge medio
- 5g 5h
- PR unite (30g)
- 19
Descrizione
Version and Platform (required):
- Binary Ninja Version: 5.3.9369-dev (f52453d9)
Bug Description:
64bit register parameters in PPC SVR4 are "aligned" in terms of their offset from arg1/r3. Binja doesn't know that. That is, a function like:
int math2(int a, unsigned long long b)
Will take a in r3, skip r4, and take b in r5:r6.
Steps To Reproduce:
Dumb repro source:
int
blackhole(char c)
{
*(volatile char *)0x41414140 = c;
return (*(volatile int *)0x42424240);
}
int
math2(int a, unsigned long long b)
{
blackhole(a >> 24);
blackhole(a >> 16);
blackhole(a >> 8);
blackhole(a);
for (unsigned i=0;i < 8;i++) {
blackhole(b >> (8 * (i % 8)));
}
return (0);
}
unsigned long long
math(unsigned long long a)
{
return ((a << 3) | (a >> 61));
}
void _start(void)
{
unsigned long long foo;
foo = math(0x0102030405060708ULL);
blackhole(math(0x1121314151617181ULL));
math2(0xcafebeef, foo);
return;
}
Build: powerpc-none-eabi-gcc test.c -o test
Binary: polygonal entropy splits intuitively
HLIL in _start:
01800424 r3, r4 = math(0x1020304, 0x5060708)
01800440 int32_t r4_1 = math(0x11213141, 0x51617181)
01800454 blackhole(r4_1.b & 0xff)
01800468 math2(0xcafebeef, r4_1, r3, r4)
The extra r4_1 argument to math2 is incorrect. Not catastrophic here in this tiny case, but in my real binaries, printf calls with %llus sprinkled in get super messed up and confusing.
Of course this should also be concatenating the upper/lower halves back together in theory, but I imagine that's a separate, larger issue.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Start by building the supplied test with powerpc-none-eabi-gcc and inspect the _start HLIL, especially the calls to math and math2. Trace how the PPC SVR4 calling convention assigns 64-bit parameters from r3 onward; done means the math2 call no longer includes the spurious r4_1 argument and the affected 64-bit values are represented correctly.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c
- Ambito
- reverse-engineering
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100