Criticism of C aside, when you use a language that isn't very expressive and where it's easy to shoot yourself in the foot, you need to keep it very neat. I mean just look at this https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/pos... That size of methods, huge macros, the low ratio of comments to (non-obvious) statements etc. I know it's easy to criticize very old and tested code, but there is no (and never…
Glibc getaddrinfo stack-based buffer overflow
341–350 of 480 posts
Re: Glibc getaddrinfo stack-based buffer overflow
#342Re: Glibc getaddrinfo stack-based buffer overflow
#343Earlier quoted context omitted.
That's such an irrational assertion, ironically enough. Every decision has a trade off, even non-engineering decisions. It's called opportunity cost.
Opportunity cost doesn't make all decisions zero-sum. There is a quirk of human psychology that makes us believe that most things must be zero sum (i.e. that anything I do that improves something I care about must have a 'payback' at a later date and that to achieve a good outcome I must always make an equivalent sacrifice). JabavuAdams is falling for that. Although his inability to control his own violent emotional…
Re: Glibc getaddrinfo stack-based buffer overflow
#344Earlier quoted context omitted.
I'm still unsure why people start projects with C, or C++ (or other unsafe languages), that do not need it. I totally understand that there are use cases where C++ and C make sense. In my mind, these use cases are quite limited though - integration into 3rd party libraries, legacy codebases, and working in embedded environments. I also agree that performance can be a reason, but see Knuth's opinion on premature optim…
> Can people tell me why they start projects in broad C++, and C still? I may be completely missing some piece of the puzzle. Sure. --- Compelling features: - Unrivaled portability (yes, contrary to folklore C - and to a lesser extent C++ - is more portable than Java) - Excellent libraries - Excellent documentation and learning resources - Unrivaled tooling - perfect mapping to how the computer works - Unrivaled perf…
Re: Glibc getaddrinfo stack-based buffer overflow
#345Criticism of C aside, when you use a language that isn't very expressive and where it's easy to shoot yourself in the foot, you need to keep it very neat. I mean just look at this https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/pos... That size of methods, huge macros, the low ratio of comments to (non-obvious) statements etc. I know it's easy to criticize very old and tested code, but there is no (and never…
Compare to the musl implementation: http://git.musl-libc.org/cgit/musl/tree/src/network/getaddri...
But the musl code too has bloody ZERO comments for a nearly 100 line long method of dense/opaque C code! Why? Is commenting and splitting code into functions frowned upon in "traditional" systems programming?
Who is it that writes code like this? Why isn't code like this rejected by a maintainer with "split this into at least smaller 5 functions and comment anything non-obvious"?
Edit: looking again it's actually not that bad, it does have two lookups already broken out and a lot of the verbosity is just field assignment. Would be happy with a dozen lines of comments and a split into 2-3 functions.
Re: Glibc getaddrinfo stack-based buffer overflow
#346> "The glibc DNS client side resolver is vulnerable to a stack-based buffer overflow when the getaddrinfo() library function is used. Software using this function may be exploited with attacker-controlled domain names, attacker-controlled DNS servers, or through a man-in-the-middle attack." > "The vectors to trigger this buffer overflow are very common and can include ssh, sudo, and curl. We are confident that the ex…
Will you bell the cat? I'd pay a lot of money to see Linus' reaction to your massive network-stack replacement kernel patch written in Rust.
More seriously though, who is prepared to fund this? Is the risk worth that much effort? Because I see a lot of people being vocal about it on HN, but no real attempt is made to come up with a safe Rust-based alternatives
Re: Glibc getaddrinfo stack-based buffer overflow
#347> "The glibc DNS client side resolver is vulnerable to a stack-based buffer overflow when the getaddrinfo() library function is used. Software using this function may be exploited with attacker-controlled domain names, attacker-controlled DNS servers, or through a man-in-the-middle attack." > "The vectors to trigger this buffer overflow are very common and can include ssh, sudo, and curl. We are confident that the ex…
Re: Glibc getaddrinfo stack-based buffer overflow
#348Earlier quoted context omitted.
Um, what? char too_small_buffer[256]; function_that_expects_a_big_buffer(too_small_buffer); There's even a paragraph on Wikipedia debunking this idea: https://en.wikipedia.org/wiki/Stack_buffer_overflow#Stacks_t...
Wikipedia is wrong. It is not naive. Yes, this does not solve every possible stack overwrite. But look at the number that have actually happened in the field and whether this would have dramatically reduced vulnerability in those actual real-world cases. Most times it would. Most notably, for overwrites happening within the local stack frame, you completely remove the possibility of overwriting the return address. Th…
void
dumb_func(char *user_input) {
char buf[64];
sprintf(buf, "reformatted: %s", user_input);
}
Overflows in functions whose activation records precede the buffer are --- obviously, because they necessarily involve hand-rolled copy loops --- rarer than those that don't.Additional fun fact: a few early generations of mid-90s stack overflow exploits didn't even target the activation records at all!
I think it's interesting and worthwhile to consider whether stacks growing upwards would have made exploit development meaningfully harder, but I also think the answer to that question is straightforward: no, not really.
Re: Glibc getaddrinfo stack-based buffer overflow
#349Earlier quoted context omitted.
C++ is not reasonable if your goal is to avoid memory safety bugs.
> C++ is not reasonable if your goal is to avoid memory safety bugs. I'll get crucified for saying this but it's easier to write safe code in C++ than C. C requires a perfect discipline very few people can maintain. Cyclone-lang had good ideas about how to fix C, almost 10 years ago. I wish it has been more successful. i was less "alien" looking than Rust.
However, it is very hard to avoid C++ developers that don't follow the modern C++ mantra to use it as if it was C, specially in the enterprise space.
You end up with "C compiled with C++" code style, which usually isn't subjected to any kind of code reviews or static analysis.