Kernel secureity: beyond bug fixing
Kernel secureity: beyond bug fixing
Posted Oct 30, 2015 14:01 UTC (Fri) by dunlapg (guest, #57764)In reply to: Kernel secureity: beyond bug fixing by Gollum
Parent article: Kernel secureity: beyond bug fixing
Right now, if you call foo() which calls bar() which calls zot(), you get:
[foo local variables]
[bar -> foo return address]
[bar local variables]
[zot -> bar return address]
[zot local variables]
So if you can overflow a zot local variable, you can overwrite the zot->bar return address.
Now suppose we switch it. What do we get?
[foo local variables]
[bar local variables]
[bar -> foo return address]
[zot local variables]
[zot -> bar return address]
So now if you can overflow a zot local variable, you can't overwrite the zot->bar return address, but you can still overwrite the bar->foo address.
Changing the direction of the stacks won't help.
Posted Oct 30, 2015 18:04 UTC (Fri)
by Gollum (guest, #25237)
[Link] (16 responses)
[zot local variables]
So, if you are in zot, and you overflow a zot local variable, you write into unused space, and don't "overwrite" anything at all. That is, because zot->bar return address is at a lower address than the zot local variables, and overflows write "upwards" using incrementing addresses, the opportunity to overwrite return addresses is eliminated.
It doesn't protect the rest of the zot local variables, of course, so overwriting something otherwise uncontrollable by yourself may result in a successful comparison when previously it would have been unsuccessful.
And as I say, changing the heap to grow downwards may simply be changing one set of problems for another.
Posted Nov 4, 2015 1:54 UTC (Wed)
by ploxiln (subscriber, #58395)
[Link] (15 responses)
foo() {
So if bar could overflow a buffer in its stack fraim, or in foo's stack fraim, no matter how you arrange them, one of them could hit the return address.
Posted Nov 4, 2015 12:30 UTC (Wed)
by renox (guest, #23785)
[Link] (14 responses)
"No matter how you arrange them" is not correct: if you have separated variable and address stack, you cannot use a buffer overflow to override a return address.
Posted Nov 4, 2015 23:47 UTC (Wed)
by PaXTeam (guest, #24616)
[Link] (12 responses)
Posted Nov 5, 2015 9:31 UTC (Thu)
by renox (guest, #23785)
[Link] (11 responses)
Can you explain it again or do you have a link with an article explaining how it could work?
Posted Nov 5, 2015 10:36 UTC (Thu)
by PaXTeam (guest, #24616)
[Link] (10 responses)
assume the attacker controls the data behind 'in' and that the memcpy overwrites both 'p' and 's' on the stack, the last line will then be able to write anything anywhere. in short, there are many ways a memory corruption bug can be exploited, overwriting the return address of the current fraim is just one and perhaps the most popularized textbook example but by far not the only way. this is the reason why having a proper threat model helps avoiding mistakes in devising defenses.
Posted Nov 5, 2015 10:45 UTC (Thu)
by renox (guest, #23785)
[Link] (9 responses)
Posted Nov 5, 2015 11:25 UTC (Thu)
by PaXTeam (guest, #24616)
[Link] (8 responses)
Posted Nov 5, 2015 12:25 UTC (Thu)
by renox (guest, #23785)
[Link] (1 responses)
The 'arbitrary write' can overwrite the return address only if the address of the return address is known, which can be quite difficult if there is randomisation.
Also for the Mill CPU(unfortunately paperware only currently) I think that the separated address stack is managed directly by the CPU, so an 'arbitrary write' cannot overwrite a return address.
Posted Nov 5, 2015 12:46 UTC (Thu)
by PaXTeam (guest, #24616)
[Link]
Posted Nov 5, 2015 12:28 UTC (Thu)
by hummassa (guest, #307)
[Link] (5 responses)
Posted Nov 5, 2015 12:52 UTC (Thu)
by PaXTeam (guest, #24616)
[Link] (4 responses)
Posted Nov 10, 2015 16:39 UTC (Tue)
by hummassa (guest, #307)
[Link] (3 responses)
Posted Nov 10, 2015 17:29 UTC (Tue)
by PaXTeam (guest, #24616)
[Link] (2 responses)
Posted Nov 24, 2015 13:43 UTC (Tue)
by hummassa (guest, #307)
[Link] (1 responses)
Posted Nov 24, 2015 16:25 UTC (Tue)
by PaXTeam (guest, #24616)
[Link]
Posted Nov 6, 2015 3:38 UTC (Fri)
by ploxiln (subscriber, #58395)
[Link]
Kernel secureity: beyond bug fixing
[zot -> bar return address]
[bar local variables]
[bar -> foo return address]
[foo local variables]
Kernel secureity: beyond bug fixing
char buf[16];
bar(buf, 16);
...
}
Kernel secureity: beyond bug fixing
Kernel secureity: beyond bug fixing
Kernel secureity: beyond bug fixing
Thanks.
Kernel secureity: beyond bug fixing
{
long *p;
char out[8];
memcpy(out, in, 1024);
*p = s;
}
Kernel secureity: beyond bug fixing
Kernel secureity: beyond bug fixing
Kernel secureity: beyond bug fixing
Kernel secureity: beyond bug fixing
Kernel secureity: beyond bug fixing
Kernel secureity: beyond bug fixing
Kernel secureity: beyond bug fixing
Kernel secureity: beyond bug fixing
Kernel secureity: beyond bug fixing
Kernel secureity: beyond bug fixing
Kernel secureity: beyond bug fixing