Re:Glibc getaddrinfo stack-based buffer overflow
by GregBuchholz on Tuesday February 16, 2016 @03:40PM
(#11112971)
Have you looked at CCured?
http://www.cs.berkeley.edu/~necula/Papers/ccured_pldi03.pdf
"CCured is a program transformation system that adds memory safety guarantees to C programs by verifying statically that memory errors cannot occur and by inserting run-time checks where static verification is insufficient."
Re:Glibc getaddrinfo stack-based buffer overflow
by mikeash on Wednesday February 17, 2016 @09:56AM
(#11118204)
I haven't heard of it before, but that's the sort of thing I'm thinking of, and that looks pretty cool. Looks like the resulting programs still perform reasonably well too.
Re:Glibc getaddrinfo stack-based buffer overflow
by steveklabnik on Tuesday February 16, 2016 @01:58PM
(#11112240)
This is sort of what Cyclone tried, in a way.
Re:Glibc getaddrinfo stack-based buffer overflow
by mikeash on Tuesday February 16, 2016 @02:06PM
(#11112287)
Cyclone looks cool, but it's a pretty significant departure from normal C. I'm wondering how far you can take safety without changing the actual language at all. Or rather, how far you can take safety without changing the language and without completely killing performance. Memory safety shouldn't be hard: track all valid regions and pointers to them and don't allow mixing stuff up. But doing it fast is tough.
The C standard doesn't require the compiler to check the validity of array indexing and pointer dereferences and such, but it also doesn't require the compiler not to. Can they be added without destroying performance and compatibility?
Some of this already exists, with stuff like stack canaries and address sanitizer. But can it go beyond these ad hoc solutions that catch common mishaps, and become something truly reliable?
It should be possible to just flip a switch on the compiler and have it so that, for example, if you alloca() X bytes and then use the resulting pointer to access byte X+1, that is reliably caught at runtime. And not just as some single patch that specifically looks out for alloca() abuse, but as part of a wider system that understands and catches all out of bounds access.